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

Merge tag 'mfd-3.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6

Pull MFS update from Samuel Ortiz:
"This is the MFD patch set for the 3.8 merge window.

We have several new drivers, most of the time coming with their sub
devices drivers:

- Austria Microsystem's AS3711
- Nano River's viperboard
- TI's TPS80031, AM335x TS/ADC,
- Realtek's MMC/memstick card reader
- Nokia's retu

We also got some notable cleanups and improvements:

- tps6586x got converted to IRQ domains.
- tps65910 and tps65090 moved to the regmap IRQ API.
- STMPE is now Device Tree aware.
- A general twl6040 and twl-core cleanup, with moves to the regmap
I/O and IRQ APIs and a conversion to the recently added PWM
framework.
- sta2x11 gained regmap support.

Then the rest is mostly tiny cleanups and fixes, among which we have
Mark's wm5xxx and wm8xxx patchset."

Far amount of annoying but largely trivial conflicts. Many due to
__devinit/exit removal, others due to one or two of the new drivers also
having come in through another tree.

* tag 'mfd-3.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6: (119 commits)
mfd: tps6507x: Convert to devm_kzalloc
mfd: stmpe: Update DT support for stmpe driver
mfd: wm5102: Add readback of DSP status 3 register
mfd: arizona: Log if we fail to create the primary IRQ domain
mfd: tps80031: MFD_TPS80031 needs to select REGMAP_IRQ
mfd: tps80031: Add terminating entry for tps80031_id_table
mfd: sta2x11: Fix potential NULL pointer dereference in __sta2x11_mfd_mask()
mfd: wm5102: Add tuning for revision B
mfd: arizona: Defer patch initialistation until after first device boot
mfd: tps65910: Fix wrong ack_base register
mfd: tps65910: Remove unused data
mfd: stmpe: Get rid of irq_invert_polarity
mfd: ab8500-core: Fix invalid free of devm_ allocated data
mfd: wm5102: Mark DSP memory regions as volatile
mfd: wm5102: Correct default for LDO1_CONTROL_2
mfd: arizona: Register haptics devices
mfd: wm8994: Make current device behaviour the default
mfd: tps65090: MFD_TPS65090 needs to select REGMAP_IRQ
mfd: Fix stmpe.c build when OF is not enabled
mfd: jz4740-adc: Use devm_kzalloc
...

+6785 -2460
+28
Documentation/devicetree/bindings/mfd/stmpe.txt
··· 1 + * ST Microelectronics STMPE Multi-Functional Device 2 + 3 + STMPE is an MFD device which may expose the following inbuilt devices: gpio, 4 + keypad, touchscreen, adc, pwm, rotator. 5 + 6 + Required properties: 7 + - compatible : "st,stmpe[610|801|811|1601|2401|2403]" 8 + - reg : I2C/SPI address of the device 9 + 10 + Optional properties: 11 + - interrupts : The interrupt outputs from the controller 12 + - interrupt-controller : Marks the device node as an interrupt controller 13 + - interrupt-parent : Specifies which IRQ controller we're connected to 14 + - wakeup-source : Marks the input device as wakable 15 + - st,autosleep-timeout : Valid entries (ms); 4, 16, 32, 64, 128, 256, 512 and 1024 16 + 17 + Example: 18 + 19 + stmpe1601: stmpe1601@40 { 20 + compatible = "st,stmpe1601"; 21 + reg = <0x40>; 22 + interrupts = <26 0x4>; 23 + interrupt-parent = <&gpio6>; 24 + interrupt-controller; 25 + 26 + wakeup-source; 27 + st,autosleep-timeout = <1024>; 28 + };
+4
Documentation/devicetree/bindings/regulator/tps65217.txt
··· 11 11 using the standard binding for regulators found at 12 12 Documentation/devicetree/bindings/regulator/regulator.txt. 13 13 14 + Optional properties: 15 + - ti,pmic-shutdown-controller: Telling the PMIC to shutdown on PWR_EN toggle. 16 + 14 17 The valid names for regulators are: 15 18 tps65217: dcdc1, dcdc2, dcdc3, ldo1, ldo2, ldo3 and ldo4 16 19 ··· 23 20 24 21 tps: tps@24 { 25 22 compatible = "ti,tps65217"; 23 + ti,pmic-shutdown-controller; 26 24 27 25 regulators { 28 26 dcdc1_reg: dcdc1 {
+13
drivers/gpio/Kconfig
··· 683 683 Enable support for GPIO on intel MSIC controllers found in 684 684 intel MID devices 685 685 686 + comment "USB GPIO expanders:" 687 + 688 + config GPIO_VIPERBOARD 689 + tristate "Viperboard GPIO a & b support" 690 + depends on MFD_VIPERBOARD && USB 691 + help 692 + Say yes here to access the GPIO signals of Nano River 693 + Technologies Viperboard. There are two GPIO chips on the 694 + board: gpioa and gpiob. 695 + See viperboard API specification and Nano 696 + River Tech's viperboard.h for detailed meaning 697 + of the module parameters. 698 + 686 699 endif
+1
drivers/gpio/Makefile
··· 76 76 obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o 77 77 obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.o 78 78 obj-$(CONFIG_GPIO_UCB1400) += gpio-ucb1400.o 79 + obj-$(CONFIG_GPIO_VIPERBOARD) += gpio-viperboard.o 79 80 obj-$(CONFIG_GPIO_VR41XX) += gpio-vr41xx.o 80 81 obj-$(CONFIG_GPIO_VT8500) += gpio-vt8500.o 81 82 obj-$(CONFIG_GPIO_VX855) += gpio-vx855.o
+5 -1
drivers/gpio/gpio-da9052.c
··· 185 185 struct da9052_gpio *gpio = to_da9052_gpio(gc); 186 186 struct da9052 *da9052 = gpio->da9052; 187 187 188 - return da9052->irq_base + DA9052_IRQ_GPI0 + offset; 188 + int irq; 189 + 190 + irq = regmap_irq_get_virq(da9052->irq_data, DA9052_IRQ_GPI0 + offset); 191 + 192 + return irq; 189 193 } 190 194 191 195 static struct gpio_chip reference_gp = {
+9
drivers/gpio/gpio-tps6586x.c
··· 80 80 val, mask); 81 81 } 82 82 83 + static int tps6586x_gpio_to_irq(struct gpio_chip *gc, unsigned offset) 84 + { 85 + struct tps6586x_gpio *tps6586x_gpio = to_tps6586x_gpio(gc); 86 + 87 + return tps6586x_irq_get_virq(tps6586x_gpio->parent, 88 + TPS6586X_INT_PLDO_0 + offset); 89 + } 90 + 83 91 static int tps6586x_gpio_probe(struct platform_device *pdev) 84 92 { 85 93 struct tps6586x_platform_data *pdata; ··· 114 106 tps6586x_gpio->gpio_chip.direction_output = tps6586x_gpio_output; 115 107 tps6586x_gpio->gpio_chip.set = tps6586x_gpio_set; 116 108 tps6586x_gpio->gpio_chip.get = tps6586x_gpio_get; 109 + tps6586x_gpio->gpio_chip.to_irq = tps6586x_gpio_to_irq; 117 110 118 111 #ifdef CONFIG_OF_GPIO 119 112 tps6586x_gpio->gpio_chip.of_node = pdev->dev.parent->of_node;
+6 -6
drivers/gpio/gpio-twl4030.c
··· 355 355 356 356 static int gpio_twl4030_pulls(u32 ups, u32 downs) 357 357 { 358 - u8 message[6]; 358 + u8 message[5]; 359 359 unsigned i, gpio_bit; 360 360 361 361 /* For most pins, a pulldown was enabled by default. 362 362 * We should have data that's specific to this board. 363 363 */ 364 - for (gpio_bit = 1, i = 1; i < 6; i++) { 364 + for (gpio_bit = 1, i = 0; i < 5; i++) { 365 365 u8 bit_mask; 366 366 unsigned j; 367 367 ··· 380 380 381 381 static int gpio_twl4030_debounce(u32 debounce, u8 mmc_cd) 382 382 { 383 - u8 message[4]; 383 + u8 message[3]; 384 384 385 385 /* 30 msec of debouncing is always used for MMC card detect, 386 386 * and is optional for everything else. 387 387 */ 388 - message[1] = (debounce & 0xff) | (mmc_cd & 0x03); 388 + message[0] = (debounce & 0xff) | (mmc_cd & 0x03); 389 389 debounce >>= 8; 390 - message[2] = (debounce & 0xff); 390 + message[1] = (debounce & 0xff); 391 391 debounce >>= 8; 392 - message[3] = (debounce & 0x03); 392 + message[2] = (debounce & 0x03); 393 393 394 394 return twl_i2c_write(TWL4030_MODULE_GPIO, message, 395 395 REG_GPIO_DEBEN1, 3);
+517
drivers/gpio/gpio-viperboard.c
··· 1 + /* 2 + * Nano River Technologies viperboard GPIO lib driver 3 + * 4 + * (C) 2012 by Lemonage GmbH 5 + * Author: Lars Poeschel <poeschel@lemonage.de> 6 + * All rights reserved. 7 + * 8 + * This program is free software; you can redistribute it and/or modify it 9 + * under the terms of the GNU General Public License as published by the 10 + * Free Software Foundation; either version 2 of the License, or (at your 11 + * option) any later version. 12 + * 13 + */ 14 + 15 + #include <linux/kernel.h> 16 + #include <linux/errno.h> 17 + #include <linux/module.h> 18 + #include <linux/slab.h> 19 + #include <linux/types.h> 20 + #include <linux/mutex.h> 21 + #include <linux/platform_device.h> 22 + 23 + #include <linux/usb.h> 24 + #include <linux/gpio.h> 25 + 26 + #include <linux/mfd/viperboard.h> 27 + 28 + #define VPRBRD_GPIOA_CLK_1MHZ 0 29 + #define VPRBRD_GPIOA_CLK_100KHZ 1 30 + #define VPRBRD_GPIOA_CLK_10KHZ 2 31 + #define VPRBRD_GPIOA_CLK_1KHZ 3 32 + #define VPRBRD_GPIOA_CLK_100HZ 4 33 + #define VPRBRD_GPIOA_CLK_10HZ 5 34 + 35 + #define VPRBRD_GPIOA_FREQ_DEFAULT 1000 36 + 37 + #define VPRBRD_GPIOA_CMD_CONT 0x00 38 + #define VPRBRD_GPIOA_CMD_PULSE 0x01 39 + #define VPRBRD_GPIOA_CMD_PWM 0x02 40 + #define VPRBRD_GPIOA_CMD_SETOUT 0x03 41 + #define VPRBRD_GPIOA_CMD_SETIN 0x04 42 + #define VPRBRD_GPIOA_CMD_SETINT 0x05 43 + #define VPRBRD_GPIOA_CMD_GETIN 0x06 44 + 45 + #define VPRBRD_GPIOB_CMD_SETDIR 0x00 46 + #define VPRBRD_GPIOB_CMD_SETVAL 0x01 47 + 48 + struct vprbrd_gpioa_msg { 49 + u8 cmd; 50 + u8 clk; 51 + u8 offset; 52 + u8 t1; 53 + u8 t2; 54 + u8 invert; 55 + u8 pwmlevel; 56 + u8 outval; 57 + u8 risefall; 58 + u8 answer; 59 + u8 __fill; 60 + } __packed; 61 + 62 + struct vprbrd_gpiob_msg { 63 + u8 cmd; 64 + u16 val; 65 + u16 mask; 66 + } __packed; 67 + 68 + struct vprbrd_gpio { 69 + struct gpio_chip gpioa; /* gpio a related things */ 70 + u32 gpioa_out; 71 + u32 gpioa_val; 72 + struct gpio_chip gpiob; /* gpio b related things */ 73 + u32 gpiob_out; 74 + u32 gpiob_val; 75 + struct vprbrd *vb; 76 + }; 77 + 78 + /* gpioa sampling clock module parameter */ 79 + static unsigned char gpioa_clk; 80 + static unsigned int gpioa_freq = VPRBRD_GPIOA_FREQ_DEFAULT; 81 + module_param(gpioa_freq, uint, 0); 82 + MODULE_PARM_DESC(gpioa_freq, 83 + "gpio-a sampling freq in Hz (default is 1000Hz) valid values: 10, 100, 1000, 10000, 100000, 1000000"); 84 + 85 + /* ----- begin of gipo a chip -------------------------------------------- */ 86 + 87 + static int vprbrd_gpioa_get(struct gpio_chip *chip, 88 + unsigned offset) 89 + { 90 + int ret, answer, error = 0; 91 + struct vprbrd_gpio *gpio = 92 + container_of(chip, struct vprbrd_gpio, gpioa); 93 + struct vprbrd *vb = gpio->vb; 94 + struct vprbrd_gpioa_msg *gamsg = (struct vprbrd_gpioa_msg *)vb->buf; 95 + 96 + /* if io is set to output, just return the saved value */ 97 + if (gpio->gpioa_out & (1 << offset)) 98 + return gpio->gpioa_val & (1 << offset); 99 + 100 + mutex_lock(&vb->lock); 101 + 102 + gamsg->cmd = VPRBRD_GPIOA_CMD_GETIN; 103 + gamsg->clk = 0x00; 104 + gamsg->offset = offset; 105 + gamsg->t1 = 0x00; 106 + gamsg->t2 = 0x00; 107 + gamsg->invert = 0x00; 108 + gamsg->pwmlevel = 0x00; 109 + gamsg->outval = 0x00; 110 + gamsg->risefall = 0x00; 111 + gamsg->answer = 0x00; 112 + gamsg->__fill = 0x00; 113 + 114 + ret = usb_control_msg(vb->usb_dev, usb_sndctrlpipe(vb->usb_dev, 0), 115 + VPRBRD_USB_REQUEST_GPIOA, VPRBRD_USB_TYPE_OUT, 0x0000, 116 + 0x0000, gamsg, sizeof(struct vprbrd_gpioa_msg), 117 + VPRBRD_USB_TIMEOUT_MS); 118 + if (ret != sizeof(struct vprbrd_gpioa_msg)) 119 + error = -EREMOTEIO; 120 + 121 + ret = usb_control_msg(vb->usb_dev, usb_rcvctrlpipe(vb->usb_dev, 0), 122 + VPRBRD_USB_REQUEST_GPIOA, VPRBRD_USB_TYPE_IN, 0x0000, 123 + 0x0000, gamsg, sizeof(struct vprbrd_gpioa_msg), 124 + VPRBRD_USB_TIMEOUT_MS); 125 + answer = gamsg->answer & 0x01; 126 + 127 + mutex_unlock(&vb->lock); 128 + 129 + if (ret != sizeof(struct vprbrd_gpioa_msg)) 130 + error = -EREMOTEIO; 131 + 132 + if (error) 133 + return error; 134 + 135 + return answer; 136 + } 137 + 138 + static void vprbrd_gpioa_set(struct gpio_chip *chip, 139 + unsigned offset, int value) 140 + { 141 + int ret; 142 + struct vprbrd_gpio *gpio = 143 + container_of(chip, struct vprbrd_gpio, gpioa); 144 + struct vprbrd *vb = gpio->vb; 145 + struct vprbrd_gpioa_msg *gamsg = (struct vprbrd_gpioa_msg *)vb->buf; 146 + 147 + if (gpio->gpioa_out & (1 << offset)) { 148 + if (value) 149 + gpio->gpioa_val |= (1 << offset); 150 + else 151 + gpio->gpioa_val &= ~(1 << offset); 152 + 153 + mutex_lock(&vb->lock); 154 + 155 + gamsg->cmd = VPRBRD_GPIOA_CMD_SETOUT; 156 + gamsg->clk = 0x00; 157 + gamsg->offset = offset; 158 + gamsg->t1 = 0x00; 159 + gamsg->t2 = 0x00; 160 + gamsg->invert = 0x00; 161 + gamsg->pwmlevel = 0x00; 162 + gamsg->outval = value; 163 + gamsg->risefall = 0x00; 164 + gamsg->answer = 0x00; 165 + gamsg->__fill = 0x00; 166 + 167 + ret = usb_control_msg(vb->usb_dev, 168 + usb_sndctrlpipe(vb->usb_dev, 0), 169 + VPRBRD_USB_REQUEST_GPIOA, VPRBRD_USB_TYPE_OUT, 170 + 0x0000, 0x0000, gamsg, 171 + sizeof(struct vprbrd_gpioa_msg), VPRBRD_USB_TIMEOUT_MS); 172 + 173 + mutex_unlock(&vb->lock); 174 + 175 + if (ret != sizeof(struct vprbrd_gpioa_msg)) 176 + dev_err(chip->dev, "usb error setting pin value\n"); 177 + } 178 + } 179 + 180 + static int vprbrd_gpioa_direction_input(struct gpio_chip *chip, 181 + unsigned offset) 182 + { 183 + int ret; 184 + struct vprbrd_gpio *gpio = 185 + container_of(chip, struct vprbrd_gpio, gpioa); 186 + struct vprbrd *vb = gpio->vb; 187 + struct vprbrd_gpioa_msg *gamsg = (struct vprbrd_gpioa_msg *)vb->buf; 188 + 189 + gpio->gpioa_out &= ~(1 << offset); 190 + 191 + mutex_lock(&vb->lock); 192 + 193 + gamsg->cmd = VPRBRD_GPIOA_CMD_SETIN; 194 + gamsg->clk = gpioa_clk; 195 + gamsg->offset = offset; 196 + gamsg->t1 = 0x00; 197 + gamsg->t2 = 0x00; 198 + gamsg->invert = 0x00; 199 + gamsg->pwmlevel = 0x00; 200 + gamsg->outval = 0x00; 201 + gamsg->risefall = 0x00; 202 + gamsg->answer = 0x00; 203 + gamsg->__fill = 0x00; 204 + 205 + ret = usb_control_msg(vb->usb_dev, usb_sndctrlpipe(vb->usb_dev, 0), 206 + VPRBRD_USB_REQUEST_GPIOA, VPRBRD_USB_TYPE_OUT, 0x0000, 207 + 0x0000, gamsg, sizeof(struct vprbrd_gpioa_msg), 208 + VPRBRD_USB_TIMEOUT_MS); 209 + 210 + mutex_unlock(&vb->lock); 211 + 212 + if (ret != sizeof(struct vprbrd_gpioa_msg)) 213 + return -EREMOTEIO; 214 + 215 + return 0; 216 + } 217 + 218 + static int vprbrd_gpioa_direction_output(struct gpio_chip *chip, 219 + unsigned offset, int value) 220 + { 221 + int ret; 222 + struct vprbrd_gpio *gpio = 223 + container_of(chip, struct vprbrd_gpio, gpioa); 224 + struct vprbrd *vb = gpio->vb; 225 + struct vprbrd_gpioa_msg *gamsg = (struct vprbrd_gpioa_msg *)vb->buf; 226 + 227 + gpio->gpioa_out |= (1 << offset); 228 + if (value) 229 + gpio->gpioa_val |= (1 << offset); 230 + else 231 + gpio->gpioa_val &= ~(1 << offset); 232 + 233 + mutex_lock(&vb->lock); 234 + 235 + gamsg->cmd = VPRBRD_GPIOA_CMD_SETOUT; 236 + gamsg->clk = 0x00; 237 + gamsg->offset = offset; 238 + gamsg->t1 = 0x00; 239 + gamsg->t2 = 0x00; 240 + gamsg->invert = 0x00; 241 + gamsg->pwmlevel = 0x00; 242 + gamsg->outval = value; 243 + gamsg->risefall = 0x00; 244 + gamsg->answer = 0x00; 245 + gamsg->__fill = 0x00; 246 + 247 + ret = usb_control_msg(vb->usb_dev, usb_sndctrlpipe(vb->usb_dev, 0), 248 + VPRBRD_USB_REQUEST_GPIOA, VPRBRD_USB_TYPE_OUT, 0x0000, 249 + 0x0000, gamsg, sizeof(struct vprbrd_gpioa_msg), 250 + VPRBRD_USB_TIMEOUT_MS); 251 + 252 + mutex_unlock(&vb->lock); 253 + 254 + if (ret != sizeof(struct vprbrd_gpioa_msg)) 255 + return -EREMOTEIO; 256 + 257 + return 0; 258 + } 259 + 260 + /* ----- end of gpio a chip ---------------------------------------------- */ 261 + 262 + /* ----- begin of gipo b chip -------------------------------------------- */ 263 + 264 + static int vprbrd_gpiob_setdir(struct vprbrd *vb, unsigned offset, 265 + unsigned dir) 266 + { 267 + struct vprbrd_gpiob_msg *gbmsg = (struct vprbrd_gpiob_msg *)vb->buf; 268 + int ret; 269 + 270 + gbmsg->cmd = VPRBRD_GPIOB_CMD_SETDIR; 271 + gbmsg->val = cpu_to_be16(dir << offset); 272 + gbmsg->mask = cpu_to_be16(0x0001 << offset); 273 + 274 + ret = usb_control_msg(vb->usb_dev, usb_sndctrlpipe(vb->usb_dev, 0), 275 + VPRBRD_USB_REQUEST_GPIOB, VPRBRD_USB_TYPE_OUT, 0x0000, 276 + 0x0000, gbmsg, sizeof(struct vprbrd_gpiob_msg), 277 + VPRBRD_USB_TIMEOUT_MS); 278 + 279 + if (ret != sizeof(struct vprbrd_gpiob_msg)) 280 + return -EREMOTEIO; 281 + 282 + return 0; 283 + } 284 + 285 + static int vprbrd_gpiob_get(struct gpio_chip *chip, 286 + unsigned offset) 287 + { 288 + int ret; 289 + u16 val; 290 + struct vprbrd_gpio *gpio = 291 + container_of(chip, struct vprbrd_gpio, gpiob); 292 + struct vprbrd *vb = gpio->vb; 293 + struct vprbrd_gpiob_msg *gbmsg = (struct vprbrd_gpiob_msg *)vb->buf; 294 + 295 + /* if io is set to output, just return the saved value */ 296 + if (gpio->gpiob_out & (1 << offset)) 297 + return gpio->gpiob_val & (1 << offset); 298 + 299 + mutex_lock(&vb->lock); 300 + 301 + ret = usb_control_msg(vb->usb_dev, usb_rcvctrlpipe(vb->usb_dev, 0), 302 + VPRBRD_USB_REQUEST_GPIOB, VPRBRD_USB_TYPE_IN, 0x0000, 303 + 0x0000, gbmsg, sizeof(struct vprbrd_gpiob_msg), 304 + VPRBRD_USB_TIMEOUT_MS); 305 + val = gbmsg->val; 306 + 307 + mutex_unlock(&vb->lock); 308 + 309 + if (ret != sizeof(struct vprbrd_gpiob_msg)) 310 + return ret; 311 + 312 + /* cache the read values */ 313 + gpio->gpiob_val = be16_to_cpu(val); 314 + 315 + return (gpio->gpiob_val >> offset) & 0x1; 316 + } 317 + 318 + static void vprbrd_gpiob_set(struct gpio_chip *chip, 319 + unsigned offset, int value) 320 + { 321 + int ret; 322 + struct vprbrd_gpio *gpio = 323 + container_of(chip, struct vprbrd_gpio, gpiob); 324 + struct vprbrd *vb = gpio->vb; 325 + struct vprbrd_gpiob_msg *gbmsg = (struct vprbrd_gpiob_msg *)vb->buf; 326 + 327 + if (gpio->gpiob_out & (1 << offset)) { 328 + if (value) 329 + gpio->gpiob_val |= (1 << offset); 330 + else 331 + gpio->gpiob_val &= ~(1 << offset); 332 + 333 + mutex_lock(&vb->lock); 334 + 335 + gbmsg->cmd = VPRBRD_GPIOB_CMD_SETVAL; 336 + gbmsg->val = cpu_to_be16(value << offset); 337 + gbmsg->mask = cpu_to_be16(0x0001 << offset); 338 + 339 + ret = usb_control_msg(vb->usb_dev, 340 + usb_sndctrlpipe(vb->usb_dev, 0), 341 + VPRBRD_USB_REQUEST_GPIOB, VPRBRD_USB_TYPE_OUT, 342 + 0x0000, 0x0000, gbmsg, 343 + sizeof(struct vprbrd_gpiob_msg), VPRBRD_USB_TIMEOUT_MS); 344 + 345 + mutex_unlock(&vb->lock); 346 + 347 + if (ret != sizeof(struct vprbrd_gpiob_msg)) 348 + dev_err(chip->dev, "usb error setting pin value\n"); 349 + } 350 + } 351 + 352 + static int vprbrd_gpiob_direction_input(struct gpio_chip *chip, 353 + unsigned offset) 354 + { 355 + int ret; 356 + struct vprbrd_gpio *gpio = 357 + container_of(chip, struct vprbrd_gpio, gpiob); 358 + struct vprbrd *vb = gpio->vb; 359 + 360 + gpio->gpiob_out &= ~(1 << offset); 361 + 362 + mutex_lock(&vb->lock); 363 + 364 + ret = vprbrd_gpiob_setdir(vb, offset, 0); 365 + 366 + mutex_unlock(&vb->lock); 367 + 368 + if (ret) 369 + dev_err(chip->dev, "usb error setting pin to input\n"); 370 + 371 + return ret; 372 + } 373 + 374 + static int vprbrd_gpiob_direction_output(struct gpio_chip *chip, 375 + unsigned offset, int value) 376 + { 377 + int ret; 378 + struct vprbrd_gpio *gpio = 379 + container_of(chip, struct vprbrd_gpio, gpiob); 380 + struct vprbrd *vb = gpio->vb; 381 + 382 + gpio->gpiob_out |= (1 << offset); 383 + if (value) 384 + gpio->gpiob_val |= (1 << offset); 385 + else 386 + gpio->gpiob_val &= ~(1 << offset); 387 + 388 + mutex_lock(&vb->lock); 389 + 390 + ret = vprbrd_gpiob_setdir(vb, offset, 1); 391 + if (ret) 392 + dev_err(chip->dev, "usb error setting pin to output\n"); 393 + 394 + mutex_unlock(&vb->lock); 395 + 396 + vprbrd_gpiob_set(chip, offset, value); 397 + 398 + return ret; 399 + } 400 + 401 + /* ----- end of gpio b chip ---------------------------------------------- */ 402 + 403 + static int __devinit vprbrd_gpio_probe(struct platform_device *pdev) 404 + { 405 + struct vprbrd *vb = dev_get_drvdata(pdev->dev.parent); 406 + struct vprbrd_gpio *vb_gpio; 407 + int ret; 408 + 409 + vb_gpio = devm_kzalloc(&pdev->dev, sizeof(*vb_gpio), GFP_KERNEL); 410 + if (vb_gpio == NULL) 411 + return -ENOMEM; 412 + 413 + vb_gpio->vb = vb; 414 + /* registering gpio a */ 415 + vb_gpio->gpioa.label = "viperboard gpio a"; 416 + vb_gpio->gpioa.dev = &pdev->dev; 417 + vb_gpio->gpioa.owner = THIS_MODULE; 418 + vb_gpio->gpioa.base = -1; 419 + vb_gpio->gpioa.ngpio = 16; 420 + vb_gpio->gpioa.can_sleep = 1; 421 + vb_gpio->gpioa.set = vprbrd_gpioa_set; 422 + vb_gpio->gpioa.get = vprbrd_gpioa_get; 423 + vb_gpio->gpioa.direction_input = vprbrd_gpioa_direction_input; 424 + vb_gpio->gpioa.direction_output = vprbrd_gpioa_direction_output; 425 + ret = gpiochip_add(&vb_gpio->gpioa); 426 + if (ret < 0) { 427 + dev_err(vb_gpio->gpioa.dev, "could not add gpio a"); 428 + goto err_gpioa; 429 + } 430 + 431 + /* registering gpio b */ 432 + vb_gpio->gpiob.label = "viperboard gpio b"; 433 + vb_gpio->gpiob.dev = &pdev->dev; 434 + vb_gpio->gpiob.owner = THIS_MODULE; 435 + vb_gpio->gpiob.base = -1; 436 + vb_gpio->gpiob.ngpio = 16; 437 + vb_gpio->gpiob.can_sleep = 1; 438 + vb_gpio->gpiob.set = vprbrd_gpiob_set; 439 + vb_gpio->gpiob.get = vprbrd_gpiob_get; 440 + vb_gpio->gpiob.direction_input = vprbrd_gpiob_direction_input; 441 + vb_gpio->gpiob.direction_output = vprbrd_gpiob_direction_output; 442 + ret = gpiochip_add(&vb_gpio->gpiob); 443 + if (ret < 0) { 444 + dev_err(vb_gpio->gpiob.dev, "could not add gpio b"); 445 + goto err_gpiob; 446 + } 447 + 448 + platform_set_drvdata(pdev, vb_gpio); 449 + 450 + return ret; 451 + 452 + err_gpiob: 453 + ret = gpiochip_remove(&vb_gpio->gpioa); 454 + 455 + err_gpioa: 456 + return ret; 457 + } 458 + 459 + static int __devexit vprbrd_gpio_remove(struct platform_device *pdev) 460 + { 461 + struct vprbrd_gpio *vb_gpio = platform_get_drvdata(pdev); 462 + int ret; 463 + 464 + ret = gpiochip_remove(&vb_gpio->gpiob); 465 + if (ret == 0) 466 + ret = gpiochip_remove(&vb_gpio->gpioa); 467 + 468 + return ret; 469 + } 470 + 471 + static struct platform_driver vprbrd_gpio_driver = { 472 + .driver.name = "viperboard-gpio", 473 + .driver.owner = THIS_MODULE, 474 + .probe = vprbrd_gpio_probe, 475 + .remove = __devexit_p(vprbrd_gpio_remove), 476 + }; 477 + 478 + static int __init vprbrd_gpio_init(void) 479 + { 480 + switch (gpioa_freq) { 481 + case 1000000: 482 + gpioa_clk = VPRBRD_GPIOA_CLK_1MHZ; 483 + break; 484 + case 100000: 485 + gpioa_clk = VPRBRD_GPIOA_CLK_100KHZ; 486 + break; 487 + case 10000: 488 + gpioa_clk = VPRBRD_GPIOA_CLK_10KHZ; 489 + break; 490 + case 1000: 491 + gpioa_clk = VPRBRD_GPIOA_CLK_1KHZ; 492 + break; 493 + case 100: 494 + gpioa_clk = VPRBRD_GPIOA_CLK_100HZ; 495 + break; 496 + case 10: 497 + gpioa_clk = VPRBRD_GPIOA_CLK_10HZ; 498 + break; 499 + default: 500 + pr_warn("invalid gpioa_freq (%d)\n", gpioa_freq); 501 + gpioa_clk = VPRBRD_GPIOA_CLK_1KHZ; 502 + } 503 + 504 + return platform_driver_register(&vprbrd_gpio_driver); 505 + } 506 + subsys_initcall(vprbrd_gpio_init); 507 + 508 + static void __exit vprbrd_gpio_exit(void) 509 + { 510 + platform_driver_unregister(&vprbrd_gpio_driver); 511 + } 512 + module_exit(vprbrd_gpio_exit); 513 + 514 + MODULE_AUTHOR("Lars Poeschel <poeschel@lemonage.de>"); 515 + MODULE_DESCRIPTION("GPIO driver for Nano River Techs Viperboard"); 516 + MODULE_LICENSE("GPL"); 517 + MODULE_ALIAS("platform:viperboard-gpio");
+10
drivers/i2c/busses/Kconfig
··· 818 818 This driver can also be built as a module. If so, the module 819 819 will be called i2c-tiny-usb. 820 820 821 + config I2C_VIPERBOARD 822 + tristate "Viperboard I2C master support" 823 + depends on MFD_VIPERBOARD && USB 824 + help 825 + Say yes here to access the I2C part of the Nano River 826 + Technologies Viperboard as I2C master. 827 + See viperboard API specification and Nano 828 + River Tech's viperboard.h for detailed meaning 829 + of the module parameters. 830 + 821 831 comment "Other I2C/SMBus bus drivers" 822 832 823 833 config I2C_ACORN
+1
drivers/i2c/busses/Makefile
··· 79 79 obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o 80 80 obj-$(CONFIG_I2C_TAOS_EVM) += i2c-taos-evm.o 81 81 obj-$(CONFIG_I2C_TINY_USB) += i2c-tiny-usb.o 82 + obj-$(CONFIG_I2C_VIPERBOARD) += i2c-viperboard.o 82 83 83 84 # Other I2C/SMBus bus drivers 84 85 obj-$(CONFIG_I2C_ACORN) += i2c-acorn.o
+480
drivers/i2c/busses/i2c-viperboard.c
··· 1 + /* 2 + * Nano River Technologies viperboard i2c master driver 3 + * 4 + * (C) 2012 by Lemonage GmbH 5 + * Author: Lars Poeschel <poeschel@lemonage.de> 6 + * All rights reserved. 7 + * 8 + * This program is free software; you can redistribute it and/or modify it 9 + * under the terms of the GNU General Public License as published by the 10 + * Free Software Foundation; either version 2 of the License, or (at your 11 + * option) any later version. 12 + * 13 + */ 14 + 15 + #include <linux/kernel.h> 16 + #include <linux/errno.h> 17 + #include <linux/module.h> 18 + #include <linux/slab.h> 19 + #include <linux/types.h> 20 + #include <linux/mutex.h> 21 + #include <linux/platform_device.h> 22 + 23 + #include <linux/usb.h> 24 + #include <linux/i2c.h> 25 + 26 + #include <linux/mfd/viperboard.h> 27 + 28 + struct vprbrd_i2c { 29 + struct i2c_adapter i2c; 30 + u8 bus_freq_param; 31 + }; 32 + 33 + /* i2c bus frequency module parameter */ 34 + static u8 i2c_bus_param; 35 + static unsigned int i2c_bus_freq = 100; 36 + module_param(i2c_bus_freq, int, 0); 37 + MODULE_PARM_DESC(i2c_bus_freq, 38 + "i2c bus frequency in khz (default is 100) valid values: 10, 100, 200, 400, 1000, 3000, 6000"); 39 + 40 + static int vprbrd_i2c_status(struct i2c_adapter *i2c, 41 + struct vprbrd_i2c_status *status, bool prev_error) 42 + { 43 + u16 bytes_xfer; 44 + int ret; 45 + struct vprbrd *vb = (struct vprbrd *)i2c->algo_data; 46 + 47 + /* check for protocol error */ 48 + bytes_xfer = sizeof(struct vprbrd_i2c_status); 49 + 50 + ret = usb_control_msg(vb->usb_dev, usb_rcvctrlpipe(vb->usb_dev, 0), 51 + VPRBRD_USB_REQUEST_I2C, VPRBRD_USB_TYPE_IN, 0x0000, 0x0000, 52 + status, bytes_xfer, VPRBRD_USB_TIMEOUT_MS); 53 + 54 + if (ret != bytes_xfer) 55 + prev_error = true; 56 + 57 + if (prev_error) { 58 + dev_err(&i2c->dev, "failure in usb communication\n"); 59 + return -EREMOTEIO; 60 + } 61 + 62 + dev_dbg(&i2c->dev, " status = %d\n", status->status); 63 + if (status->status != 0x00) { 64 + dev_err(&i2c->dev, "failure: i2c protocol error\n"); 65 + return -EPROTO; 66 + } 67 + return 0; 68 + } 69 + 70 + static int vprbrd_i2c_receive(struct usb_device *usb_dev, 71 + struct vprbrd_i2c_read_msg *rmsg, int bytes_xfer) 72 + { 73 + int ret, bytes_actual; 74 + int error = 0; 75 + 76 + /* send the read request */ 77 + ret = usb_bulk_msg(usb_dev, 78 + usb_sndbulkpipe(usb_dev, VPRBRD_EP_OUT), rmsg, 79 + sizeof(struct vprbrd_i2c_read_hdr), &bytes_actual, 80 + VPRBRD_USB_TIMEOUT_MS); 81 + 82 + if ((ret < 0) 83 + || (bytes_actual != sizeof(struct vprbrd_i2c_read_hdr))) { 84 + dev_err(&usb_dev->dev, "failure transmitting usb\n"); 85 + error = -EREMOTEIO; 86 + } 87 + 88 + /* read the actual data */ 89 + ret = usb_bulk_msg(usb_dev, 90 + usb_rcvbulkpipe(usb_dev, VPRBRD_EP_IN), rmsg, 91 + bytes_xfer, &bytes_actual, VPRBRD_USB_TIMEOUT_MS); 92 + 93 + if ((ret < 0) || (bytes_xfer != bytes_actual)) { 94 + dev_err(&usb_dev->dev, "failure receiving usb\n"); 95 + error = -EREMOTEIO; 96 + } 97 + return error; 98 + } 99 + 100 + static int vprbrd_i2c_addr(struct usb_device *usb_dev, 101 + struct vprbrd_i2c_addr_msg *amsg) 102 + { 103 + int ret, bytes_actual; 104 + 105 + ret = usb_bulk_msg(usb_dev, 106 + usb_sndbulkpipe(usb_dev, VPRBRD_EP_OUT), amsg, 107 + sizeof(struct vprbrd_i2c_addr_msg), &bytes_actual, 108 + VPRBRD_USB_TIMEOUT_MS); 109 + 110 + if ((ret < 0) || 111 + (sizeof(struct vprbrd_i2c_addr_msg) != bytes_actual)) { 112 + dev_err(&usb_dev->dev, "failure transmitting usb\n"); 113 + return -EREMOTEIO; 114 + } 115 + return 0; 116 + } 117 + 118 + static int vprbrd_i2c_read(struct vprbrd *vb, struct i2c_msg *msg) 119 + { 120 + int ret; 121 + u16 remain_len, bytes_xfer, len1, len2, 122 + start = 0x0000; 123 + struct vprbrd_i2c_read_msg *rmsg = 124 + (struct vprbrd_i2c_read_msg *)vb->buf; 125 + 126 + remain_len = msg->len; 127 + rmsg->header.cmd = VPRBRD_I2C_CMD_READ; 128 + while (remain_len > 0) { 129 + rmsg->header.addr = cpu_to_le16(start + 0x4000); 130 + if (remain_len <= 255) { 131 + len1 = remain_len; 132 + len2 = 0x00; 133 + rmsg->header.len0 = remain_len; 134 + rmsg->header.len1 = 0x00; 135 + rmsg->header.len2 = 0x00; 136 + rmsg->header.len3 = 0x00; 137 + rmsg->header.len4 = 0x00; 138 + rmsg->header.len5 = 0x00; 139 + remain_len = 0; 140 + } else if (remain_len <= 510) { 141 + len1 = remain_len; 142 + len2 = 0x00; 143 + rmsg->header.len0 = remain_len - 255; 144 + rmsg->header.len1 = 0xff; 145 + rmsg->header.len2 = 0x00; 146 + rmsg->header.len3 = 0x00; 147 + rmsg->header.len4 = 0x00; 148 + rmsg->header.len5 = 0x00; 149 + remain_len = 0; 150 + } else if (remain_len <= 512) { 151 + len1 = remain_len; 152 + len2 = 0x00; 153 + rmsg->header.len0 = remain_len - 510; 154 + rmsg->header.len1 = 0xff; 155 + rmsg->header.len2 = 0xff; 156 + rmsg->header.len3 = 0x00; 157 + rmsg->header.len4 = 0x00; 158 + rmsg->header.len5 = 0x00; 159 + remain_len = 0; 160 + } else if (remain_len <= 767) { 161 + len1 = 512; 162 + len2 = remain_len - 512; 163 + rmsg->header.len0 = 0x02; 164 + rmsg->header.len1 = 0xff; 165 + rmsg->header.len2 = 0xff; 166 + rmsg->header.len3 = remain_len - 512; 167 + rmsg->header.len4 = 0x00; 168 + rmsg->header.len5 = 0x00; 169 + bytes_xfer = remain_len; 170 + remain_len = 0; 171 + } else if (remain_len <= 1022) { 172 + len1 = 512; 173 + len2 = remain_len - 512; 174 + rmsg->header.len0 = 0x02; 175 + rmsg->header.len1 = 0xff; 176 + rmsg->header.len2 = 0xff; 177 + rmsg->header.len3 = remain_len - 767; 178 + rmsg->header.len4 = 0xff; 179 + rmsg->header.len5 = 0x00; 180 + remain_len = 0; 181 + } else if (remain_len <= 1024) { 182 + len1 = 512; 183 + len2 = remain_len - 512; 184 + rmsg->header.len0 = 0x02; 185 + rmsg->header.len1 = 0xff; 186 + rmsg->header.len2 = 0xff; 187 + rmsg->header.len3 = remain_len - 1022; 188 + rmsg->header.len4 = 0xff; 189 + rmsg->header.len5 = 0xff; 190 + remain_len = 0; 191 + } else { 192 + len1 = 512; 193 + len2 = 512; 194 + rmsg->header.len0 = 0x02; 195 + rmsg->header.len1 = 0xff; 196 + rmsg->header.len2 = 0xff; 197 + rmsg->header.len3 = 0x02; 198 + rmsg->header.len4 = 0xff; 199 + rmsg->header.len5 = 0xff; 200 + remain_len -= 1024; 201 + start += 1024; 202 + } 203 + rmsg->header.tf1 = cpu_to_le16(len1); 204 + rmsg->header.tf2 = cpu_to_le16(len2); 205 + 206 + /* first read transfer */ 207 + ret = vprbrd_i2c_receive(vb->usb_dev, rmsg, len1); 208 + if (ret < 0) 209 + return ret; 210 + /* copy the received data */ 211 + memcpy(msg->buf + start, rmsg, len1); 212 + 213 + /* second read transfer if neccessary */ 214 + if (len2 > 0) { 215 + ret = vprbrd_i2c_receive(vb->usb_dev, rmsg, len2); 216 + if (ret < 0) 217 + return ret; 218 + /* copy the received data */ 219 + memcpy(msg->buf + start + 512, rmsg, len2); 220 + } 221 + } 222 + return 0; 223 + } 224 + 225 + static int vprbrd_i2c_write(struct vprbrd *vb, struct i2c_msg *msg) 226 + { 227 + int ret, bytes_actual; 228 + u16 remain_len, bytes_xfer, 229 + start = 0x0000; 230 + struct vprbrd_i2c_write_msg *wmsg = 231 + (struct vprbrd_i2c_write_msg *)vb->buf; 232 + 233 + remain_len = msg->len; 234 + wmsg->header.cmd = VPRBRD_I2C_CMD_WRITE; 235 + wmsg->header.last = 0x00; 236 + wmsg->header.chan = 0x00; 237 + wmsg->header.spi = 0x0000; 238 + while (remain_len > 0) { 239 + wmsg->header.addr = cpu_to_le16(start + 0x4000); 240 + if (remain_len > 503) { 241 + wmsg->header.len1 = 0xff; 242 + wmsg->header.len2 = 0xf8; 243 + remain_len -= 503; 244 + bytes_xfer = 503 + sizeof(struct vprbrd_i2c_write_hdr); 245 + start += 503; 246 + } else if (remain_len > 255) { 247 + wmsg->header.len1 = 0xff; 248 + wmsg->header.len2 = (remain_len - 255); 249 + bytes_xfer = remain_len + 250 + sizeof(struct vprbrd_i2c_write_hdr); 251 + remain_len = 0; 252 + } else { 253 + wmsg->header.len1 = remain_len; 254 + wmsg->header.len2 = 0x00; 255 + bytes_xfer = remain_len + 256 + sizeof(struct vprbrd_i2c_write_hdr); 257 + remain_len = 0; 258 + } 259 + memcpy(wmsg->data, msg->buf + start, 260 + bytes_xfer - sizeof(struct vprbrd_i2c_write_hdr)); 261 + 262 + ret = usb_bulk_msg(vb->usb_dev, 263 + usb_sndbulkpipe(vb->usb_dev, 264 + VPRBRD_EP_OUT), wmsg, 265 + bytes_xfer, &bytes_actual, VPRBRD_USB_TIMEOUT_MS); 266 + if ((ret < 0) || (bytes_xfer != bytes_actual)) 267 + return -EREMOTEIO; 268 + } 269 + return 0; 270 + } 271 + 272 + static int vprbrd_i2c_xfer(struct i2c_adapter *i2c, struct i2c_msg *msgs, 273 + int num) 274 + { 275 + struct i2c_msg *pmsg; 276 + int i, ret, 277 + error = 0; 278 + struct vprbrd *vb = (struct vprbrd *)i2c->algo_data; 279 + struct vprbrd_i2c_addr_msg *amsg = 280 + (struct vprbrd_i2c_addr_msg *)vb->buf; 281 + struct vprbrd_i2c_status *smsg = (struct vprbrd_i2c_status *)vb->buf; 282 + 283 + dev_dbg(&i2c->dev, "master xfer %d messages:\n", num); 284 + 285 + for (i = 0 ; i < num ; i++) { 286 + pmsg = &msgs[i]; 287 + 288 + dev_dbg(&i2c->dev, 289 + " %d: %s (flags %d) %d bytes to 0x%02x\n", 290 + i, pmsg->flags & I2C_M_RD ? "read" : "write", 291 + pmsg->flags, pmsg->len, pmsg->addr); 292 + 293 + /* msgs longer than 2048 bytes are not supported by adapter */ 294 + if (pmsg->len > 2048) 295 + return -EINVAL; 296 + 297 + mutex_lock(&vb->lock); 298 + /* directly send the message */ 299 + if (pmsg->flags & I2C_M_RD) { 300 + /* read data */ 301 + amsg->cmd = VPRBRD_I2C_CMD_ADDR; 302 + amsg->unknown2 = 0x00; 303 + amsg->unknown3 = 0x00; 304 + amsg->addr = pmsg->addr; 305 + amsg->unknown1 = 0x01; 306 + amsg->len = cpu_to_le16(pmsg->len); 307 + /* send the addr and len, we're interested to board */ 308 + ret = vprbrd_i2c_addr(vb->usb_dev, amsg); 309 + if (ret < 0) 310 + error = ret; 311 + 312 + ret = vprbrd_i2c_read(vb, pmsg); 313 + if (ret < 0) 314 + error = ret; 315 + 316 + ret = vprbrd_i2c_status(i2c, smsg, error); 317 + if (ret < 0) 318 + error = ret; 319 + /* in case of protocol error, return the error */ 320 + if (error < 0) 321 + goto error; 322 + } else { 323 + /* write data */ 324 + ret = vprbrd_i2c_write(vb, pmsg); 325 + 326 + amsg->cmd = VPRBRD_I2C_CMD_ADDR; 327 + amsg->unknown2 = 0x00; 328 + amsg->unknown3 = 0x00; 329 + amsg->addr = pmsg->addr; 330 + amsg->unknown1 = 0x00; 331 + amsg->len = cpu_to_le16(pmsg->len); 332 + /* send the addr, the data goes to to board */ 333 + ret = vprbrd_i2c_addr(vb->usb_dev, amsg); 334 + if (ret < 0) 335 + error = ret; 336 + 337 + ret = vprbrd_i2c_status(i2c, smsg, error); 338 + if (ret < 0) 339 + error = ret; 340 + 341 + if (error < 0) 342 + goto error; 343 + } 344 + mutex_unlock(&vb->lock); 345 + } 346 + return 0; 347 + error: 348 + mutex_unlock(&vb->lock); 349 + return error; 350 + } 351 + 352 + static u32 vprbrd_i2c_func(struct i2c_adapter *i2c) 353 + { 354 + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; 355 + } 356 + 357 + /* This is the actual algorithm we define */ 358 + static const struct i2c_algorithm vprbrd_algorithm = { 359 + .master_xfer = vprbrd_i2c_xfer, 360 + .functionality = vprbrd_i2c_func, 361 + }; 362 + 363 + static int __devinit vprbrd_i2c_probe(struct platform_device *pdev) 364 + { 365 + struct vprbrd *vb = dev_get_drvdata(pdev->dev.parent); 366 + struct vprbrd_i2c *vb_i2c; 367 + int ret; 368 + int pipe; 369 + 370 + vb_i2c = kzalloc(sizeof(*vb_i2c), GFP_KERNEL); 371 + if (vb_i2c == NULL) 372 + return -ENOMEM; 373 + 374 + /* setup i2c adapter description */ 375 + vb_i2c->i2c.owner = THIS_MODULE; 376 + vb_i2c->i2c.class = I2C_CLASS_HWMON; 377 + vb_i2c->i2c.algo = &vprbrd_algorithm; 378 + vb_i2c->i2c.algo_data = vb; 379 + /* save the param in usb capabable memory */ 380 + vb_i2c->bus_freq_param = i2c_bus_param; 381 + 382 + snprintf(vb_i2c->i2c.name, sizeof(vb_i2c->i2c.name), 383 + "viperboard at bus %03d device %03d", 384 + vb->usb_dev->bus->busnum, vb->usb_dev->devnum); 385 + 386 + /* setting the bus frequency */ 387 + if ((i2c_bus_param <= VPRBRD_I2C_FREQ_10KHZ) 388 + && (i2c_bus_param >= VPRBRD_I2C_FREQ_6MHZ)) { 389 + pipe = usb_sndctrlpipe(vb->usb_dev, 0); 390 + ret = usb_control_msg(vb->usb_dev, pipe, 391 + VPRBRD_USB_REQUEST_I2C_FREQ, VPRBRD_USB_TYPE_OUT, 392 + 0x0000, 0x0000, &vb_i2c->bus_freq_param, 1, 393 + VPRBRD_USB_TIMEOUT_MS); 394 + if (ret != 1) { 395 + dev_err(&pdev->dev, 396 + "failure setting i2c_bus_freq to %d\n", i2c_bus_freq); 397 + ret = -EIO; 398 + goto error; 399 + } 400 + } else { 401 + dev_err(&pdev->dev, 402 + "invalid i2c_bus_freq setting:%d\n", i2c_bus_freq); 403 + ret = -EIO; 404 + goto error; 405 + } 406 + 407 + vb_i2c->i2c.dev.parent = &pdev->dev; 408 + 409 + /* attach to i2c layer */ 410 + i2c_add_adapter(&vb_i2c->i2c); 411 + 412 + platform_set_drvdata(pdev, vb_i2c); 413 + 414 + return 0; 415 + 416 + error: 417 + kfree(vb_i2c); 418 + return ret; 419 + } 420 + 421 + static int __devexit vprbrd_i2c_remove(struct platform_device *pdev) 422 + { 423 + struct vprbrd_i2c *vb_i2c = platform_get_drvdata(pdev); 424 + int ret; 425 + 426 + ret = i2c_del_adapter(&vb_i2c->i2c); 427 + 428 + return ret; 429 + } 430 + 431 + static struct platform_driver vprbrd_i2c_driver = { 432 + .driver.name = "viperboard-i2c", 433 + .driver.owner = THIS_MODULE, 434 + .probe = vprbrd_i2c_probe, 435 + .remove = __devexit_p(vprbrd_i2c_remove), 436 + }; 437 + 438 + static int __init vprbrd_i2c_init(void) 439 + { 440 + switch (i2c_bus_freq) { 441 + case 6000: 442 + i2c_bus_param = VPRBRD_I2C_FREQ_6MHZ; 443 + break; 444 + case 3000: 445 + i2c_bus_param = VPRBRD_I2C_FREQ_3MHZ; 446 + break; 447 + case 1000: 448 + i2c_bus_param = VPRBRD_I2C_FREQ_1MHZ; 449 + break; 450 + case 400: 451 + i2c_bus_param = VPRBRD_I2C_FREQ_400KHZ; 452 + break; 453 + case 200: 454 + i2c_bus_param = VPRBRD_I2C_FREQ_200KHZ; 455 + break; 456 + case 100: 457 + i2c_bus_param = VPRBRD_I2C_FREQ_100KHZ; 458 + break; 459 + case 10: 460 + i2c_bus_param = VPRBRD_I2C_FREQ_10KHZ; 461 + break; 462 + default: 463 + pr_warn("invalid i2c_bus_freq (%d)\n", i2c_bus_freq); 464 + i2c_bus_param = VPRBRD_I2C_FREQ_100KHZ; 465 + } 466 + 467 + return platform_driver_register(&vprbrd_i2c_driver); 468 + } 469 + subsys_initcall(vprbrd_i2c_init); 470 + 471 + static void __exit vprbrd_i2c_exit(void) 472 + { 473 + platform_driver_unregister(&vprbrd_i2c_driver); 474 + } 475 + module_exit(vprbrd_i2c_exit); 476 + 477 + MODULE_AUTHOR("Lars Poeschel <poeschel@lemonage.de>"); 478 + MODULE_DESCRIPTION("I2C master driver for Nano River Techs Viperboard"); 479 + MODULE_LICENSE("GPL"); 480 + MODULE_ALIAS("platform:viperboard-i2c");
+14
drivers/iio/adc/Kconfig
··· 125 125 This driver can also be built as a module. If so, the module will be 126 126 called ti-adc081c. 127 127 128 + config TI_AM335X_ADC 129 + tristate "TI's ADC driver" 130 + depends on MFD_TI_AM335X_TSCADC 131 + help 132 + Say yes here to build support for Texas Instruments ADC 133 + driver which is also a MFD client. 134 + 135 + config VIPERBOARD_ADC 136 + tristate "Viperboard ADC support" 137 + depends on MFD_VIPERBOARD && USB 138 + help 139 + Say yes here to access the ADC part of the Nano River 140 + Technologies Viperboard. 141 + 128 142 endmenu
+2 -1
drivers/iio/adc/Makefile
··· 13 13 obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o 14 14 obj-$(CONFIG_MAX1363) += max1363.o 15 15 obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o 16 - 16 + obj-$(CONFIG_TI_AM335X_ADC) += ti_am335x_adc.o 17 + obj-$(CONFIG_VIPERBOARD_ADC) += viperboard_adc.o
+260
drivers/iio/adc/ti_am335x_adc.c
··· 1 + /* 2 + * TI ADC MFD driver 3 + * 4 + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License as 8 + * published by the Free Software Foundation version 2. 9 + * 10 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 11 + * kind, whether express or implied; without even the implied warranty 12 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + */ 15 + 16 + #include <linux/init.h> 17 + #include <linux/kernel.h> 18 + #include <linux/err.h> 19 + #include <linux/module.h> 20 + #include <linux/slab.h> 21 + #include <linux/interrupt.h> 22 + #include <linux/platform_device.h> 23 + #include <linux/io.h> 24 + #include <linux/iio/iio.h> 25 + 26 + #include <linux/mfd/ti_am335x_tscadc.h> 27 + #include <linux/platform_data/ti_am335x_adc.h> 28 + 29 + struct tiadc_device { 30 + struct ti_tscadc_dev *mfd_tscadc; 31 + int channels; 32 + }; 33 + 34 + static unsigned int tiadc_readl(struct tiadc_device *adc, unsigned int reg) 35 + { 36 + return readl(adc->mfd_tscadc->tscadc_base + reg); 37 + } 38 + 39 + static void tiadc_writel(struct tiadc_device *adc, unsigned int reg, 40 + unsigned int val) 41 + { 42 + writel(val, adc->mfd_tscadc->tscadc_base + reg); 43 + } 44 + 45 + static void tiadc_step_config(struct tiadc_device *adc_dev) 46 + { 47 + unsigned int stepconfig; 48 + int i, channels = 0, steps; 49 + 50 + /* 51 + * There are 16 configurable steps and 8 analog input 52 + * lines available which are shared between Touchscreen and ADC. 53 + * 54 + * Steps backwards i.e. from 16 towards 0 are used by ADC 55 + * depending on number of input lines needed. 56 + * Channel would represent which analog input 57 + * needs to be given to ADC to digitalize data. 58 + */ 59 + 60 + steps = TOTAL_STEPS - adc_dev->channels; 61 + channels = TOTAL_CHANNELS - adc_dev->channels; 62 + 63 + stepconfig = STEPCONFIG_AVG_16 | STEPCONFIG_FIFO1; 64 + 65 + for (i = (steps + 1); i <= TOTAL_STEPS; i++) { 66 + tiadc_writel(adc_dev, REG_STEPCONFIG(i), 67 + stepconfig | STEPCONFIG_INP(channels)); 68 + tiadc_writel(adc_dev, REG_STEPDELAY(i), 69 + STEPCONFIG_OPENDLY); 70 + channels++; 71 + } 72 + tiadc_writel(adc_dev, REG_SE, STPENB_STEPENB); 73 + } 74 + 75 + static int tiadc_channel_init(struct iio_dev *indio_dev, int channels) 76 + { 77 + struct iio_chan_spec *chan_array; 78 + int i; 79 + 80 + indio_dev->num_channels = channels; 81 + chan_array = kcalloc(indio_dev->num_channels, 82 + sizeof(struct iio_chan_spec), GFP_KERNEL); 83 + 84 + if (chan_array == NULL) 85 + return -ENOMEM; 86 + 87 + for (i = 0; i < (indio_dev->num_channels); i++) { 88 + struct iio_chan_spec *chan = chan_array + i; 89 + chan->type = IIO_VOLTAGE; 90 + chan->indexed = 1; 91 + chan->channel = i; 92 + chan->info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT; 93 + } 94 + 95 + indio_dev->channels = chan_array; 96 + 97 + return indio_dev->num_channels; 98 + } 99 + 100 + static void tiadc_channels_remove(struct iio_dev *indio_dev) 101 + { 102 + kfree(indio_dev->channels); 103 + } 104 + 105 + static int tiadc_read_raw(struct iio_dev *indio_dev, 106 + struct iio_chan_spec const *chan, 107 + int *val, int *val2, long mask) 108 + { 109 + struct tiadc_device *adc_dev = iio_priv(indio_dev); 110 + int i; 111 + unsigned int fifo1count, readx1; 112 + 113 + /* 114 + * When the sub-system is first enabled, 115 + * the sequencer will always start with the 116 + * lowest step (1) and continue until step (16). 117 + * For ex: If we have enabled 4 ADC channels and 118 + * currently use only 1 out of them, the 119 + * sequencer still configures all the 4 steps, 120 + * leading to 3 unwanted data. 121 + * Hence we need to flush out this data. 122 + */ 123 + 124 + fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); 125 + for (i = 0; i < fifo1count; i++) { 126 + readx1 = tiadc_readl(adc_dev, REG_FIFO1); 127 + if (i == chan->channel) 128 + *val = readx1 & 0xfff; 129 + } 130 + tiadc_writel(adc_dev, REG_SE, STPENB_STEPENB); 131 + 132 + return IIO_VAL_INT; 133 + } 134 + 135 + static const struct iio_info tiadc_info = { 136 + .read_raw = &tiadc_read_raw, 137 + }; 138 + 139 + static int __devinit tiadc_probe(struct platform_device *pdev) 140 + { 141 + struct iio_dev *indio_dev; 142 + struct tiadc_device *adc_dev; 143 + struct ti_tscadc_dev *tscadc_dev = pdev->dev.platform_data; 144 + struct mfd_tscadc_board *pdata; 145 + int err; 146 + 147 + pdata = tscadc_dev->dev->platform_data; 148 + if (!pdata || !pdata->adc_init) { 149 + dev_err(&pdev->dev, "Could not find platform data\n"); 150 + return -EINVAL; 151 + } 152 + 153 + indio_dev = iio_device_alloc(sizeof(struct tiadc_device)); 154 + if (indio_dev == NULL) { 155 + dev_err(&pdev->dev, "failed to allocate iio device\n"); 156 + err = -ENOMEM; 157 + goto err_ret; 158 + } 159 + adc_dev = iio_priv(indio_dev); 160 + 161 + adc_dev->mfd_tscadc = tscadc_dev; 162 + adc_dev->channels = pdata->adc_init->adc_channels; 163 + 164 + indio_dev->dev.parent = &pdev->dev; 165 + indio_dev->name = dev_name(&pdev->dev); 166 + indio_dev->modes = INDIO_DIRECT_MODE; 167 + indio_dev->info = &tiadc_info; 168 + 169 + tiadc_step_config(adc_dev); 170 + 171 + err = tiadc_channel_init(indio_dev, adc_dev->channels); 172 + if (err < 0) 173 + goto err_free_device; 174 + 175 + err = iio_device_register(indio_dev); 176 + if (err) 177 + goto err_free_channels; 178 + 179 + platform_set_drvdata(pdev, indio_dev); 180 + 181 + return 0; 182 + 183 + err_free_channels: 184 + tiadc_channels_remove(indio_dev); 185 + err_free_device: 186 + iio_device_free(indio_dev); 187 + err_ret: 188 + return err; 189 + } 190 + 191 + static int __devexit tiadc_remove(struct platform_device *pdev) 192 + { 193 + struct iio_dev *indio_dev = platform_get_drvdata(pdev); 194 + 195 + iio_device_unregister(indio_dev); 196 + tiadc_channels_remove(indio_dev); 197 + 198 + iio_device_free(indio_dev); 199 + 200 + return 0; 201 + } 202 + 203 + #ifdef CONFIG_PM 204 + static int tiadc_suspend(struct device *dev) 205 + { 206 + struct iio_dev *indio_dev = dev_get_drvdata(dev); 207 + struct tiadc_device *adc_dev = iio_priv(indio_dev); 208 + struct ti_tscadc_dev *tscadc_dev = dev->platform_data; 209 + unsigned int idle; 210 + 211 + if (!device_may_wakeup(tscadc_dev->dev)) { 212 + idle = tiadc_readl(adc_dev, REG_CTRL); 213 + idle &= ~(CNTRLREG_TSCSSENB); 214 + tiadc_writel(adc_dev, REG_CTRL, (idle | 215 + CNTRLREG_POWERDOWN)); 216 + } 217 + 218 + return 0; 219 + } 220 + 221 + static int tiadc_resume(struct device *dev) 222 + { 223 + struct iio_dev *indio_dev = dev_get_drvdata(dev); 224 + struct tiadc_device *adc_dev = iio_priv(indio_dev); 225 + unsigned int restore; 226 + 227 + /* Make sure ADC is powered up */ 228 + restore = tiadc_readl(adc_dev, REG_CTRL); 229 + restore &= ~(CNTRLREG_POWERDOWN); 230 + tiadc_writel(adc_dev, REG_CTRL, restore); 231 + 232 + tiadc_step_config(adc_dev); 233 + 234 + return 0; 235 + } 236 + 237 + static const struct dev_pm_ops tiadc_pm_ops = { 238 + .suspend = tiadc_suspend, 239 + .resume = tiadc_resume, 240 + }; 241 + #define TIADC_PM_OPS (&tiadc_pm_ops) 242 + #else 243 + #define TIADC_PM_OPS NULL 244 + #endif 245 + 246 + static struct platform_driver tiadc_driver = { 247 + .driver = { 248 + .name = "tiadc", 249 + .owner = THIS_MODULE, 250 + .pm = TIADC_PM_OPS, 251 + }, 252 + .probe = tiadc_probe, 253 + .remove = __devexit_p(tiadc_remove), 254 + }; 255 + 256 + module_platform_driver(tiadc_driver); 257 + 258 + MODULE_DESCRIPTION("TI ADC controller driver"); 259 + MODULE_AUTHOR("Rachna Patil <rachna@ti.com>"); 260 + MODULE_LICENSE("GPL");
+181
drivers/iio/adc/viperboard_adc.c
··· 1 + /* 2 + * Nano River Technologies viperboard IIO ADC driver 3 + * 4 + * (C) 2012 by Lemonage GmbH 5 + * Author: Lars Poeschel <poeschel@lemonage.de> 6 + * All rights reserved. 7 + * 8 + * This program is free software; you can redistribute it and/or modify it 9 + * under the terms of the GNU General Public License as published by the 10 + * Free Software Foundation; either version 2 of the License, or (at your 11 + * option) any later version. 12 + * 13 + */ 14 + 15 + #include <linux/kernel.h> 16 + #include <linux/errno.h> 17 + #include <linux/module.h> 18 + #include <linux/slab.h> 19 + #include <linux/types.h> 20 + #include <linux/mutex.h> 21 + #include <linux/platform_device.h> 22 + 23 + #include <linux/usb.h> 24 + #include <linux/iio/iio.h> 25 + 26 + #include <linux/mfd/viperboard.h> 27 + 28 + #define VPRBRD_ADC_CMD_GET 0x00 29 + 30 + struct vprbrd_adc_msg { 31 + u8 cmd; 32 + u8 chan; 33 + u8 val; 34 + } __packed; 35 + 36 + struct vprbrd_adc { 37 + struct vprbrd *vb; 38 + }; 39 + 40 + #define VPRBRD_ADC_CHANNEL(_index) { \ 41 + .type = IIO_VOLTAGE, \ 42 + .indexed = 1, \ 43 + .channel = _index, \ 44 + .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, \ 45 + .scan_index = _index, \ 46 + .scan_type = { \ 47 + .sign = 'u', \ 48 + .realbits = 8, \ 49 + .storagebits = 8, \ 50 + }, \ 51 + } 52 + 53 + static struct iio_chan_spec const vprbrd_adc_iio_channels[] = { 54 + VPRBRD_ADC_CHANNEL(0), 55 + VPRBRD_ADC_CHANNEL(1), 56 + VPRBRD_ADC_CHANNEL(2), 57 + VPRBRD_ADC_CHANNEL(3), 58 + }; 59 + 60 + static int vprbrd_iio_read_raw(struct iio_dev *iio_dev, 61 + struct iio_chan_spec const *chan, 62 + int *val, 63 + int *val2, 64 + long info) 65 + { 66 + int ret, error = 0; 67 + struct vprbrd_adc *adc = iio_priv(iio_dev); 68 + struct vprbrd *vb = adc->vb; 69 + struct vprbrd_adc_msg *admsg = (struct vprbrd_adc_msg *)vb->buf; 70 + 71 + switch (info) { 72 + case IIO_CHAN_INFO_RAW: 73 + mutex_lock(&vb->lock); 74 + 75 + admsg->cmd = VPRBRD_ADC_CMD_GET; 76 + admsg->chan = chan->scan_index; 77 + admsg->val = 0x00; 78 + 79 + ret = usb_control_msg(vb->usb_dev, 80 + usb_sndctrlpipe(vb->usb_dev, 0), VPRBRD_USB_REQUEST_ADC, 81 + VPRBRD_USB_TYPE_OUT, 0x0000, 0x0000, admsg, 82 + sizeof(struct vprbrd_adc_msg), VPRBRD_USB_TIMEOUT_MS); 83 + if (ret != sizeof(struct vprbrd_adc_msg)) { 84 + dev_err(&iio_dev->dev, "usb send error on adc read\n"); 85 + error = -EREMOTEIO; 86 + } 87 + 88 + ret = usb_control_msg(vb->usb_dev, 89 + usb_rcvctrlpipe(vb->usb_dev, 0), VPRBRD_USB_REQUEST_ADC, 90 + VPRBRD_USB_TYPE_IN, 0x0000, 0x0000, admsg, 91 + sizeof(struct vprbrd_adc_msg), VPRBRD_USB_TIMEOUT_MS); 92 + 93 + *val = admsg->val; 94 + 95 + mutex_unlock(&vb->lock); 96 + 97 + if (ret != sizeof(struct vprbrd_adc_msg)) { 98 + dev_err(&iio_dev->dev, "usb recv error on adc read\n"); 99 + error = -EREMOTEIO; 100 + } 101 + 102 + if (error) 103 + goto error; 104 + 105 + return IIO_VAL_INT; 106 + default: 107 + error = -EINVAL; 108 + break; 109 + } 110 + error: 111 + return error; 112 + } 113 + 114 + static const struct iio_info vprbrd_adc_iio_info = { 115 + .read_raw = &vprbrd_iio_read_raw, 116 + .driver_module = THIS_MODULE, 117 + }; 118 + 119 + static int __devinit vprbrd_adc_probe(struct platform_device *pdev) 120 + { 121 + struct vprbrd *vb = dev_get_drvdata(pdev->dev.parent); 122 + struct vprbrd_adc *adc; 123 + struct iio_dev *indio_dev; 124 + int ret; 125 + 126 + /* registering iio */ 127 + indio_dev = iio_device_alloc(sizeof(*adc)); 128 + if (!indio_dev) { 129 + dev_err(&pdev->dev, "failed allocating iio device\n"); 130 + return -ENOMEM; 131 + } 132 + 133 + adc = iio_priv(indio_dev); 134 + adc->vb = vb; 135 + indio_dev->name = "viperboard adc"; 136 + indio_dev->dev.parent = &pdev->dev; 137 + indio_dev->info = &vprbrd_adc_iio_info; 138 + indio_dev->modes = INDIO_DIRECT_MODE; 139 + indio_dev->channels = vprbrd_adc_iio_channels; 140 + indio_dev->num_channels = ARRAY_SIZE(vprbrd_adc_iio_channels); 141 + 142 + ret = iio_device_register(indio_dev); 143 + if (ret) { 144 + dev_err(&pdev->dev, "could not register iio (adc)"); 145 + goto error; 146 + } 147 + 148 + platform_set_drvdata(pdev, indio_dev); 149 + 150 + return 0; 151 + 152 + error: 153 + iio_device_free(indio_dev); 154 + return ret; 155 + } 156 + 157 + static int __devexit vprbrd_adc_remove(struct platform_device *pdev) 158 + { 159 + struct iio_dev *indio_dev = platform_get_drvdata(pdev); 160 + 161 + iio_device_unregister(indio_dev); 162 + iio_device_free(indio_dev); 163 + 164 + return 0; 165 + } 166 + 167 + static struct platform_driver vprbrd_adc_driver = { 168 + .driver = { 169 + .name = "viperboard-adc", 170 + .owner = THIS_MODULE, 171 + }, 172 + .probe = vprbrd_adc_probe, 173 + .remove = __devexit_p(vprbrd_adc_remove), 174 + }; 175 + 176 + module_platform_driver(vprbrd_adc_driver); 177 + 178 + MODULE_AUTHOR("Lars Poeschel <poeschel@lemonage.de>"); 179 + MODULE_DESCRIPTION("IIO ADC driver for Nano River Techs Viperboard"); 180 + MODULE_LICENSE("GPL"); 181 + MODULE_ALIAS("platform:viperboard-adc");
+5 -17
drivers/input/misc/da9052_onkey.c
··· 24 24 struct da9052 *da9052; 25 25 struct input_dev *input; 26 26 struct delayed_work work; 27 - unsigned int irq; 28 27 }; 29 28 30 29 static void da9052_onkey_query(struct da9052_onkey *onkey) ··· 75 76 struct da9052 *da9052 = dev_get_drvdata(pdev->dev.parent); 76 77 struct da9052_onkey *onkey; 77 78 struct input_dev *input_dev; 78 - int irq; 79 79 int error; 80 80 81 81 if (!da9052) { 82 82 dev_err(&pdev->dev, "Failed to get the driver's data\n"); 83 - return -EINVAL; 84 - } 85 - 86 - irq = platform_get_irq_byname(pdev, "ONKEY"); 87 - if (irq < 0) { 88 - dev_err(&pdev->dev, 89 - "Failed to get an IRQ for input device, %d\n", irq); 90 83 return -EINVAL; 91 84 } 92 85 ··· 92 101 93 102 onkey->input = input_dev; 94 103 onkey->da9052 = da9052; 95 - onkey->irq = irq; 96 104 INIT_DELAYED_WORK(&onkey->work, da9052_onkey_work); 97 105 98 106 input_dev->name = "da9052-onkey"; ··· 101 111 input_dev->evbit[0] = BIT_MASK(EV_KEY); 102 112 __set_bit(KEY_POWER, input_dev->keybit); 103 113 104 - error = request_threaded_irq(onkey->irq, NULL, da9052_onkey_irq, 105 - IRQF_TRIGGER_LOW | IRQF_ONESHOT, 106 - "ONKEY", onkey); 114 + error = da9052_request_irq(onkey->da9052, DA9052_IRQ_NONKEY, "ONKEY", 115 + da9052_onkey_irq, onkey); 107 116 if (error < 0) { 108 117 dev_err(onkey->da9052->dev, 109 - "Failed to register ONKEY IRQ %d, error = %d\n", 110 - onkey->irq, error); 118 + "Failed to register ONKEY IRQ: %d\n", error); 111 119 goto err_free_mem; 112 120 } 113 121 ··· 120 132 return 0; 121 133 122 134 err_free_irq: 123 - free_irq(onkey->irq, onkey); 135 + da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey); 124 136 cancel_delayed_work_sync(&onkey->work); 125 137 err_free_mem: 126 138 input_free_device(input_dev); ··· 133 145 { 134 146 struct da9052_onkey *onkey = platform_get_drvdata(pdev); 135 147 136 - free_irq(onkey->irq, onkey); 148 + da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey); 137 149 cancel_delayed_work_sync(&onkey->work); 138 150 139 151 input_unregister_device(onkey->input);
+3 -3
drivers/input/touchscreen/Kconfig
··· 529 529 To compile this driver as a module, choose M here: the 530 530 module will be called touchwin. 531 531 532 - config TOUCHSCREEN_TI_TSCADC 532 + config TOUCHSCREEN_TI_AM335X_TSC 533 533 tristate "TI Touchscreen Interface" 534 - depends on ARCH_OMAP2PLUS 534 + depends on MFD_TI_AM335X_TSCADC 535 535 help 536 536 Say Y here if you have 4/5/8 wire touchscreen controller 537 537 to be connected to the ADC controller on your TI AM335x SoC. ··· 539 539 If unsure, say N. 540 540 541 541 To compile this driver as a module, choose M here: the 542 - module will be called ti_tscadc. 542 + module will be called ti_am335x_tsc. 543 543 544 544 config TOUCHSCREEN_ATMEL_TSADCC 545 545 tristate "Atmel Touchscreen Interface"
+1 -1
drivers/input/touchscreen/Makefile
··· 52 52 obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o 53 53 obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o 54 54 obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o 55 - obj-$(CONFIG_TOUCHSCREEN_TI_TSCADC) += ti_tscadc.o 55 + obj-$(CONFIG_TOUCHSCREEN_TI_AM335X_TSC) += ti_am335x_tsc.o 56 56 obj-$(CONFIG_TOUCHSCREEN_TNETV107X) += tnetv107x-ts.o 57 57 obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o 58 58 obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o
+20 -39
drivers/input/touchscreen/da9052_tsi.c
··· 27 27 struct input_dev *dev; 28 28 struct delayed_work ts_pen_work; 29 29 struct mutex mutex; 30 - unsigned int irq_pendwn; 31 - unsigned int irq_datardy; 32 30 bool stopped; 33 31 bool adc_on; 34 32 }; ··· 43 45 44 46 if (!tsi->stopped) { 45 47 /* Mask PEN_DOWN event and unmask TSI_READY event */ 46 - disable_irq_nosync(tsi->irq_pendwn); 47 - enable_irq(tsi->irq_datardy); 48 + da9052_disable_irq_nosync(tsi->da9052, DA9052_IRQ_PENDOWN); 49 + da9052_enable_irq(tsi->da9052, DA9052_IRQ_TSIREADY); 48 50 49 51 da9052_ts_adc_toggle(tsi, true); 50 52 ··· 135 137 return; 136 138 137 139 /* Mask TSI_READY event and unmask PEN_DOWN event */ 138 - disable_irq(tsi->irq_datardy); 139 - enable_irq(tsi->irq_pendwn); 140 + da9052_disable_irq(tsi->da9052, DA9052_IRQ_TSIREADY); 141 + da9052_enable_irq(tsi->da9052, DA9052_IRQ_PENDOWN); 140 142 } 141 143 } 142 144 } ··· 195 197 mb(); 196 198 197 199 /* Unmask PEN_DOWN event */ 198 - enable_irq(tsi->irq_pendwn); 200 + da9052_enable_irq(tsi->da9052, DA9052_IRQ_PENDOWN); 199 201 200 202 /* Enable Pen Detect Circuit */ 201 203 return da9052_reg_update(tsi->da9052, DA9052_TSI_CONT_A_REG, ··· 208 210 209 211 tsi->stopped = true; 210 212 mb(); 211 - disable_irq(tsi->irq_pendwn); 213 + da9052_disable_irq(tsi->da9052, DA9052_IRQ_PENDOWN); 212 214 cancel_delayed_work_sync(&tsi->ts_pen_work); 213 215 214 216 if (tsi->adc_on) { 215 - disable_irq(tsi->irq_datardy); 217 + da9052_disable_irq(tsi->da9052, DA9052_IRQ_TSIREADY); 216 218 da9052_ts_adc_toggle(tsi, false); 217 219 218 220 /* ··· 220 222 * twice and we need to enable it to keep enable/disable 221 223 * counter balanced. IRQ is still off though. 222 224 */ 223 - enable_irq(tsi->irq_pendwn); 225 + da9052_enable_irq(tsi->da9052, DA9052_IRQ_PENDOWN); 224 226 } 225 227 226 228 /* Disable Pen Detect Circuit */ ··· 232 234 struct da9052 *da9052; 233 235 struct da9052_tsi *tsi; 234 236 struct input_dev *input_dev; 235 - int irq_pendwn; 236 - int irq_datardy; 237 237 int error; 238 238 239 239 da9052 = dev_get_drvdata(pdev->dev.parent); 240 240 if (!da9052) 241 241 return -EINVAL; 242 - 243 - irq_pendwn = platform_get_irq_byname(pdev, "PENDWN"); 244 - irq_datardy = platform_get_irq_byname(pdev, "TSIRDY"); 245 - if (irq_pendwn < 0 || irq_datardy < 0) { 246 - dev_err(da9052->dev, "Unable to determine device interrupts\n"); 247 - return -ENXIO; 248 - } 249 242 250 243 tsi = kzalloc(sizeof(struct da9052_tsi), GFP_KERNEL); 251 244 input_dev = input_allocate_device(); ··· 247 258 248 259 tsi->da9052 = da9052; 249 260 tsi->dev = input_dev; 250 - tsi->irq_pendwn = da9052->irq_base + irq_pendwn; 251 - tsi->irq_datardy = da9052->irq_base + irq_datardy; 252 261 tsi->stopped = true; 253 262 INIT_DELAYED_WORK(&tsi->ts_pen_work, da9052_ts_pen_work); 254 263 ··· 274 287 /* Disable ADC */ 275 288 da9052_ts_adc_toggle(tsi, false); 276 289 277 - error = request_threaded_irq(tsi->irq_pendwn, 278 - NULL, da9052_ts_pendwn_irq, 279 - IRQF_TRIGGER_LOW | IRQF_ONESHOT, 280 - "PENDWN", tsi); 290 + error = da9052_request_irq(tsi->da9052, DA9052_IRQ_PENDOWN, 291 + "pendown-irq", da9052_ts_pendwn_irq, tsi); 281 292 if (error) { 282 293 dev_err(tsi->da9052->dev, 283 - "Failed to register PENDWN IRQ %d, error = %d\n", 284 - tsi->irq_pendwn, error); 294 + "Failed to register PENDWN IRQ: %d\n", error); 285 295 goto err_free_mem; 286 296 } 287 297 288 - error = request_threaded_irq(tsi->irq_datardy, 289 - NULL, da9052_ts_datardy_irq, 290 - IRQF_TRIGGER_LOW | IRQF_ONESHOT, 291 - "TSIRDY", tsi); 298 + error = da9052_request_irq(tsi->da9052, DA9052_IRQ_TSIREADY, 299 + "tsiready-irq", da9052_ts_datardy_irq, tsi); 292 300 if (error) { 293 301 dev_err(tsi->da9052->dev, 294 - "Failed to register TSIRDY IRQ %d, error = %d\n", 295 - tsi->irq_datardy, error); 302 + "Failed to register TSIRDY IRQ :%d\n", error); 296 303 goto err_free_pendwn_irq; 297 304 } 298 305 299 306 /* Mask PEN_DOWN and TSI_READY events */ 300 - disable_irq(tsi->irq_pendwn); 301 - disable_irq(tsi->irq_datardy); 307 + da9052_disable_irq(tsi->da9052, DA9052_IRQ_PENDOWN); 308 + da9052_disable_irq(tsi->da9052, DA9052_IRQ_TSIREADY); 302 309 303 310 error = da9052_configure_tsi(tsi); 304 311 if (error) ··· 307 326 return 0; 308 327 309 328 err_free_datardy_irq: 310 - free_irq(tsi->irq_datardy, tsi); 329 + da9052_free_irq(tsi->da9052, DA9052_IRQ_TSIREADY, tsi); 311 330 err_free_pendwn_irq: 312 - free_irq(tsi->irq_pendwn, tsi); 331 + da9052_free_irq(tsi->da9052, DA9052_IRQ_PENDOWN, tsi); 313 332 err_free_mem: 314 333 kfree(tsi); 315 334 input_free_device(input_dev); ··· 323 342 324 343 da9052_reg_write(tsi->da9052, DA9052_LDO9_REG, 0x19); 325 344 326 - free_irq(tsi->irq_pendwn, tsi); 327 - free_irq(tsi->irq_datardy, tsi); 345 + da9052_free_irq(tsi->da9052, DA9052_IRQ_TSIREADY, tsi); 346 + da9052_free_irq(tsi->da9052, DA9052_IRQ_PENDOWN, tsi); 328 347 329 348 input_unregister_device(tsi->dev); 330 349 kfree(tsi);
+398
drivers/input/touchscreen/ti_am335x_tsc.c
··· 1 + /* 2 + * TI Touch Screen driver 3 + * 4 + * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License as 8 + * published by the Free Software Foundation version 2. 9 + * 10 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 11 + * kind, whether express or implied; without even the implied warranty 12 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + */ 15 + 16 + 17 + #include <linux/init.h> 18 + #include <linux/kernel.h> 19 + #include <linux/err.h> 20 + #include <linux/module.h> 21 + #include <linux/input.h> 22 + #include <linux/slab.h> 23 + #include <linux/interrupt.h> 24 + #include <linux/clk.h> 25 + #include <linux/platform_device.h> 26 + #include <linux/io.h> 27 + #include <linux/input/ti_am335x_tsc.h> 28 + #include <linux/delay.h> 29 + 30 + #include <linux/mfd/ti_am335x_tscadc.h> 31 + 32 + #define ADCFSM_STEPID 0x10 33 + #define SEQ_SETTLE 275 34 + #define MAX_12BIT ((1 << 12) - 1) 35 + 36 + struct titsc { 37 + struct input_dev *input; 38 + struct ti_tscadc_dev *mfd_tscadc; 39 + unsigned int irq; 40 + unsigned int wires; 41 + unsigned int x_plate_resistance; 42 + bool pen_down; 43 + int steps_to_configure; 44 + }; 45 + 46 + static unsigned int titsc_readl(struct titsc *ts, unsigned int reg) 47 + { 48 + return readl(ts->mfd_tscadc->tscadc_base + reg); 49 + } 50 + 51 + static void titsc_writel(struct titsc *tsc, unsigned int reg, 52 + unsigned int val) 53 + { 54 + writel(val, tsc->mfd_tscadc->tscadc_base + reg); 55 + } 56 + 57 + static void titsc_step_config(struct titsc *ts_dev) 58 + { 59 + unsigned int config; 60 + int i, total_steps; 61 + 62 + /* Configure the Step registers */ 63 + total_steps = 2 * ts_dev->steps_to_configure; 64 + 65 + config = STEPCONFIG_MODE_HWSYNC | 66 + STEPCONFIG_AVG_16 | STEPCONFIG_XPP; 67 + switch (ts_dev->wires) { 68 + case 4: 69 + config |= STEPCONFIG_INP_AN2 | STEPCONFIG_XNN; 70 + break; 71 + case 5: 72 + config |= STEPCONFIG_YNN | 73 + STEPCONFIG_INP_AN4 | STEPCONFIG_XNN | 74 + STEPCONFIG_YPP; 75 + break; 76 + case 8: 77 + config |= STEPCONFIG_INP_AN2 | STEPCONFIG_XNN; 78 + break; 79 + } 80 + 81 + for (i = 1; i <= ts_dev->steps_to_configure; i++) { 82 + titsc_writel(ts_dev, REG_STEPCONFIG(i), config); 83 + titsc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY); 84 + } 85 + 86 + config = 0; 87 + config = STEPCONFIG_MODE_HWSYNC | 88 + STEPCONFIG_AVG_16 | STEPCONFIG_YNN | 89 + STEPCONFIG_INM_ADCREFM | STEPCONFIG_FIFO1; 90 + switch (ts_dev->wires) { 91 + case 4: 92 + config |= STEPCONFIG_YPP; 93 + break; 94 + case 5: 95 + config |= STEPCONFIG_XPP | STEPCONFIG_INP_AN4 | 96 + STEPCONFIG_XNP | STEPCONFIG_YPN; 97 + break; 98 + case 8: 99 + config |= STEPCONFIG_YPP; 100 + break; 101 + } 102 + 103 + for (i = (ts_dev->steps_to_configure + 1); i <= total_steps; i++) { 104 + titsc_writel(ts_dev, REG_STEPCONFIG(i), config); 105 + titsc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY); 106 + } 107 + 108 + config = 0; 109 + /* Charge step configuration */ 110 + config = STEPCONFIG_XPP | STEPCONFIG_YNN | 111 + STEPCHARGE_RFP_XPUL | STEPCHARGE_RFM_XNUR | 112 + STEPCHARGE_INM_AN1 | STEPCHARGE_INP_AN1; 113 + 114 + titsc_writel(ts_dev, REG_CHARGECONFIG, config); 115 + titsc_writel(ts_dev, REG_CHARGEDELAY, CHARGEDLY_OPENDLY); 116 + 117 + config = 0; 118 + /* Configure to calculate pressure */ 119 + config = STEPCONFIG_MODE_HWSYNC | 120 + STEPCONFIG_AVG_16 | STEPCONFIG_YPP | 121 + STEPCONFIG_XNN | STEPCONFIG_INM_ADCREFM; 122 + titsc_writel(ts_dev, REG_STEPCONFIG(total_steps + 1), config); 123 + titsc_writel(ts_dev, REG_STEPDELAY(total_steps + 1), 124 + STEPCONFIG_OPENDLY); 125 + 126 + config |= STEPCONFIG_INP_AN3 | STEPCONFIG_FIFO1; 127 + titsc_writel(ts_dev, REG_STEPCONFIG(total_steps + 2), config); 128 + titsc_writel(ts_dev, REG_STEPDELAY(total_steps + 2), 129 + STEPCONFIG_OPENDLY); 130 + 131 + titsc_writel(ts_dev, REG_SE, STPENB_STEPENB_TC); 132 + } 133 + 134 + static void titsc_read_coordinates(struct titsc *ts_dev, 135 + unsigned int *x, unsigned int *y) 136 + { 137 + unsigned int fifocount = titsc_readl(ts_dev, REG_FIFO0CNT); 138 + unsigned int prev_val_x = ~0, prev_val_y = ~0; 139 + unsigned int prev_diff_x = ~0, prev_diff_y = ~0; 140 + unsigned int read, diff; 141 + unsigned int i, channel; 142 + 143 + /* 144 + * Delta filter is used to remove large variations in sampled 145 + * values from ADC. The filter tries to predict where the next 146 + * coordinate could be. This is done by taking a previous 147 + * coordinate and subtracting it form current one. Further the 148 + * algorithm compares the difference with that of a present value, 149 + * if true the value is reported to the sub system. 150 + */ 151 + for (i = 0; i < fifocount - 1; i++) { 152 + read = titsc_readl(ts_dev, REG_FIFO0); 153 + channel = read & 0xf0000; 154 + channel = channel >> 0x10; 155 + if ((channel >= 0) && (channel < ts_dev->steps_to_configure)) { 156 + read &= 0xfff; 157 + diff = abs(read - prev_val_x); 158 + if (diff < prev_diff_x) { 159 + prev_diff_x = diff; 160 + *x = read; 161 + } 162 + prev_val_x = read; 163 + } 164 + 165 + read = titsc_readl(ts_dev, REG_FIFO1); 166 + channel = read & 0xf0000; 167 + channel = channel >> 0x10; 168 + if ((channel >= ts_dev->steps_to_configure) && 169 + (channel < (2 * ts_dev->steps_to_configure - 1))) { 170 + read &= 0xfff; 171 + diff = abs(read - prev_val_y); 172 + if (diff < prev_diff_y) { 173 + prev_diff_y = diff; 174 + *y = read; 175 + } 176 + prev_val_y = read; 177 + } 178 + } 179 + } 180 + 181 + static irqreturn_t titsc_irq(int irq, void *dev) 182 + { 183 + struct titsc *ts_dev = dev; 184 + struct input_dev *input_dev = ts_dev->input; 185 + unsigned int status, irqclr = 0; 186 + unsigned int x = 0, y = 0; 187 + unsigned int z1, z2, z; 188 + unsigned int fsm; 189 + unsigned int fifo1count, fifo0count; 190 + int i; 191 + 192 + status = titsc_readl(ts_dev, REG_IRQSTATUS); 193 + if (status & IRQENB_FIFO0THRES) { 194 + titsc_read_coordinates(ts_dev, &x, &y); 195 + 196 + z1 = titsc_readl(ts_dev, REG_FIFO0) & 0xfff; 197 + z2 = titsc_readl(ts_dev, REG_FIFO1) & 0xfff; 198 + 199 + fifo1count = titsc_readl(ts_dev, REG_FIFO1CNT); 200 + for (i = 0; i < fifo1count; i++) 201 + titsc_readl(ts_dev, REG_FIFO1); 202 + 203 + fifo0count = titsc_readl(ts_dev, REG_FIFO0CNT); 204 + for (i = 0; i < fifo0count; i++) 205 + titsc_readl(ts_dev, REG_FIFO0); 206 + 207 + if (ts_dev->pen_down && z1 != 0 && z2 != 0) { 208 + /* 209 + * Calculate pressure using formula 210 + * Resistance(touch) = x plate resistance * 211 + * x postion/4096 * ((z2 / z1) - 1) 212 + */ 213 + z = z2 - z1; 214 + z *= x; 215 + z *= ts_dev->x_plate_resistance; 216 + z /= z1; 217 + z = (z + 2047) >> 12; 218 + 219 + if (z <= MAX_12BIT) { 220 + input_report_abs(input_dev, ABS_X, x); 221 + input_report_abs(input_dev, ABS_Y, y); 222 + input_report_abs(input_dev, ABS_PRESSURE, z); 223 + input_report_key(input_dev, BTN_TOUCH, 1); 224 + input_sync(input_dev); 225 + } 226 + } 227 + irqclr |= IRQENB_FIFO0THRES; 228 + } 229 + 230 + /* 231 + * Time for sequencer to settle, to read 232 + * correct state of the sequencer. 233 + */ 234 + udelay(SEQ_SETTLE); 235 + 236 + status = titsc_readl(ts_dev, REG_RAWIRQSTATUS); 237 + if (status & IRQENB_PENUP) { 238 + /* Pen up event */ 239 + fsm = titsc_readl(ts_dev, REG_ADCFSM); 240 + if (fsm == ADCFSM_STEPID) { 241 + ts_dev->pen_down = false; 242 + input_report_key(input_dev, BTN_TOUCH, 0); 243 + input_report_abs(input_dev, ABS_PRESSURE, 0); 244 + input_sync(input_dev); 245 + } else { 246 + ts_dev->pen_down = true; 247 + } 248 + irqclr |= IRQENB_PENUP; 249 + } 250 + 251 + titsc_writel(ts_dev, REG_IRQSTATUS, irqclr); 252 + 253 + titsc_writel(ts_dev, REG_SE, STPENB_STEPENB_TC); 254 + return IRQ_HANDLED; 255 + } 256 + 257 + /* 258 + * The functions for inserting/removing driver as a module. 259 + */ 260 + 261 + static int __devinit titsc_probe(struct platform_device *pdev) 262 + { 263 + struct titsc *ts_dev; 264 + struct input_dev *input_dev; 265 + struct ti_tscadc_dev *tscadc_dev = pdev->dev.platform_data; 266 + struct mfd_tscadc_board *pdata; 267 + int err; 268 + 269 + pdata = tscadc_dev->dev->platform_data; 270 + 271 + if (!pdata) { 272 + dev_err(&pdev->dev, "Could not find platform data\n"); 273 + return -EINVAL; 274 + } 275 + 276 + /* Allocate memory for device */ 277 + ts_dev = kzalloc(sizeof(struct titsc), GFP_KERNEL); 278 + input_dev = input_allocate_device(); 279 + if (!ts_dev || !input_dev) { 280 + dev_err(&pdev->dev, "failed to allocate memory.\n"); 281 + err = -ENOMEM; 282 + goto err_free_mem; 283 + } 284 + 285 + tscadc_dev->tsc = ts_dev; 286 + ts_dev->mfd_tscadc = tscadc_dev; 287 + ts_dev->input = input_dev; 288 + ts_dev->irq = tscadc_dev->irq; 289 + ts_dev->wires = pdata->tsc_init->wires; 290 + ts_dev->x_plate_resistance = pdata->tsc_init->x_plate_resistance; 291 + ts_dev->steps_to_configure = pdata->tsc_init->steps_to_configure; 292 + 293 + err = request_irq(ts_dev->irq, titsc_irq, 294 + 0, pdev->dev.driver->name, ts_dev); 295 + if (err) { 296 + dev_err(&pdev->dev, "failed to allocate irq.\n"); 297 + goto err_free_mem; 298 + } 299 + 300 + titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_FIFO0THRES); 301 + titsc_step_config(ts_dev); 302 + titsc_writel(ts_dev, REG_FIFO0THR, ts_dev->steps_to_configure); 303 + 304 + input_dev->name = "ti-tsc"; 305 + input_dev->dev.parent = &pdev->dev; 306 + 307 + input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 308 + input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); 309 + 310 + input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0); 311 + input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0); 312 + input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, 0, 0); 313 + 314 + /* register to the input system */ 315 + err = input_register_device(input_dev); 316 + if (err) 317 + goto err_free_irq; 318 + 319 + platform_set_drvdata(pdev, ts_dev); 320 + return 0; 321 + 322 + err_free_irq: 323 + free_irq(ts_dev->irq, ts_dev); 324 + err_free_mem: 325 + input_free_device(input_dev); 326 + kfree(ts_dev); 327 + return err; 328 + } 329 + 330 + static int __devexit titsc_remove(struct platform_device *pdev) 331 + { 332 + struct ti_tscadc_dev *tscadc_dev = pdev->dev.platform_data; 333 + struct titsc *ts_dev = tscadc_dev->tsc; 334 + 335 + free_irq(ts_dev->irq, ts_dev); 336 + 337 + input_unregister_device(ts_dev->input); 338 + 339 + platform_set_drvdata(pdev, NULL); 340 + kfree(ts_dev); 341 + return 0; 342 + } 343 + 344 + #ifdef CONFIG_PM 345 + static int titsc_suspend(struct device *dev) 346 + { 347 + struct ti_tscadc_dev *tscadc_dev = dev->platform_data; 348 + struct titsc *ts_dev = tscadc_dev->tsc; 349 + unsigned int idle; 350 + 351 + if (device_may_wakeup(tscadc_dev->dev)) { 352 + idle = titsc_readl(ts_dev, REG_IRQENABLE); 353 + titsc_writel(ts_dev, REG_IRQENABLE, 354 + (idle | IRQENB_HW_PEN)); 355 + titsc_writel(ts_dev, REG_IRQWAKEUP, IRQWKUP_ENB); 356 + } 357 + return 0; 358 + } 359 + 360 + static int titsc_resume(struct device *dev) 361 + { 362 + struct ti_tscadc_dev *tscadc_dev = dev->platform_data; 363 + struct titsc *ts_dev = tscadc_dev->tsc; 364 + 365 + if (device_may_wakeup(tscadc_dev->dev)) { 366 + titsc_writel(ts_dev, REG_IRQWAKEUP, 367 + 0x00); 368 + titsc_writel(ts_dev, REG_IRQCLR, IRQENB_HW_PEN); 369 + } 370 + titsc_step_config(ts_dev); 371 + titsc_writel(ts_dev, REG_FIFO0THR, 372 + ts_dev->steps_to_configure); 373 + return 0; 374 + } 375 + 376 + static const struct dev_pm_ops titsc_pm_ops = { 377 + .suspend = titsc_suspend, 378 + .resume = titsc_resume, 379 + }; 380 + #define TITSC_PM_OPS (&titsc_pm_ops) 381 + #else 382 + #define TITSC_PM_OPS NULL 383 + #endif 384 + 385 + static struct platform_driver ti_tsc_driver = { 386 + .probe = titsc_probe, 387 + .remove = __devexit_p(titsc_remove), 388 + .driver = { 389 + .name = "tsc", 390 + .owner = THIS_MODULE, 391 + .pm = TITSC_PM_OPS, 392 + }, 393 + }; 394 + module_platform_driver(ti_tsc_driver); 395 + 396 + MODULE_DESCRIPTION("TI touchscreen controller driver"); 397 + MODULE_AUTHOR("Rachna Patil <rachna@ti.com>"); 398 + MODULE_LICENSE("GPL");
-486
drivers/input/touchscreen/ti_tscadc.c
··· 1 - /* 2 - * TI Touch Screen driver 3 - * 4 - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ 5 - * 6 - * This program is free software; you can redistribute it and/or 7 - * modify it under the terms of the GNU General Public License as 8 - * published by the Free Software Foundation version 2. 9 - * 10 - * This program is distributed "as is" WITHOUT ANY WARRANTY of any 11 - * kind, whether express or implied; without even the implied warranty 12 - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 - * GNU General Public License for more details. 14 - */ 15 - 16 - 17 - #include <linux/init.h> 18 - #include <linux/kernel.h> 19 - #include <linux/err.h> 20 - #include <linux/module.h> 21 - #include <linux/input.h> 22 - #include <linux/slab.h> 23 - #include <linux/interrupt.h> 24 - #include <linux/clk.h> 25 - #include <linux/platform_device.h> 26 - #include <linux/io.h> 27 - #include <linux/input/ti_tscadc.h> 28 - #include <linux/delay.h> 29 - 30 - #define REG_IRQEOI 0x020 31 - #define REG_RAWIRQSTATUS 0x024 32 - #define REG_IRQSTATUS 0x028 33 - #define REG_IRQENABLE 0x02C 34 - #define REG_IRQWAKEUP 0x034 35 - #define REG_CTRL 0x040 36 - #define REG_ADCFSM 0x044 37 - #define REG_CLKDIV 0x04C 38 - #define REG_SE 0x054 39 - #define REG_IDLECONFIG 0x058 40 - #define REG_CHARGECONFIG 0x05C 41 - #define REG_CHARGEDELAY 0x060 42 - #define REG_STEPCONFIG(n) (0x64 + ((n - 1) * 8)) 43 - #define REG_STEPDELAY(n) (0x68 + ((n - 1) * 8)) 44 - #define REG_STEPCONFIG13 0x0C4 45 - #define REG_STEPDELAY13 0x0C8 46 - #define REG_STEPCONFIG14 0x0CC 47 - #define REG_STEPDELAY14 0x0D0 48 - #define REG_FIFO0CNT 0xE4 49 - #define REG_FIFO1THR 0xF4 50 - #define REG_FIFO0 0x100 51 - #define REG_FIFO1 0x200 52 - 53 - /* Register Bitfields */ 54 - #define IRQWKUP_ENB BIT(0) 55 - #define STPENB_STEPENB 0x7FFF 56 - #define IRQENB_FIFO1THRES BIT(5) 57 - #define IRQENB_PENUP BIT(9) 58 - #define STEPCONFIG_MODE_HWSYNC 0x2 59 - #define STEPCONFIG_SAMPLES_AVG (1 << 4) 60 - #define STEPCONFIG_XPP (1 << 5) 61 - #define STEPCONFIG_XNN (1 << 6) 62 - #define STEPCONFIG_YPP (1 << 7) 63 - #define STEPCONFIG_YNN (1 << 8) 64 - #define STEPCONFIG_XNP (1 << 9) 65 - #define STEPCONFIG_YPN (1 << 10) 66 - #define STEPCONFIG_INM (1 << 18) 67 - #define STEPCONFIG_INP (1 << 20) 68 - #define STEPCONFIG_INP_5 (1 << 21) 69 - #define STEPCONFIG_FIFO1 (1 << 26) 70 - #define STEPCONFIG_OPENDLY 0xff 71 - #define STEPCONFIG_Z1 (3 << 19) 72 - #define STEPIDLE_INP (1 << 22) 73 - #define STEPCHARGE_RFP (1 << 12) 74 - #define STEPCHARGE_INM (1 << 15) 75 - #define STEPCHARGE_INP (1 << 19) 76 - #define STEPCHARGE_RFM (1 << 23) 77 - #define STEPCHARGE_DELAY 0x1 78 - #define CNTRLREG_TSCSSENB (1 << 0) 79 - #define CNTRLREG_STEPID (1 << 1) 80 - #define CNTRLREG_STEPCONFIGWRT (1 << 2) 81 - #define CNTRLREG_4WIRE (1 << 5) 82 - #define CNTRLREG_5WIRE (1 << 6) 83 - #define CNTRLREG_8WIRE (3 << 5) 84 - #define CNTRLREG_TSCENB (1 << 7) 85 - #define ADCFSM_STEPID 0x10 86 - 87 - #define SEQ_SETTLE 275 88 - #define ADC_CLK 3000000 89 - #define MAX_12BIT ((1 << 12) - 1) 90 - #define TSCADC_DELTA_X 15 91 - #define TSCADC_DELTA_Y 15 92 - 93 - struct tscadc { 94 - struct input_dev *input; 95 - struct clk *tsc_ick; 96 - void __iomem *tsc_base; 97 - unsigned int irq; 98 - unsigned int wires; 99 - unsigned int x_plate_resistance; 100 - bool pen_down; 101 - }; 102 - 103 - static unsigned int tscadc_readl(struct tscadc *ts, unsigned int reg) 104 - { 105 - return readl(ts->tsc_base + reg); 106 - } 107 - 108 - static void tscadc_writel(struct tscadc *tsc, unsigned int reg, 109 - unsigned int val) 110 - { 111 - writel(val, tsc->tsc_base + reg); 112 - } 113 - 114 - static void tscadc_step_config(struct tscadc *ts_dev) 115 - { 116 - unsigned int config; 117 - int i; 118 - 119 - /* Configure the Step registers */ 120 - 121 - config = STEPCONFIG_MODE_HWSYNC | 122 - STEPCONFIG_SAMPLES_AVG | STEPCONFIG_XPP; 123 - switch (ts_dev->wires) { 124 - case 4: 125 - config |= STEPCONFIG_INP | STEPCONFIG_XNN; 126 - break; 127 - case 5: 128 - config |= STEPCONFIG_YNN | 129 - STEPCONFIG_INP_5 | STEPCONFIG_XNN | 130 - STEPCONFIG_YPP; 131 - break; 132 - case 8: 133 - config |= STEPCONFIG_INP | STEPCONFIG_XNN; 134 - break; 135 - } 136 - 137 - for (i = 1; i < 7; i++) { 138 - tscadc_writel(ts_dev, REG_STEPCONFIG(i), config); 139 - tscadc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY); 140 - } 141 - 142 - config = 0; 143 - config = STEPCONFIG_MODE_HWSYNC | 144 - STEPCONFIG_SAMPLES_AVG | STEPCONFIG_YNN | 145 - STEPCONFIG_INM | STEPCONFIG_FIFO1; 146 - switch (ts_dev->wires) { 147 - case 4: 148 - config |= STEPCONFIG_YPP; 149 - break; 150 - case 5: 151 - config |= STEPCONFIG_XPP | STEPCONFIG_INP_5 | 152 - STEPCONFIG_XNP | STEPCONFIG_YPN; 153 - break; 154 - case 8: 155 - config |= STEPCONFIG_YPP; 156 - break; 157 - } 158 - 159 - for (i = 7; i < 13; i++) { 160 - tscadc_writel(ts_dev, REG_STEPCONFIG(i), config); 161 - tscadc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY); 162 - } 163 - 164 - config = 0; 165 - /* Charge step configuration */ 166 - config = STEPCONFIG_XPP | STEPCONFIG_YNN | 167 - STEPCHARGE_RFP | STEPCHARGE_RFM | 168 - STEPCHARGE_INM | STEPCHARGE_INP; 169 - 170 - tscadc_writel(ts_dev, REG_CHARGECONFIG, config); 171 - tscadc_writel(ts_dev, REG_CHARGEDELAY, STEPCHARGE_DELAY); 172 - 173 - config = 0; 174 - /* Configure to calculate pressure */ 175 - config = STEPCONFIG_MODE_HWSYNC | 176 - STEPCONFIG_SAMPLES_AVG | STEPCONFIG_YPP | 177 - STEPCONFIG_XNN | STEPCONFIG_INM; 178 - tscadc_writel(ts_dev, REG_STEPCONFIG13, config); 179 - tscadc_writel(ts_dev, REG_STEPDELAY13, STEPCONFIG_OPENDLY); 180 - 181 - config |= STEPCONFIG_Z1 | STEPCONFIG_FIFO1; 182 - tscadc_writel(ts_dev, REG_STEPCONFIG14, config); 183 - tscadc_writel(ts_dev, REG_STEPDELAY14, STEPCONFIG_OPENDLY); 184 - 185 - tscadc_writel(ts_dev, REG_SE, STPENB_STEPENB); 186 - } 187 - 188 - static void tscadc_idle_config(struct tscadc *ts_config) 189 - { 190 - unsigned int idleconfig; 191 - 192 - idleconfig = STEPCONFIG_YNN | 193 - STEPCONFIG_INM | 194 - STEPCONFIG_YPN | STEPIDLE_INP; 195 - tscadc_writel(ts_config, REG_IDLECONFIG, idleconfig); 196 - } 197 - 198 - static void tscadc_read_coordinates(struct tscadc *ts_dev, 199 - unsigned int *x, unsigned int *y) 200 - { 201 - unsigned int fifocount = tscadc_readl(ts_dev, REG_FIFO0CNT); 202 - unsigned int prev_val_x = ~0, prev_val_y = ~0; 203 - unsigned int prev_diff_x = ~0, prev_diff_y = ~0; 204 - unsigned int read, diff; 205 - unsigned int i; 206 - 207 - /* 208 - * Delta filter is used to remove large variations in sampled 209 - * values from ADC. The filter tries to predict where the next 210 - * coordinate could be. This is done by taking a previous 211 - * coordinate and subtracting it form current one. Further the 212 - * algorithm compares the difference with that of a present value, 213 - * if true the value is reported to the sub system. 214 - */ 215 - for (i = 0; i < fifocount - 1; i++) { 216 - read = tscadc_readl(ts_dev, REG_FIFO0) & 0xfff; 217 - diff = abs(read - prev_val_x); 218 - if (diff < prev_diff_x) { 219 - prev_diff_x = diff; 220 - *x = read; 221 - } 222 - prev_val_x = read; 223 - 224 - read = tscadc_readl(ts_dev, REG_FIFO1) & 0xfff; 225 - diff = abs(read - prev_val_y); 226 - if (diff < prev_diff_y) { 227 - prev_diff_y = diff; 228 - *y = read; 229 - } 230 - prev_val_y = read; 231 - } 232 - } 233 - 234 - static irqreturn_t tscadc_irq(int irq, void *dev) 235 - { 236 - struct tscadc *ts_dev = dev; 237 - struct input_dev *input_dev = ts_dev->input; 238 - unsigned int status, irqclr = 0; 239 - unsigned int x = 0, y = 0; 240 - unsigned int z1, z2, z; 241 - unsigned int fsm; 242 - 243 - status = tscadc_readl(ts_dev, REG_IRQSTATUS); 244 - if (status & IRQENB_FIFO1THRES) { 245 - tscadc_read_coordinates(ts_dev, &x, &y); 246 - 247 - z1 = tscadc_readl(ts_dev, REG_FIFO0) & 0xfff; 248 - z2 = tscadc_readl(ts_dev, REG_FIFO1) & 0xfff; 249 - 250 - if (ts_dev->pen_down && z1 != 0 && z2 != 0) { 251 - /* 252 - * Calculate pressure using formula 253 - * Resistance(touch) = x plate resistance * 254 - * x postion/4096 * ((z2 / z1) - 1) 255 - */ 256 - z = z2 - z1; 257 - z *= x; 258 - z *= ts_dev->x_plate_resistance; 259 - z /= z1; 260 - z = (z + 2047) >> 12; 261 - 262 - if (z <= MAX_12BIT) { 263 - input_report_abs(input_dev, ABS_X, x); 264 - input_report_abs(input_dev, ABS_Y, y); 265 - input_report_abs(input_dev, ABS_PRESSURE, z); 266 - input_report_key(input_dev, BTN_TOUCH, 1); 267 - input_sync(input_dev); 268 - } 269 - } 270 - irqclr |= IRQENB_FIFO1THRES; 271 - } 272 - 273 - /* 274 - * Time for sequencer to settle, to read 275 - * correct state of the sequencer. 276 - */ 277 - udelay(SEQ_SETTLE); 278 - 279 - status = tscadc_readl(ts_dev, REG_RAWIRQSTATUS); 280 - if (status & IRQENB_PENUP) { 281 - /* Pen up event */ 282 - fsm = tscadc_readl(ts_dev, REG_ADCFSM); 283 - if (fsm == ADCFSM_STEPID) { 284 - ts_dev->pen_down = false; 285 - input_report_key(input_dev, BTN_TOUCH, 0); 286 - input_report_abs(input_dev, ABS_PRESSURE, 0); 287 - input_sync(input_dev); 288 - } else { 289 - ts_dev->pen_down = true; 290 - } 291 - irqclr |= IRQENB_PENUP; 292 - } 293 - 294 - tscadc_writel(ts_dev, REG_IRQSTATUS, irqclr); 295 - /* check pending interrupts */ 296 - tscadc_writel(ts_dev, REG_IRQEOI, 0x0); 297 - 298 - tscadc_writel(ts_dev, REG_SE, STPENB_STEPENB); 299 - return IRQ_HANDLED; 300 - } 301 - 302 - /* 303 - * The functions for inserting/removing driver as a module. 304 - */ 305 - 306 - static int __devinit tscadc_probe(struct platform_device *pdev) 307 - { 308 - const struct tsc_data *pdata = pdev->dev.platform_data; 309 - struct resource *res; 310 - struct tscadc *ts_dev; 311 - struct input_dev *input_dev; 312 - struct clk *clk; 313 - int err; 314 - int clk_value, ctrl, irq; 315 - 316 - if (!pdata) { 317 - dev_err(&pdev->dev, "missing platform data.\n"); 318 - return -EINVAL; 319 - } 320 - 321 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 322 - if (!res) { 323 - dev_err(&pdev->dev, "no memory resource defined.\n"); 324 - return -EINVAL; 325 - } 326 - 327 - irq = platform_get_irq(pdev, 0); 328 - if (irq < 0) { 329 - dev_err(&pdev->dev, "no irq ID is specified.\n"); 330 - return -EINVAL; 331 - } 332 - 333 - /* Allocate memory for device */ 334 - ts_dev = kzalloc(sizeof(struct tscadc), GFP_KERNEL); 335 - input_dev = input_allocate_device(); 336 - if (!ts_dev || !input_dev) { 337 - dev_err(&pdev->dev, "failed to allocate memory.\n"); 338 - err = -ENOMEM; 339 - goto err_free_mem; 340 - } 341 - 342 - ts_dev->input = input_dev; 343 - ts_dev->irq = irq; 344 - ts_dev->wires = pdata->wires; 345 - ts_dev->x_plate_resistance = pdata->x_plate_resistance; 346 - 347 - res = request_mem_region(res->start, resource_size(res), pdev->name); 348 - if (!res) { 349 - dev_err(&pdev->dev, "failed to reserve registers.\n"); 350 - err = -EBUSY; 351 - goto err_free_mem; 352 - } 353 - 354 - ts_dev->tsc_base = ioremap(res->start, resource_size(res)); 355 - if (!ts_dev->tsc_base) { 356 - dev_err(&pdev->dev, "failed to map registers.\n"); 357 - err = -ENOMEM; 358 - goto err_release_mem_region; 359 - } 360 - 361 - err = request_irq(ts_dev->irq, tscadc_irq, 362 - 0, pdev->dev.driver->name, ts_dev); 363 - if (err) { 364 - dev_err(&pdev->dev, "failed to allocate irq.\n"); 365 - goto err_unmap_regs; 366 - } 367 - 368 - ts_dev->tsc_ick = clk_get(&pdev->dev, "adc_tsc_ick"); 369 - if (IS_ERR(ts_dev->tsc_ick)) { 370 - dev_err(&pdev->dev, "failed to get TSC ick\n"); 371 - goto err_free_irq; 372 - } 373 - clk_enable(ts_dev->tsc_ick); 374 - 375 - clk = clk_get(&pdev->dev, "adc_tsc_fck"); 376 - if (IS_ERR(clk)) { 377 - dev_err(&pdev->dev, "failed to get TSC fck\n"); 378 - err = PTR_ERR(clk); 379 - goto err_disable_clk; 380 - } 381 - 382 - clk_value = clk_get_rate(clk) / ADC_CLK; 383 - clk_put(clk); 384 - 385 - if (clk_value < 7) { 386 - dev_err(&pdev->dev, "clock input less than min clock requirement\n"); 387 - goto err_disable_clk; 388 - } 389 - /* CLKDIV needs to be configured to the value minus 1 */ 390 - tscadc_writel(ts_dev, REG_CLKDIV, clk_value - 1); 391 - 392 - /* Enable wake-up of the SoC using touchscreen */ 393 - tscadc_writel(ts_dev, REG_IRQWAKEUP, IRQWKUP_ENB); 394 - 395 - ctrl = CNTRLREG_STEPCONFIGWRT | 396 - CNTRLREG_TSCENB | 397 - CNTRLREG_STEPID; 398 - switch (ts_dev->wires) { 399 - case 4: 400 - ctrl |= CNTRLREG_4WIRE; 401 - break; 402 - case 5: 403 - ctrl |= CNTRLREG_5WIRE; 404 - break; 405 - case 8: 406 - ctrl |= CNTRLREG_8WIRE; 407 - break; 408 - } 409 - tscadc_writel(ts_dev, REG_CTRL, ctrl); 410 - 411 - tscadc_idle_config(ts_dev); 412 - tscadc_writel(ts_dev, REG_IRQENABLE, IRQENB_FIFO1THRES); 413 - tscadc_step_config(ts_dev); 414 - tscadc_writel(ts_dev, REG_FIFO1THR, 6); 415 - 416 - ctrl |= CNTRLREG_TSCSSENB; 417 - tscadc_writel(ts_dev, REG_CTRL, ctrl); 418 - 419 - input_dev->name = "ti-tsc-adc"; 420 - input_dev->dev.parent = &pdev->dev; 421 - 422 - input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 423 - input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); 424 - 425 - input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0); 426 - input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0); 427 - input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, 0, 0); 428 - 429 - /* register to the input system */ 430 - err = input_register_device(input_dev); 431 - if (err) 432 - goto err_disable_clk; 433 - 434 - platform_set_drvdata(pdev, ts_dev); 435 - return 0; 436 - 437 - err_disable_clk: 438 - clk_disable(ts_dev->tsc_ick); 439 - clk_put(ts_dev->tsc_ick); 440 - err_free_irq: 441 - free_irq(ts_dev->irq, ts_dev); 442 - err_unmap_regs: 443 - iounmap(ts_dev->tsc_base); 444 - err_release_mem_region: 445 - release_mem_region(res->start, resource_size(res)); 446 - err_free_mem: 447 - input_free_device(input_dev); 448 - kfree(ts_dev); 449 - return err; 450 - } 451 - 452 - static int __devexit tscadc_remove(struct platform_device *pdev) 453 - { 454 - struct tscadc *ts_dev = platform_get_drvdata(pdev); 455 - struct resource *res; 456 - 457 - free_irq(ts_dev->irq, ts_dev); 458 - 459 - input_unregister_device(ts_dev->input); 460 - 461 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 462 - iounmap(ts_dev->tsc_base); 463 - release_mem_region(res->start, resource_size(res)); 464 - 465 - clk_disable(ts_dev->tsc_ick); 466 - clk_put(ts_dev->tsc_ick); 467 - 468 - kfree(ts_dev); 469 - 470 - platform_set_drvdata(pdev, NULL); 471 - return 0; 472 - } 473 - 474 - static struct platform_driver ti_tsc_driver = { 475 - .probe = tscadc_probe, 476 - .remove = __devexit_p(tscadc_remove), 477 - .driver = { 478 - .name = "tsc", 479 - .owner = THIS_MODULE, 480 - }, 481 - }; 482 - module_platform_driver(ti_tsc_driver); 483 - 484 - MODULE_DESCRIPTION("TI touchscreen controller driver"); 485 - MODULE_AUTHOR("Rachna Patil <rachna@ti.com>"); 486 - MODULE_LICENSE("GPL");
+61 -2
drivers/mfd/Kconfig
··· 104 104 To compile this driver as a module, choose M here: the 105 105 module will be called ti-ssp. 106 106 107 + config MFD_TI_AM335X_TSCADC 108 + tristate "TI ADC / Touch Screen chip support" 109 + select MFD_CORE 110 + select REGMAP 111 + select REGMAP_MMIO 112 + help 113 + If you say yes here you get support for Texas Instruments series 114 + of Touch Screen /ADC chips. 115 + To compile this driver as a module, choose M here: the 116 + module will be called ti_am335x_tscadc. 117 + 107 118 config HTC_EGPIO 108 119 bool "HTC EGPIO support" 109 120 depends on GENERIC_HARDIRQS && GPIOLIB && ARM ··· 264 253 If you say yes here you get support for the TPS65912 series of 265 254 PM chips with SPI interface. 266 255 256 + config MFD_TPS80031 257 + bool "TI TPS80031/TPS80032 Power Management chips" 258 + depends on I2C=y && GENERIC_HARDIRQS 259 + select MFD_CORE 260 + select REGMAP_I2C 261 + select REGMAP_IRQ 262 + help 263 + If you say yes here you get support for the Texas Instruments 264 + TPS80031/ TPS80032 Fully Integrated Power Management with Power 265 + Path and Battery Charger. The device provides five configurable 266 + step-down converters, 11 general purpose LDOs, USB OTG Module, 267 + ADC, RTC, 2 PWM, System Voltage Regulator/Battery Charger with 268 + Power Path from USB, 32K clock generator. 269 + 267 270 config MENELAUS 268 271 bool "Texas Instruments TWL92330/Menelaus PM chip" 269 272 depends on I2C=y && ARCH_OMAP2 ··· 334 309 335 310 config TWL6040_CORE 336 311 bool "Support for TWL6040 audio codec" 337 - depends on I2C=y && GENERIC_HARDIRQS 312 + depends on I2C=y 338 313 select MFD_CORE 339 314 select REGMAP_I2C 340 - select IRQ_DOMAIN 315 + select REGMAP_IRQ 341 316 default n 342 317 help 343 318 Say yes here if you want support for Texas Instruments TWL6040 audio ··· 1015 990 depends on I2C=y && GENERIC_HARDIRQS 1016 991 select MFD_CORE 1017 992 select REGMAP_I2C 993 + select REGMAP_IRQ 1018 994 help 1019 995 If you say yes here you get support for the TPS65090 series of 1020 996 Power Management chips. ··· 1060 1034 bool "STA2X11 multi function device support" 1061 1035 depends on STA2X11 1062 1036 select MFD_CORE 1037 + select REGMAP_MMIO 1063 1038 1064 1039 config MFD_SYSCON 1065 1040 bool "System Controller Register R/W Based on Regmap" ··· 1079 1052 help 1080 1053 If you say yes here you get support for the Palmas 1081 1054 series of PMIC chips from Texas Instruments. 1055 + 1056 + config MFD_VIPERBOARD 1057 + tristate "Support for Nano River Technologies Viperboard" 1058 + select MFD_CORE 1059 + depends on USB 1060 + default n 1061 + help 1062 + Say yes here if you want support for Nano River Technologies 1063 + Viperboard. 1064 + There are mfd cell drivers available for i2c master, adc and 1065 + both gpios found on the board. The spi part does not yet 1066 + have a driver. 1067 + You need to select the mfd cell drivers separately. 1068 + The drivers do not support all features the board exposes. 1069 + 1070 + config MFD_RETU 1071 + tristate "Support for Retu multi-function device" 1072 + select MFD_CORE 1073 + depends on I2C 1074 + select REGMAP_IRQ 1075 + help 1076 + Retu is a multi-function device found on Nokia Internet Tablets 1077 + (770, N800 and N810). 1078 + 1079 + config MFD_AS3711 1080 + bool "Support for AS3711" 1081 + select MFD_CORE 1082 + select REGMAP_I2C 1083 + select REGMAP_IRQ 1084 + depends on I2C=y 1085 + help 1086 + Support for the AS3711 PMIC from AMS 1082 1087 1083 1088 endmenu 1084 1089 endif
+8 -2
drivers/mfd/Makefile
··· 19 19 obj-$(CONFIG_MFD_DAVINCI_VOICECODEC) += davinci_voicecodec.o 20 20 obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o 21 21 obj-$(CONFIG_MFD_TI_SSP) += ti-ssp.o 22 + obj-$(CONFIG_MFD_TI_AM335X_TSCADC) += ti_am335x_tscadc.o 22 23 23 24 obj-$(CONFIG_MFD_STA2X11) += sta2x11-mfd.o 24 25 obj-$(CONFIG_MFD_STMPE) += stmpe.o ··· 56 55 obj-$(CONFIG_TPS65010) += tps65010.o 57 56 obj-$(CONFIG_TPS6507X) += tps6507x.o 58 57 obj-$(CONFIG_MFD_TPS65217) += tps65217.o 59 - obj-$(CONFIG_MFD_TPS65910) += tps65910.o tps65910-irq.o 58 + obj-$(CONFIG_MFD_TPS65910) += tps65910.o 60 59 tps65912-objs := tps65912-core.o tps65912-irq.o 61 60 obj-$(CONFIG_MFD_TPS65912) += tps65912.o 62 61 obj-$(CONFIG_MFD_TPS65912_I2C) += tps65912-i2c.o 63 62 obj-$(CONFIG_MFD_TPS65912_SPI) += tps65912-spi.o 63 + obj-$(CONFIG_MFD_TPS80031) += tps80031.o 64 64 obj-$(CONFIG_MENELAUS) += menelaus.o 65 65 66 66 obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o 67 67 obj-$(CONFIG_TWL4030_MADC) += twl4030-madc.o 68 68 obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o 69 69 obj-$(CONFIG_MFD_TWL4030_AUDIO) += twl4030-audio.o 70 - obj-$(CONFIG_TWL6040_CORE) += twl6040-core.o twl6040-irq.o 70 + obj-$(CONFIG_TWL6040_CORE) += twl6040.o 71 71 72 72 obj-$(CONFIG_MFD_MC13XXX) += mc13xxx-core.o 73 73 obj-$(CONFIG_MFD_MC13XXX_SPI) += mc13xxx-spi.o ··· 91 89 92 90 obj-$(CONFIG_PMIC_DA903X) += da903x.o 93 91 92 + obj-$(CONFIG_PMIC_DA9052) += da9052-irq.o 94 93 obj-$(CONFIG_PMIC_DA9052) += da9052-core.o 95 94 obj-$(CONFIG_MFD_DA9052_SPI) += da9052-spi.o 96 95 obj-$(CONFIG_MFD_DA9052_I2C) += da9052-i2c.o ··· 140 137 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o 141 138 obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o 142 139 obj-$(CONFIG_MFD_PALMAS) += palmas.o 140 + obj-$(CONFIG_MFD_VIPERBOARD) += viperboard.o 143 141 obj-$(CONFIG_MFD_RC5T583) += rc5t583.o rc5t583-irq.o 144 142 obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o 145 143 obj-$(CONFIG_MFD_SYSCON) += syscon.o 146 144 obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o 147 145 obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress-config.o vexpress-sysreg.o 146 + obj-$(CONFIG_MFD_RETU) += retu-mfd.o 147 + obj-$(CONFIG_MFD_AS3711) += as3711.o
+28 -79
drivers/mfd/ab8500-core.c
··· 586 586 return 0; 587 587 } 588 588 589 - /* AB8500 GPIO Resources */ 590 - static struct resource __devinitdata ab8500_gpio_resources[] = { 591 - { 592 - .name = "GPIO_INT6", 593 - .start = AB8500_INT_GPIO6R, 594 - .end = AB8500_INT_GPIO41F, 595 - .flags = IORESOURCE_IRQ, 596 - } 597 - }; 598 - 599 - /* AB9540 GPIO Resources */ 600 - static struct resource __devinitdata ab9540_gpio_resources[] = { 601 - { 602 - .name = "GPIO_INT6", 603 - .start = AB8500_INT_GPIO6R, 604 - .end = AB8500_INT_GPIO41F, 605 - .flags = IORESOURCE_IRQ, 606 - }, 607 - { 608 - .name = "GPIO_INT14", 609 - .start = AB9540_INT_GPIO50R, 610 - .end = AB9540_INT_GPIO54R, 611 - .flags = IORESOURCE_IRQ, 612 - }, 613 - { 614 - .name = "GPIO_INT15", 615 - .start = AB9540_INT_GPIO50F, 616 - .end = AB9540_INT_GPIO54F, 617 - .flags = IORESOURCE_IRQ, 618 - } 619 - }; 620 - 621 589 static struct resource ab8500_gpadc_resources[] = { 622 590 { 623 591 .name = "HW_CONV_END", ··· 947 979 .of_compatible = "stericsson,ab8500-regulator", 948 980 }, 949 981 { 982 + .name = "abx500-clk", 983 + .of_compatible = "stericsson,abx500-clk", 984 + }, 985 + { 950 986 .name = "ab8500-gpadc", 951 987 .of_compatible = "stericsson,ab8500-gpadc", 952 988 .num_resources = ARRAY_SIZE(ab8500_gpadc_resources), ··· 1052 1080 { 1053 1081 .name = "ab8500-gpio", 1054 1082 .of_compatible = "stericsson,ab8500-gpio", 1055 - .num_resources = ARRAY_SIZE(ab8500_gpio_resources), 1056 - .resources = ab8500_gpio_resources, 1057 1083 }, 1058 1084 { 1059 1085 .name = "ab8500-usb", ··· 1068 1098 static struct mfd_cell ab9540_devs[] = { 1069 1099 { 1070 1100 .name = "ab8500-gpio", 1071 - .num_resources = ARRAY_SIZE(ab9540_gpio_resources), 1072 - .resources = ab9540_gpio_resources, 1073 1101 }, 1074 1102 { 1075 1103 .name = "ab9540-usb", ··· 1252 1284 int i; 1253 1285 u8 value; 1254 1286 1255 - ab8500 = kzalloc(sizeof *ab8500, GFP_KERNEL); 1287 + ab8500 = devm_kzalloc(&pdev->dev, sizeof *ab8500, GFP_KERNEL); 1256 1288 if (!ab8500) 1257 1289 return -ENOMEM; 1258 1290 ··· 1262 1294 ab8500->dev = &pdev->dev; 1263 1295 1264 1296 resource = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 1265 - if (!resource) { 1266 - ret = -ENODEV; 1267 - goto out_free_ab8500; 1268 - } 1297 + if (!resource) 1298 + return -ENODEV; 1269 1299 1270 1300 ab8500->irq = resource->start; 1271 1301 ··· 1286 1320 ret = get_register_interruptible(ab8500, AB8500_MISC, 1287 1321 AB8500_IC_NAME_REG, &value); 1288 1322 if (ret < 0) 1289 - goto out_free_ab8500; 1323 + return ret; 1290 1324 1291 1325 ab8500->version = value; 1292 1326 } ··· 1294 1328 ret = get_register_interruptible(ab8500, AB8500_MISC, 1295 1329 AB8500_REV_REG, &value); 1296 1330 if (ret < 0) 1297 - goto out_free_ab8500; 1331 + return ret; 1298 1332 1299 1333 ab8500->chip_id = value; 1300 1334 ··· 1311 1345 ab8500->mask_size = AB8500_NUM_IRQ_REGS; 1312 1346 ab8500->irq_reg_offset = ab8500_irq_regoffset; 1313 1347 } 1314 - ab8500->mask = kzalloc(ab8500->mask_size, GFP_KERNEL); 1348 + ab8500->mask = devm_kzalloc(&pdev->dev, ab8500->mask_size, GFP_KERNEL); 1315 1349 if (!ab8500->mask) 1316 1350 return -ENOMEM; 1317 - ab8500->oldmask = kzalloc(ab8500->mask_size, GFP_KERNEL); 1318 - if (!ab8500->oldmask) { 1319 - ret = -ENOMEM; 1320 - goto out_freemask; 1321 - } 1351 + ab8500->oldmask = devm_kzalloc(&pdev->dev, ab8500->mask_size, GFP_KERNEL); 1352 + if (!ab8500->oldmask) 1353 + return -ENOMEM; 1354 + 1322 1355 /* 1323 1356 * ab8500 has switched off due to (SWITCH_OFF_STATUS): 1324 1357 * 0x01 Swoff bit programming ··· 1371 1406 1372 1407 ret = abx500_register_ops(ab8500->dev, &ab8500_ops); 1373 1408 if (ret) 1374 - goto out_freeoldmask; 1409 + return ret; 1375 1410 1376 1411 for (i = 0; i < ab8500->mask_size; i++) 1377 1412 ab8500->mask[i] = ab8500->oldmask[i] = 0xff; 1378 1413 1379 1414 ret = ab8500_irq_init(ab8500, np); 1380 1415 if (ret) 1381 - goto out_freeoldmask; 1416 + return ret; 1382 1417 1383 1418 /* Activate this feature only in ab9540 */ 1384 1419 /* till tests are done on ab8500 1p2 or later*/ 1385 1420 if (is_ab9540(ab8500)) { 1386 - ret = request_threaded_irq(ab8500->irq, NULL, 1387 - ab8500_hierarchical_irq, 1388 - IRQF_ONESHOT | IRQF_NO_SUSPEND, 1389 - "ab8500", ab8500); 1421 + ret = devm_request_threaded_irq(&pdev->dev, ab8500->irq, NULL, 1422 + ab8500_hierarchical_irq, 1423 + IRQF_ONESHOT | IRQF_NO_SUSPEND, 1424 + "ab8500", ab8500); 1390 1425 } 1391 1426 else { 1392 - ret = request_threaded_irq(ab8500->irq, NULL, 1393 - ab8500_irq, 1394 - IRQF_ONESHOT | IRQF_NO_SUSPEND, 1395 - "ab8500", ab8500); 1427 + ret = devm_request_threaded_irq(&pdev->dev, ab8500->irq, NULL, 1428 + ab8500_irq, 1429 + IRQF_ONESHOT | IRQF_NO_SUSPEND, 1430 + "ab8500", ab8500); 1396 1431 if (ret) 1397 - goto out_freeoldmask; 1432 + return ret; 1398 1433 } 1399 1434 1400 1435 ret = mfd_add_devices(ab8500->dev, 0, abx500_common_devs, 1401 1436 ARRAY_SIZE(abx500_common_devs), NULL, 1402 1437 ab8500->irq_base, ab8500->domain); 1403 1438 if (ret) 1404 - goto out_freeirq; 1439 + return ret; 1405 1440 1406 1441 if (is_ab9540(ab8500)) 1407 1442 ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs, ··· 1412 1447 ARRAY_SIZE(ab8500_devs), NULL, 1413 1448 ab8500->irq_base, ab8500->domain); 1414 1449 if (ret) 1415 - goto out_freeirq; 1450 + return ret; 1416 1451 1417 1452 if (is_ab9540(ab8500) || is_ab8505(ab8500)) 1418 1453 ret = mfd_add_devices(ab8500->dev, 0, ab9540_ab8505_devs, 1419 1454 ARRAY_SIZE(ab9540_ab8505_devs), NULL, 1420 1455 ab8500->irq_base, ab8500->domain); 1421 1456 if (ret) 1422 - goto out_freeirq; 1457 + return ret; 1423 1458 1424 1459 if (!no_bm) { 1425 1460 /* Add battery management devices */ ··· 1440 1475 dev_err(ab8500->dev, "error creating sysfs entries\n"); 1441 1476 1442 1477 return ret; 1443 - 1444 - out_freeirq: 1445 - free_irq(ab8500->irq, ab8500); 1446 - out_freeoldmask: 1447 - kfree(ab8500->oldmask); 1448 - out_freemask: 1449 - kfree(ab8500->mask); 1450 - out_free_ab8500: 1451 - kfree(ab8500); 1452 - 1453 - return ret; 1454 1478 } 1455 1479 1456 1480 static int ab8500_remove(struct platform_device *pdev) ··· 1452 1498 sysfs_remove_group(&ab8500->dev->kobj, &ab8500_attr_group); 1453 1499 1454 1500 mfd_remove_devices(ab8500->dev); 1455 - free_irq(ab8500->irq, ab8500); 1456 - 1457 - kfree(ab8500->oldmask); 1458 - kfree(ab8500->mask); 1459 - kfree(ab8500); 1460 1501 1461 1502 return 0; 1462 1503 }
+12 -5
drivers/mfd/arizona-core.c
··· 292 292 struct device *dev = arizona->dev; 293 293 const char *type_name; 294 294 unsigned int reg, val; 295 + int (*apply_patch)(struct arizona *) = NULL; 295 296 int ret, i; 296 297 297 298 dev_set_drvdata(arizona->dev, arizona); ··· 392 391 arizona->type); 393 392 arizona->type = WM5102; 394 393 } 395 - ret = wm5102_patch(arizona); 394 + apply_patch = wm5102_patch; 396 395 break; 397 396 #endif 398 397 #ifdef CONFIG_MFD_WM5110 ··· 403 402 arizona->type); 404 403 arizona->type = WM5110; 405 404 } 406 - ret = wm5110_patch(arizona); 405 + apply_patch = wm5110_patch; 407 406 break; 408 407 #endif 409 408 default: ··· 412 411 } 413 412 414 413 dev_info(dev, "%s revision %c\n", type_name, arizona->rev + 'A'); 415 - 416 - if (ret != 0) 417 - dev_err(arizona->dev, "Failed to apply patch: %d\n", ret); 418 414 419 415 /* If we have a /RESET GPIO we'll already be reset */ 420 416 if (!arizona->pdata.reset) { ··· 434 436 if (ret != 0) { 435 437 dev_err(arizona->dev, "Device failed initial boot: %d\n", ret); 436 438 goto err_reset; 439 + } 440 + 441 + if (apply_patch) { 442 + ret = apply_patch(arizona); 443 + if (ret != 0) { 444 + dev_err(arizona->dev, "Failed to apply patch: %d\n", 445 + ret); 446 + goto err_reset; 447 + } 437 448 } 438 449 439 450 for (i = 0; i < ARRAY_SIZE(arizona->pdata.gpio_defaults); i++) {
+1
drivers/mfd/arizona-irq.c
··· 224 224 arizona->virq = irq_domain_add_linear(NULL, 2, &arizona_domain_ops, 225 225 arizona); 226 226 if (!arizona->virq) { 227 + dev_err(arizona->dev, "Failed to add core IRQ domain\n"); 227 228 ret = -EINVAL; 228 229 goto err; 229 230 }
+217
drivers/mfd/as3711.c
··· 1 + /* 2 + * AS3711 PMIC MFC driver 3 + * 4 + * Copyright (C) 2012 Renesas Electronics Corporation 5 + * Author: Guennadi Liakhovetski, <g.liakhovetski@gmx.de> 6 + * 7 + * This program is free software; you can redistribute it and/or modify 8 + * it under the terms of the version 2 of the GNU General Public License as 9 + * published by the Free Software Foundation 10 + */ 11 + 12 + #include <linux/device.h> 13 + #include <linux/err.h> 14 + #include <linux/i2c.h> 15 + #include <linux/init.h> 16 + #include <linux/kernel.h> 17 + #include <linux/mfd/as3711.h> 18 + #include <linux/mfd/core.h> 19 + #include <linux/module.h> 20 + #include <linux/regmap.h> 21 + #include <linux/slab.h> 22 + 23 + enum { 24 + AS3711_REGULATOR, 25 + AS3711_BACKLIGHT, 26 + }; 27 + 28 + /* 29 + * Ok to have it static: it is only used during probing and multiple I2C devices 30 + * cannot be probed simultaneously. Just make sure to avoid stale data. 31 + */ 32 + static struct mfd_cell as3711_subdevs[] = { 33 + [AS3711_REGULATOR] = {.name = "as3711-regulator",}, 34 + [AS3711_BACKLIGHT] = {.name = "as3711-backlight",}, 35 + }; 36 + 37 + static bool as3711_volatile_reg(struct device *dev, unsigned int reg) 38 + { 39 + switch (reg) { 40 + case AS3711_GPIO_SIGNAL_IN: 41 + case AS3711_INTERRUPT_STATUS_1: 42 + case AS3711_INTERRUPT_STATUS_2: 43 + case AS3711_INTERRUPT_STATUS_3: 44 + case AS3711_CHARGER_STATUS_1: 45 + case AS3711_CHARGER_STATUS_2: 46 + case AS3711_REG_STATUS: 47 + return true; 48 + } 49 + return false; 50 + } 51 + 52 + static bool as3711_precious_reg(struct device *dev, unsigned int reg) 53 + { 54 + switch (reg) { 55 + case AS3711_INTERRUPT_STATUS_1: 56 + case AS3711_INTERRUPT_STATUS_2: 57 + case AS3711_INTERRUPT_STATUS_3: 58 + return true; 59 + } 60 + return false; 61 + } 62 + 63 + static bool as3711_readable_reg(struct device *dev, unsigned int reg) 64 + { 65 + switch (reg) { 66 + case AS3711_SD_1_VOLTAGE: 67 + case AS3711_SD_2_VOLTAGE: 68 + case AS3711_SD_3_VOLTAGE: 69 + case AS3711_SD_4_VOLTAGE: 70 + case AS3711_LDO_1_VOLTAGE: 71 + case AS3711_LDO_2_VOLTAGE: 72 + case AS3711_LDO_3_VOLTAGE: 73 + case AS3711_LDO_4_VOLTAGE: 74 + case AS3711_LDO_5_VOLTAGE: 75 + case AS3711_LDO_6_VOLTAGE: 76 + case AS3711_LDO_7_VOLTAGE: 77 + case AS3711_LDO_8_VOLTAGE: 78 + case AS3711_SD_CONTROL: 79 + case AS3711_GPIO_SIGNAL_OUT: 80 + case AS3711_GPIO_SIGNAL_IN: 81 + case AS3711_SD_CONTROL_1: 82 + case AS3711_SD_CONTROL_2: 83 + case AS3711_CURR_CONTROL: 84 + case AS3711_CURR1_VALUE: 85 + case AS3711_CURR2_VALUE: 86 + case AS3711_CURR3_VALUE: 87 + case AS3711_STEPUP_CONTROL_1: 88 + case AS3711_STEPUP_CONTROL_2: 89 + case AS3711_STEPUP_CONTROL_4: 90 + case AS3711_STEPUP_CONTROL_5: 91 + case AS3711_REG_STATUS: 92 + case AS3711_INTERRUPT_STATUS_1: 93 + case AS3711_INTERRUPT_STATUS_2: 94 + case AS3711_INTERRUPT_STATUS_3: 95 + case AS3711_CHARGER_STATUS_1: 96 + case AS3711_CHARGER_STATUS_2: 97 + case AS3711_ASIC_ID_1: 98 + case AS3711_ASIC_ID_2: 99 + return true; 100 + } 101 + return false; 102 + } 103 + 104 + static const struct regmap_config as3711_regmap_config = { 105 + .reg_bits = 8, 106 + .val_bits = 8, 107 + .volatile_reg = as3711_volatile_reg, 108 + .readable_reg = as3711_readable_reg, 109 + .precious_reg = as3711_precious_reg, 110 + .max_register = AS3711_MAX_REGS, 111 + .num_reg_defaults_raw = AS3711_MAX_REGS, 112 + .cache_type = REGCACHE_RBTREE, 113 + }; 114 + 115 + static int as3711_i2c_probe(struct i2c_client *client, 116 + const struct i2c_device_id *id) 117 + { 118 + struct as3711 *as3711; 119 + struct as3711_platform_data *pdata = client->dev.platform_data; 120 + unsigned int id1, id2; 121 + int ret; 122 + 123 + if (!pdata) 124 + dev_dbg(&client->dev, "Platform data not found\n"); 125 + 126 + as3711 = devm_kzalloc(&client->dev, sizeof(struct as3711), GFP_KERNEL); 127 + if (!as3711) { 128 + dev_err(&client->dev, "Memory allocation failed\n"); 129 + return -ENOMEM; 130 + } 131 + 132 + as3711->dev = &client->dev; 133 + i2c_set_clientdata(client, as3711); 134 + 135 + if (client->irq) 136 + dev_notice(&client->dev, "IRQ not supported yet\n"); 137 + 138 + as3711->regmap = devm_regmap_init_i2c(client, &as3711_regmap_config); 139 + if (IS_ERR(as3711->regmap)) { 140 + ret = PTR_ERR(as3711->regmap); 141 + dev_err(&client->dev, "regmap initialization failed: %d\n", ret); 142 + return ret; 143 + } 144 + 145 + ret = regmap_read(as3711->regmap, AS3711_ASIC_ID_1, &id1); 146 + if (!ret) 147 + ret = regmap_read(as3711->regmap, AS3711_ASIC_ID_2, &id2); 148 + if (ret < 0) { 149 + dev_err(&client->dev, "regmap_read() failed: %d\n", ret); 150 + return ret; 151 + } 152 + if (id1 != 0x8b) 153 + return -ENODEV; 154 + dev_info(as3711->dev, "AS3711 detected: %x:%x\n", id1, id2); 155 + 156 + /* We can reuse as3711_subdevs[], it will be copied in mfd_add_devices() */ 157 + if (pdata) { 158 + as3711_subdevs[AS3711_REGULATOR].platform_data = &pdata->regulator; 159 + as3711_subdevs[AS3711_REGULATOR].pdata_size = sizeof(pdata->regulator); 160 + as3711_subdevs[AS3711_BACKLIGHT].platform_data = &pdata->backlight; 161 + as3711_subdevs[AS3711_BACKLIGHT].pdata_size = sizeof(pdata->backlight); 162 + } else { 163 + as3711_subdevs[AS3711_REGULATOR].platform_data = NULL; 164 + as3711_subdevs[AS3711_REGULATOR].pdata_size = 0; 165 + as3711_subdevs[AS3711_BACKLIGHT].platform_data = NULL; 166 + as3711_subdevs[AS3711_BACKLIGHT].pdata_size = 0; 167 + } 168 + 169 + ret = mfd_add_devices(as3711->dev, -1, as3711_subdevs, 170 + ARRAY_SIZE(as3711_subdevs), NULL, 0, NULL); 171 + if (ret < 0) 172 + dev_err(&client->dev, "add mfd devices failed: %d\n", ret); 173 + 174 + return ret; 175 + } 176 + 177 + static int as3711_i2c_remove(struct i2c_client *client) 178 + { 179 + struct as3711 *as3711 = i2c_get_clientdata(client); 180 + 181 + mfd_remove_devices(as3711->dev); 182 + return 0; 183 + } 184 + 185 + static const struct i2c_device_id as3711_i2c_id[] = { 186 + {.name = "as3711", .driver_data = 0}, 187 + {} 188 + }; 189 + 190 + MODULE_DEVICE_TABLE(i2c, as3711_i2c_id); 191 + 192 + static struct i2c_driver as3711_i2c_driver = { 193 + .driver = { 194 + .name = "as3711", 195 + .owner = THIS_MODULE, 196 + }, 197 + .probe = as3711_i2c_probe, 198 + .remove = as3711_i2c_remove, 199 + .id_table = as3711_i2c_id, 200 + }; 201 + 202 + static int __init as3711_i2c_init(void) 203 + { 204 + return i2c_add_driver(&as3711_i2c_driver); 205 + } 206 + /* Initialise early */ 207 + subsys_initcall(as3711_i2c_init); 208 + 209 + static void __exit as3711_i2c_exit(void) 210 + { 211 + i2c_del_driver(&as3711_i2c_driver); 212 + } 213 + module_exit(as3711_i2c_exit); 214 + 215 + MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>"); 216 + MODULE_DESCRIPTION("AS3711 PMIC driver"); 217 + MODULE_LICENSE("GPL v2");
+11 -262
drivers/mfd/da9052-core.c
··· 15 15 #include <linux/delay.h> 16 16 #include <linux/input.h> 17 17 #include <linux/interrupt.h> 18 - #include <linux/irq.h> 19 18 #include <linux/mfd/core.h> 20 19 #include <linux/slab.h> 21 20 #include <linux/module.h> ··· 22 23 #include <linux/mfd/da9052/da9052.h> 23 24 #include <linux/mfd/da9052/pdata.h> 24 25 #include <linux/mfd/da9052/reg.h> 25 - 26 - #define DA9052_NUM_IRQ_REGS 4 27 - #define DA9052_IRQ_MASK_POS_1 0x01 28 - #define DA9052_IRQ_MASK_POS_2 0x02 29 - #define DA9052_IRQ_MASK_POS_3 0x04 30 - #define DA9052_IRQ_MASK_POS_4 0x08 31 - #define DA9052_IRQ_MASK_POS_5 0x10 32 - #define DA9052_IRQ_MASK_POS_6 0x20 33 - #define DA9052_IRQ_MASK_POS_7 0x40 34 - #define DA9052_IRQ_MASK_POS_8 0x80 35 26 36 27 static bool da9052_reg_readable(struct device *dev, unsigned int reg) 37 28 { ··· 414 425 } 415 426 EXPORT_SYMBOL_GPL(da9052_adc_manual_read); 416 427 417 - static irqreturn_t da9052_auxadc_irq(int irq, void *irq_data) 418 - { 419 - struct da9052 *da9052 = irq_data; 420 - 421 - complete(&da9052->done); 422 - 423 - return IRQ_HANDLED; 424 - } 425 - 426 428 int da9052_adc_read_temp(struct da9052 *da9052) 427 429 { 428 430 int tbat; ··· 426 446 return tbat_lookup[tbat - 1]; 427 447 } 428 448 EXPORT_SYMBOL_GPL(da9052_adc_read_temp); 429 - 430 - static struct resource da9052_rtc_resource = { 431 - .name = "ALM", 432 - .start = DA9052_IRQ_ALARM, 433 - .end = DA9052_IRQ_ALARM, 434 - .flags = IORESOURCE_IRQ, 435 - }; 436 - 437 - static struct resource da9052_onkey_resource = { 438 - .name = "ONKEY", 439 - .start = DA9052_IRQ_NONKEY, 440 - .end = DA9052_IRQ_NONKEY, 441 - .flags = IORESOURCE_IRQ, 442 - }; 443 - 444 - static struct resource da9052_bat_resources[] = { 445 - { 446 - .name = "BATT TEMP", 447 - .start = DA9052_IRQ_TBAT, 448 - .end = DA9052_IRQ_TBAT, 449 - .flags = IORESOURCE_IRQ, 450 - }, 451 - { 452 - .name = "DCIN DET", 453 - .start = DA9052_IRQ_DCIN, 454 - .end = DA9052_IRQ_DCIN, 455 - .flags = IORESOURCE_IRQ, 456 - }, 457 - { 458 - .name = "DCIN REM", 459 - .start = DA9052_IRQ_DCINREM, 460 - .end = DA9052_IRQ_DCINREM, 461 - .flags = IORESOURCE_IRQ, 462 - }, 463 - { 464 - .name = "VBUS DET", 465 - .start = DA9052_IRQ_VBUS, 466 - .end = DA9052_IRQ_VBUS, 467 - .flags = IORESOURCE_IRQ, 468 - }, 469 - { 470 - .name = "VBUS REM", 471 - .start = DA9052_IRQ_VBUSREM, 472 - .end = DA9052_IRQ_VBUSREM, 473 - .flags = IORESOURCE_IRQ, 474 - }, 475 - { 476 - .name = "CHG END", 477 - .start = DA9052_IRQ_CHGEND, 478 - .end = DA9052_IRQ_CHGEND, 479 - .flags = IORESOURCE_IRQ, 480 - }, 481 - }; 482 - 483 - static struct resource da9052_tsi_resources[] = { 484 - { 485 - .name = "PENDWN", 486 - .start = DA9052_IRQ_PENDOWN, 487 - .end = DA9052_IRQ_PENDOWN, 488 - .flags = IORESOURCE_IRQ, 489 - }, 490 - { 491 - .name = "TSIRDY", 492 - .start = DA9052_IRQ_TSIREADY, 493 - .end = DA9052_IRQ_TSIREADY, 494 - .flags = IORESOURCE_IRQ, 495 - }, 496 - }; 497 449 498 450 static struct mfd_cell da9052_subdev_info[] = { 499 451 { ··· 486 574 }, 487 575 { 488 576 .name = "da9052-onkey", 489 - .resources = &da9052_onkey_resource, 490 - .num_resources = 1, 491 577 }, 492 578 { 493 579 .name = "da9052-rtc", 494 - .resources = &da9052_rtc_resource, 495 - .num_resources = 1, 496 580 }, 497 581 { 498 582 .name = "da9052-gpio", ··· 510 602 }, 511 603 { 512 604 .name = "da9052-tsi", 513 - .resources = da9052_tsi_resources, 514 - .num_resources = ARRAY_SIZE(da9052_tsi_resources), 515 605 }, 516 606 { 517 607 .name = "da9052-bat", 518 - .resources = da9052_bat_resources, 519 - .num_resources = ARRAY_SIZE(da9052_bat_resources), 520 608 }, 521 609 { 522 610 .name = "da9052-watchdog", 523 611 }, 524 - }; 525 - 526 - static struct regmap_irq da9052_irqs[] = { 527 - [DA9052_IRQ_DCIN] = { 528 - .reg_offset = 0, 529 - .mask = DA9052_IRQ_MASK_POS_1, 530 - }, 531 - [DA9052_IRQ_VBUS] = { 532 - .reg_offset = 0, 533 - .mask = DA9052_IRQ_MASK_POS_2, 534 - }, 535 - [DA9052_IRQ_DCINREM] = { 536 - .reg_offset = 0, 537 - .mask = DA9052_IRQ_MASK_POS_3, 538 - }, 539 - [DA9052_IRQ_VBUSREM] = { 540 - .reg_offset = 0, 541 - .mask = DA9052_IRQ_MASK_POS_4, 542 - }, 543 - [DA9052_IRQ_VDDLOW] = { 544 - .reg_offset = 0, 545 - .mask = DA9052_IRQ_MASK_POS_5, 546 - }, 547 - [DA9052_IRQ_ALARM] = { 548 - .reg_offset = 0, 549 - .mask = DA9052_IRQ_MASK_POS_6, 550 - }, 551 - [DA9052_IRQ_SEQRDY] = { 552 - .reg_offset = 0, 553 - .mask = DA9052_IRQ_MASK_POS_7, 554 - }, 555 - [DA9052_IRQ_COMP1V2] = { 556 - .reg_offset = 0, 557 - .mask = DA9052_IRQ_MASK_POS_8, 558 - }, 559 - [DA9052_IRQ_NONKEY] = { 560 - .reg_offset = 1, 561 - .mask = DA9052_IRQ_MASK_POS_1, 562 - }, 563 - [DA9052_IRQ_IDFLOAT] = { 564 - .reg_offset = 1, 565 - .mask = DA9052_IRQ_MASK_POS_2, 566 - }, 567 - [DA9052_IRQ_IDGND] = { 568 - .reg_offset = 1, 569 - .mask = DA9052_IRQ_MASK_POS_3, 570 - }, 571 - [DA9052_IRQ_CHGEND] = { 572 - .reg_offset = 1, 573 - .mask = DA9052_IRQ_MASK_POS_4, 574 - }, 575 - [DA9052_IRQ_TBAT] = { 576 - .reg_offset = 1, 577 - .mask = DA9052_IRQ_MASK_POS_5, 578 - }, 579 - [DA9052_IRQ_ADC_EOM] = { 580 - .reg_offset = 1, 581 - .mask = DA9052_IRQ_MASK_POS_6, 582 - }, 583 - [DA9052_IRQ_PENDOWN] = { 584 - .reg_offset = 1, 585 - .mask = DA9052_IRQ_MASK_POS_7, 586 - }, 587 - [DA9052_IRQ_TSIREADY] = { 588 - .reg_offset = 1, 589 - .mask = DA9052_IRQ_MASK_POS_8, 590 - }, 591 - [DA9052_IRQ_GPI0] = { 592 - .reg_offset = 2, 593 - .mask = DA9052_IRQ_MASK_POS_1, 594 - }, 595 - [DA9052_IRQ_GPI1] = { 596 - .reg_offset = 2, 597 - .mask = DA9052_IRQ_MASK_POS_2, 598 - }, 599 - [DA9052_IRQ_GPI2] = { 600 - .reg_offset = 2, 601 - .mask = DA9052_IRQ_MASK_POS_3, 602 - }, 603 - [DA9052_IRQ_GPI3] = { 604 - .reg_offset = 2, 605 - .mask = DA9052_IRQ_MASK_POS_4, 606 - }, 607 - [DA9052_IRQ_GPI4] = { 608 - .reg_offset = 2, 609 - .mask = DA9052_IRQ_MASK_POS_5, 610 - }, 611 - [DA9052_IRQ_GPI5] = { 612 - .reg_offset = 2, 613 - .mask = DA9052_IRQ_MASK_POS_6, 614 - }, 615 - [DA9052_IRQ_GPI6] = { 616 - .reg_offset = 2, 617 - .mask = DA9052_IRQ_MASK_POS_7, 618 - }, 619 - [DA9052_IRQ_GPI7] = { 620 - .reg_offset = 2, 621 - .mask = DA9052_IRQ_MASK_POS_8, 622 - }, 623 - [DA9052_IRQ_GPI8] = { 624 - .reg_offset = 3, 625 - .mask = DA9052_IRQ_MASK_POS_1, 626 - }, 627 - [DA9052_IRQ_GPI9] = { 628 - .reg_offset = 3, 629 - .mask = DA9052_IRQ_MASK_POS_2, 630 - }, 631 - [DA9052_IRQ_GPI10] = { 632 - .reg_offset = 3, 633 - .mask = DA9052_IRQ_MASK_POS_3, 634 - }, 635 - [DA9052_IRQ_GPI11] = { 636 - .reg_offset = 3, 637 - .mask = DA9052_IRQ_MASK_POS_4, 638 - }, 639 - [DA9052_IRQ_GPI12] = { 640 - .reg_offset = 3, 641 - .mask = DA9052_IRQ_MASK_POS_5, 642 - }, 643 - [DA9052_IRQ_GPI13] = { 644 - .reg_offset = 3, 645 - .mask = DA9052_IRQ_MASK_POS_6, 646 - }, 647 - [DA9052_IRQ_GPI14] = { 648 - .reg_offset = 3, 649 - .mask = DA9052_IRQ_MASK_POS_7, 650 - }, 651 - [DA9052_IRQ_GPI15] = { 652 - .reg_offset = 3, 653 - .mask = DA9052_IRQ_MASK_POS_8, 654 - }, 655 - }; 656 - 657 - static struct regmap_irq_chip da9052_regmap_irq_chip = { 658 - .name = "da9052_irq", 659 - .status_base = DA9052_EVENT_A_REG, 660 - .mask_base = DA9052_IRQ_MASK_A_REG, 661 - .ack_base = DA9052_EVENT_A_REG, 662 - .num_regs = DA9052_NUM_IRQ_REGS, 663 - .irqs = da9052_irqs, 664 - .num_irqs = ARRAY_SIZE(da9052_irqs), 665 612 }; 666 613 667 614 struct regmap_config da9052_regmap_config = { ··· 545 782 546 783 da9052->chip_id = chip_id; 547 784 548 - if (!pdata || !pdata->irq_base) 549 - da9052->irq_base = -1; 550 - else 551 - da9052->irq_base = pdata->irq_base; 552 - 553 - ret = regmap_add_irq_chip(da9052->regmap, da9052->chip_irq, 554 - IRQF_TRIGGER_LOW | IRQF_ONESHOT, 555 - da9052->irq_base, &da9052_regmap_irq_chip, 556 - &da9052->irq_data); 557 - if (ret < 0) 558 - goto regmap_err; 559 - 560 - da9052->irq_base = regmap_irq_chip_get_base(da9052->irq_data); 561 - 562 - ret = request_threaded_irq(DA9052_IRQ_ADC_EOM, NULL, da9052_auxadc_irq, 563 - IRQF_TRIGGER_LOW | IRQF_ONESHOT, 564 - "adc irq", da9052); 565 - if (ret != 0) 566 - dev_err(da9052->dev, "DA9052 ADC IRQ failed ret=%d\n", ret); 785 + ret = da9052_irq_init(da9052); 786 + if (ret != 0) { 787 + dev_err(da9052->dev, "da9052_irq_init failed: %d\n", ret); 788 + return ret; 789 + } 567 790 568 791 ret = mfd_add_devices(da9052->dev, -1, da9052_subdev_info, 569 792 ARRAY_SIZE(da9052_subdev_info), NULL, 0, NULL); 570 - if (ret) 793 + if (ret) { 794 + dev_err(da9052->dev, "mfd_add_devices failed: %d\n", ret); 571 795 goto err; 796 + } 572 797 573 798 return 0; 574 799 575 800 err: 576 - free_irq(DA9052_IRQ_ADC_EOM, da9052); 577 - mfd_remove_devices(da9052->dev); 578 - regmap_err: 801 + da9052_irq_exit(da9052); 802 + 579 803 return ret; 580 804 } 581 805 582 806 void da9052_device_exit(struct da9052 *da9052) 583 807 { 584 - free_irq(DA9052_IRQ_ADC_EOM, da9052); 585 - regmap_del_irq_chip(da9052->chip_irq, da9052->irq_data); 586 808 mfd_remove_devices(da9052->dev); 809 + da9052_irq_exit(da9052); 587 810 } 588 811 589 812 MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>");
+288
drivers/mfd/da9052-irq.c
··· 1 + /* 2 + * DA9052 interrupt support 3 + * 4 + * Author: Fabio Estevam <fabio.estevam@freescale.com> 5 + * Based on arizona-irq.c, which is: 6 + * 7 + * Copyright 2012 Wolfson Microelectronics plc 8 + * 9 + * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 10 + * 11 + * This program is free software; you can redistribute it and/or modify 12 + * it under the terms of the GNU General Public License version 2 as 13 + * published by the Free Software Foundation. 14 + */ 15 + 16 + #include <linux/device.h> 17 + #include <linux/delay.h> 18 + #include <linux/input.h> 19 + #include <linux/interrupt.h> 20 + #include <linux/irq.h> 21 + #include <linux/irqdomain.h> 22 + #include <linux/slab.h> 23 + #include <linux/module.h> 24 + 25 + #include <linux/mfd/da9052/da9052.h> 26 + #include <linux/mfd/da9052/reg.h> 27 + 28 + #define DA9052_NUM_IRQ_REGS 4 29 + #define DA9052_IRQ_MASK_POS_1 0x01 30 + #define DA9052_IRQ_MASK_POS_2 0x02 31 + #define DA9052_IRQ_MASK_POS_3 0x04 32 + #define DA9052_IRQ_MASK_POS_4 0x08 33 + #define DA9052_IRQ_MASK_POS_5 0x10 34 + #define DA9052_IRQ_MASK_POS_6 0x20 35 + #define DA9052_IRQ_MASK_POS_7 0x40 36 + #define DA9052_IRQ_MASK_POS_8 0x80 37 + 38 + static struct regmap_irq da9052_irqs[] = { 39 + [DA9052_IRQ_DCIN] = { 40 + .reg_offset = 0, 41 + .mask = DA9052_IRQ_MASK_POS_1, 42 + }, 43 + [DA9052_IRQ_VBUS] = { 44 + .reg_offset = 0, 45 + .mask = DA9052_IRQ_MASK_POS_2, 46 + }, 47 + [DA9052_IRQ_DCINREM] = { 48 + .reg_offset = 0, 49 + .mask = DA9052_IRQ_MASK_POS_3, 50 + }, 51 + [DA9052_IRQ_VBUSREM] = { 52 + .reg_offset = 0, 53 + .mask = DA9052_IRQ_MASK_POS_4, 54 + }, 55 + [DA9052_IRQ_VDDLOW] = { 56 + .reg_offset = 0, 57 + .mask = DA9052_IRQ_MASK_POS_5, 58 + }, 59 + [DA9052_IRQ_ALARM] = { 60 + .reg_offset = 0, 61 + .mask = DA9052_IRQ_MASK_POS_6, 62 + }, 63 + [DA9052_IRQ_SEQRDY] = { 64 + .reg_offset = 0, 65 + .mask = DA9052_IRQ_MASK_POS_7, 66 + }, 67 + [DA9052_IRQ_COMP1V2] = { 68 + .reg_offset = 0, 69 + .mask = DA9052_IRQ_MASK_POS_8, 70 + }, 71 + [DA9052_IRQ_NONKEY] = { 72 + .reg_offset = 1, 73 + .mask = DA9052_IRQ_MASK_POS_1, 74 + }, 75 + [DA9052_IRQ_IDFLOAT] = { 76 + .reg_offset = 1, 77 + .mask = DA9052_IRQ_MASK_POS_2, 78 + }, 79 + [DA9052_IRQ_IDGND] = { 80 + .reg_offset = 1, 81 + .mask = DA9052_IRQ_MASK_POS_3, 82 + }, 83 + [DA9052_IRQ_CHGEND] = { 84 + .reg_offset = 1, 85 + .mask = DA9052_IRQ_MASK_POS_4, 86 + }, 87 + [DA9052_IRQ_TBAT] = { 88 + .reg_offset = 1, 89 + .mask = DA9052_IRQ_MASK_POS_5, 90 + }, 91 + [DA9052_IRQ_ADC_EOM] = { 92 + .reg_offset = 1, 93 + .mask = DA9052_IRQ_MASK_POS_6, 94 + }, 95 + [DA9052_IRQ_PENDOWN] = { 96 + .reg_offset = 1, 97 + .mask = DA9052_IRQ_MASK_POS_7, 98 + }, 99 + [DA9052_IRQ_TSIREADY] = { 100 + .reg_offset = 1, 101 + .mask = DA9052_IRQ_MASK_POS_8, 102 + }, 103 + [DA9052_IRQ_GPI0] = { 104 + .reg_offset = 2, 105 + .mask = DA9052_IRQ_MASK_POS_1, 106 + }, 107 + [DA9052_IRQ_GPI1] = { 108 + .reg_offset = 2, 109 + .mask = DA9052_IRQ_MASK_POS_2, 110 + }, 111 + [DA9052_IRQ_GPI2] = { 112 + .reg_offset = 2, 113 + .mask = DA9052_IRQ_MASK_POS_3, 114 + }, 115 + [DA9052_IRQ_GPI3] = { 116 + .reg_offset = 2, 117 + .mask = DA9052_IRQ_MASK_POS_4, 118 + }, 119 + [DA9052_IRQ_GPI4] = { 120 + .reg_offset = 2, 121 + .mask = DA9052_IRQ_MASK_POS_5, 122 + }, 123 + [DA9052_IRQ_GPI5] = { 124 + .reg_offset = 2, 125 + .mask = DA9052_IRQ_MASK_POS_6, 126 + }, 127 + [DA9052_IRQ_GPI6] = { 128 + .reg_offset = 2, 129 + .mask = DA9052_IRQ_MASK_POS_7, 130 + }, 131 + [DA9052_IRQ_GPI7] = { 132 + .reg_offset = 2, 133 + .mask = DA9052_IRQ_MASK_POS_8, 134 + }, 135 + [DA9052_IRQ_GPI8] = { 136 + .reg_offset = 3, 137 + .mask = DA9052_IRQ_MASK_POS_1, 138 + }, 139 + [DA9052_IRQ_GPI9] = { 140 + .reg_offset = 3, 141 + .mask = DA9052_IRQ_MASK_POS_2, 142 + }, 143 + [DA9052_IRQ_GPI10] = { 144 + .reg_offset = 3, 145 + .mask = DA9052_IRQ_MASK_POS_3, 146 + }, 147 + [DA9052_IRQ_GPI11] = { 148 + .reg_offset = 3, 149 + .mask = DA9052_IRQ_MASK_POS_4, 150 + }, 151 + [DA9052_IRQ_GPI12] = { 152 + .reg_offset = 3, 153 + .mask = DA9052_IRQ_MASK_POS_5, 154 + }, 155 + [DA9052_IRQ_GPI13] = { 156 + .reg_offset = 3, 157 + .mask = DA9052_IRQ_MASK_POS_6, 158 + }, 159 + [DA9052_IRQ_GPI14] = { 160 + .reg_offset = 3, 161 + .mask = DA9052_IRQ_MASK_POS_7, 162 + }, 163 + [DA9052_IRQ_GPI15] = { 164 + .reg_offset = 3, 165 + .mask = DA9052_IRQ_MASK_POS_8, 166 + }, 167 + }; 168 + 169 + static struct regmap_irq_chip da9052_regmap_irq_chip = { 170 + .name = "da9052_irq", 171 + .status_base = DA9052_EVENT_A_REG, 172 + .mask_base = DA9052_IRQ_MASK_A_REG, 173 + .ack_base = DA9052_EVENT_A_REG, 174 + .num_regs = DA9052_NUM_IRQ_REGS, 175 + .irqs = da9052_irqs, 176 + .num_irqs = ARRAY_SIZE(da9052_irqs), 177 + }; 178 + 179 + static int da9052_map_irq(struct da9052 *da9052, int irq) 180 + { 181 + return regmap_irq_get_virq(da9052->irq_data, irq); 182 + } 183 + 184 + int da9052_enable_irq(struct da9052 *da9052, int irq) 185 + { 186 + irq = da9052_map_irq(da9052, irq); 187 + if (irq < 0) 188 + return irq; 189 + 190 + enable_irq(irq); 191 + 192 + return 0; 193 + } 194 + EXPORT_SYMBOL_GPL(da9052_enable_irq); 195 + 196 + int da9052_disable_irq(struct da9052 *da9052, int irq) 197 + { 198 + irq = da9052_map_irq(da9052, irq); 199 + if (irq < 0) 200 + return irq; 201 + 202 + disable_irq(irq); 203 + 204 + return 0; 205 + } 206 + EXPORT_SYMBOL_GPL(da9052_disable_irq); 207 + 208 + int da9052_disable_irq_nosync(struct da9052 *da9052, int irq) 209 + { 210 + irq = da9052_map_irq(da9052, irq); 211 + if (irq < 0) 212 + return irq; 213 + 214 + disable_irq_nosync(irq); 215 + 216 + return 0; 217 + } 218 + EXPORT_SYMBOL_GPL(da9052_disable_irq_nosync); 219 + 220 + int da9052_request_irq(struct da9052 *da9052, int irq, char *name, 221 + irq_handler_t handler, void *data) 222 + { 223 + irq = da9052_map_irq(da9052, irq); 224 + if (irq < 0) 225 + return irq; 226 + 227 + return request_threaded_irq(irq, NULL, handler, 228 + IRQF_TRIGGER_LOW | IRQF_ONESHOT, 229 + name, data); 230 + } 231 + EXPORT_SYMBOL_GPL(da9052_request_irq); 232 + 233 + void da9052_free_irq(struct da9052 *da9052, int irq, void *data) 234 + { 235 + irq = da9052_map_irq(da9052, irq); 236 + if (irq < 0) 237 + return; 238 + 239 + free_irq(irq, data); 240 + } 241 + EXPORT_SYMBOL_GPL(da9052_free_irq); 242 + 243 + static irqreturn_t da9052_auxadc_irq(int irq, void *irq_data) 244 + { 245 + struct da9052 *da9052 = irq_data; 246 + 247 + complete(&da9052->done); 248 + 249 + return IRQ_HANDLED; 250 + } 251 + 252 + int da9052_irq_init(struct da9052 *da9052) 253 + { 254 + int ret; 255 + 256 + ret = regmap_add_irq_chip(da9052->regmap, da9052->chip_irq, 257 + IRQF_TRIGGER_LOW | IRQF_ONESHOT, 258 + -1, &da9052_regmap_irq_chip, 259 + &da9052->irq_data); 260 + if (ret < 0) { 261 + dev_err(da9052->dev, "regmap_add_irq_chip failed: %d\n", ret); 262 + goto regmap_err; 263 + } 264 + 265 + ret = da9052_request_irq(da9052, DA9052_IRQ_ADC_EOM, "adc-irq", 266 + da9052_auxadc_irq, da9052); 267 + 268 + if (ret != 0) { 269 + dev_err(da9052->dev, "DA9052_IRQ_ADC_EOM failed: %d\n", ret); 270 + goto request_irq_err; 271 + } 272 + 273 + return 0; 274 + 275 + request_irq_err: 276 + regmap_del_irq_chip(da9052->chip_irq, da9052->irq_data); 277 + regmap_err: 278 + return ret; 279 + 280 + } 281 + 282 + int da9052_irq_exit(struct da9052 *da9052) 283 + { 284 + da9052_free_irq(da9052, DA9052_IRQ_ADC_EOM , da9052); 285 + regmap_del_irq_chip(da9052->chip_irq, da9052->irq_data); 286 + 287 + return 0; 288 + }
+6 -2
drivers/mfd/db8500-prcmu.c
··· 2763 2763 2764 2764 void __init db8500_prcmu_early_init(void) 2765 2765 { 2766 - if (cpu_is_u8500v2()) { 2766 + if (cpu_is_u8500v2() || cpu_is_u9540()) { 2767 2767 void *tcpm_base = ioremap_nocache(U8500_PRCMU_TCPM_BASE, SZ_4K); 2768 2768 2769 2769 if (tcpm_base != NULL) { ··· 2781 2781 iounmap(tcpm_base); 2782 2782 } 2783 2783 2784 - tcdm_base = __io_address(U8500_PRCMU_TCDM_BASE); 2784 + if (cpu_is_u9540()) 2785 + tcdm_base = ioremap_nocache(U8500_PRCMU_TCDM_BASE, 2786 + SZ_4K + SZ_8K) + SZ_8K; 2787 + else 2788 + tcdm_base = __io_address(U8500_PRCMU_TCDM_BASE); 2785 2789 } else { 2786 2790 pr_err("prcmu: Unsupported chip version\n"); 2787 2791 BUG();
+6 -14
drivers/mfd/jz4740-adc.c
··· 211 211 int ret; 212 212 int irq_base; 213 213 214 - adc = kmalloc(sizeof(*adc), GFP_KERNEL); 214 + adc = devm_kzalloc(&pdev->dev, sizeof(*adc), GFP_KERNEL); 215 215 if (!adc) { 216 216 dev_err(&pdev->dev, "Failed to allocate driver structure\n"); 217 217 return -ENOMEM; ··· 221 221 if (adc->irq < 0) { 222 222 ret = adc->irq; 223 223 dev_err(&pdev->dev, "Failed to get platform irq: %d\n", ret); 224 - goto err_free; 224 + return ret; 225 225 } 226 226 227 227 irq_base = platform_get_irq(pdev, 1); 228 228 if (irq_base < 0) { 229 - ret = irq_base; 230 - dev_err(&pdev->dev, "Failed to get irq base: %d\n", ret); 231 - goto err_free; 229 + dev_err(&pdev->dev, "Failed to get irq base: %d\n", irq_base); 230 + return irq_base; 232 231 } 233 232 234 233 mem_base = platform_get_resource(pdev, IORESOURCE_MEM, 0); 235 234 if (!mem_base) { 236 - ret = -ENOENT; 237 235 dev_err(&pdev->dev, "Failed to get platform mmio resource\n"); 238 - goto err_free; 236 + return -ENOENT; 239 237 } 240 238 241 239 /* Only request the shared registers for the MFD driver */ 242 240 adc->mem = request_mem_region(mem_base->start, JZ_REG_ADC_STATUS, 243 241 pdev->name); 244 242 if (!adc->mem) { 245 - ret = -EBUSY; 246 243 dev_err(&pdev->dev, "Failed to request mmio memory region\n"); 247 - goto err_free; 244 + return -EBUSY; 248 245 } 249 246 250 247 adc->base = ioremap_nocache(adc->mem->start, resource_size(adc->mem)); ··· 298 301 iounmap(adc->base); 299 302 err_release_mem_region: 300 303 release_mem_region(adc->mem->start, resource_size(adc->mem)); 301 - err_free: 302 - kfree(adc); 303 - 304 304 return ret; 305 305 } 306 306 ··· 318 324 clk_put(adc->clk); 319 325 320 326 platform_set_drvdata(pdev, NULL); 321 - 322 - kfree(adc); 323 327 324 328 return 0; 325 329 }
+10 -6
drivers/mfd/lpc_ich.c
··· 734 734 pci_read_config_dword(dev, ACPIBASE, &base_addr_cfg); 735 735 base_addr = base_addr_cfg & 0x0000ff80; 736 736 if (!base_addr) { 737 - dev_err(&dev->dev, "I/O space for ACPI uninitialized\n"); 737 + dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n"); 738 738 lpc_ich_cells[LPC_GPIO].num_resources--; 739 739 goto gpe0_done; 740 740 } ··· 760 760 pci_read_config_dword(dev, GPIOBASE, &base_addr_cfg); 761 761 base_addr = base_addr_cfg & 0x0000ff80; 762 762 if (!base_addr) { 763 - dev_err(&dev->dev, "I/O space for GPIO uninitialized\n"); 763 + dev_notice(&dev->dev, "I/O space for GPIO uninitialized\n"); 764 764 ret = -ENODEV; 765 765 goto gpio_done; 766 766 } ··· 810 810 pci_read_config_dword(dev, ACPIBASE, &base_addr_cfg); 811 811 base_addr = base_addr_cfg & 0x0000ff80; 812 812 if (!base_addr) { 813 - dev_err(&dev->dev, "I/O space for ACPI uninitialized\n"); 813 + dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n"); 814 814 ret = -ENODEV; 815 815 goto wdt_done; 816 816 } ··· 830 830 * we have to read RCBA from PCI Config space 0xf0 and use 831 831 * it as base. GCS = RCBA + ICH6_GCS(0x3410). 832 832 */ 833 - if (lpc_chipset_info[id->driver_data].iTCO_version == 2) { 833 + if (lpc_chipset_info[id->driver_data].iTCO_version == 1) { 834 + /* Don't register iomem for TCO ver 1 */ 835 + lpc_ich_cells[LPC_WDT].num_resources--; 836 + } else { 834 837 pci_read_config_dword(dev, RCBABASE, &base_addr_cfg); 835 838 base_addr = base_addr_cfg & 0xffffc000; 836 839 if (!(base_addr_cfg & 1)) { 837 - pr_err("RCBA is disabled by hardware/BIOS, " 838 - "device disabled\n"); 840 + dev_notice(&dev->dev, "RCBA is disabled by " 841 + "hardware/BIOS, device disabled\n"); 839 842 ret = -ENODEV; 840 843 goto wdt_done; 841 844 } ··· 874 871 * successfully. 875 872 */ 876 873 if (!cell_added) { 874 + dev_warn(&dev->dev, "No MFD cells added\n"); 877 875 lpc_ich_restore_config_space(dev); 878 876 return -ENODEV; 879 877 }
+49 -51
drivers/mfd/mc13xxx-core.c
··· 119 119 #define MC13XXX_REVISION_FAB (0x03 << 11) 120 120 #define MC13XXX_REVISION_ICIDCODE (0x3f << 13) 121 121 122 + #define MC34708_REVISION_REVMETAL (0x07 << 0) 123 + #define MC34708_REVISION_REVFULL (0x07 << 3) 124 + #define MC34708_REVISION_FIN (0x07 << 6) 125 + #define MC34708_REVISION_FAB (0x07 << 9) 126 + 122 127 #define MC13XXX_ADC1 44 123 128 #define MC13XXX_ADC1_ADEN (1 << 0) 124 129 #define MC13XXX_ADC1_RAND (1 << 1) ··· 415 410 return IRQ_RETVAL(handled); 416 411 } 417 412 418 - static const char *mc13xxx_chipname[] = { 419 - [MC13XXX_ID_MC13783] = "mc13783", 420 - [MC13XXX_ID_MC13892] = "mc13892", 421 - }; 422 - 423 413 #define maskval(reg, mask) (((reg) & (mask)) >> __ffs(mask)) 424 - static int mc13xxx_identify(struct mc13xxx *mc13xxx) 414 + static void mc13xxx_print_revision(struct mc13xxx *mc13xxx, u32 revision) 425 415 { 426 - u32 icid; 427 - u32 revision; 428 - int ret; 429 - 430 - /* 431 - * Get the generation ID from register 46, as apparently some older 432 - * IC revisions only have this info at this location. Newer ICs seem to 433 - * have both. 434 - */ 435 - ret = mc13xxx_reg_read(mc13xxx, 46, &icid); 436 - if (ret) 437 - return ret; 438 - 439 - icid = (icid >> 6) & 0x7; 440 - 441 - switch (icid) { 442 - case 2: 443 - mc13xxx->ictype = MC13XXX_ID_MC13783; 444 - break; 445 - case 7: 446 - mc13xxx->ictype = MC13XXX_ID_MC13892; 447 - break; 448 - default: 449 - mc13xxx->ictype = MC13XXX_ID_INVALID; 450 - break; 451 - } 452 - 453 - if (mc13xxx->ictype == MC13XXX_ID_MC13783 || 454 - mc13xxx->ictype == MC13XXX_ID_MC13892) { 455 - ret = mc13xxx_reg_read(mc13xxx, MC13XXX_REVISION, &revision); 456 - 457 - dev_info(mc13xxx->dev, "%s: rev: %d.%d, " 458 - "fin: %d, fab: %d, icid: %d/%d\n", 459 - mc13xxx_chipname[mc13xxx->ictype], 460 - maskval(revision, MC13XXX_REVISION_REVFULL), 461 - maskval(revision, MC13XXX_REVISION_REVMETAL), 462 - maskval(revision, MC13XXX_REVISION_FIN), 463 - maskval(revision, MC13XXX_REVISION_FAB), 464 - maskval(revision, MC13XXX_REVISION_ICID), 465 - maskval(revision, MC13XXX_REVISION_ICIDCODE)); 466 - } 467 - 468 - return (mc13xxx->ictype == MC13XXX_ID_INVALID) ? -ENODEV : 0; 416 + dev_info(mc13xxx->dev, "%s: rev: %d.%d, " 417 + "fin: %d, fab: %d, icid: %d/%d\n", 418 + mc13xxx->variant->name, 419 + maskval(revision, MC13XXX_REVISION_REVFULL), 420 + maskval(revision, MC13XXX_REVISION_REVMETAL), 421 + maskval(revision, MC13XXX_REVISION_FIN), 422 + maskval(revision, MC13XXX_REVISION_FAB), 423 + maskval(revision, MC13XXX_REVISION_ICID), 424 + maskval(revision, MC13XXX_REVISION_ICIDCODE)); 469 425 } 426 + 427 + static void mc34708_print_revision(struct mc13xxx *mc13xxx, u32 revision) 428 + { 429 + dev_info(mc13xxx->dev, "%s: rev %d.%d, fin: %d, fab: %d\n", 430 + mc13xxx->variant->name, 431 + maskval(revision, MC34708_REVISION_REVFULL), 432 + maskval(revision, MC34708_REVISION_REVMETAL), 433 + maskval(revision, MC34708_REVISION_FIN), 434 + maskval(revision, MC34708_REVISION_FAB)); 435 + } 436 + 437 + /* These are only exported for mc13xxx-i2c and mc13xxx-spi */ 438 + struct mc13xxx_variant mc13xxx_variant_mc13783 = { 439 + .name = "mc13783", 440 + .print_revision = mc13xxx_print_revision, 441 + }; 442 + EXPORT_SYMBOL_GPL(mc13xxx_variant_mc13783); 443 + 444 + struct mc13xxx_variant mc13xxx_variant_mc13892 = { 445 + .name = "mc13892", 446 + .print_revision = mc13xxx_print_revision, 447 + }; 448 + EXPORT_SYMBOL_GPL(mc13xxx_variant_mc13892); 449 + 450 + struct mc13xxx_variant mc13xxx_variant_mc34708 = { 451 + .name = "mc34708", 452 + .print_revision = mc34708_print_revision, 453 + }; 454 + EXPORT_SYMBOL_GPL(mc13xxx_variant_mc34708); 470 455 471 456 static const char *mc13xxx_get_chipname(struct mc13xxx *mc13xxx) 472 457 { 473 - return mc13xxx_chipname[mc13xxx->ictype]; 458 + return mc13xxx->variant->name; 474 459 } 475 460 476 461 int mc13xxx_get_flags(struct mc13xxx *mc13xxx) ··· 648 653 struct mc13xxx_platform_data *pdata, int irq) 649 654 { 650 655 int ret; 656 + u32 revision; 651 657 652 658 mc13xxx_lock(mc13xxx); 653 659 654 - ret = mc13xxx_identify(mc13xxx); 660 + ret = mc13xxx_reg_read(mc13xxx, MC13XXX_REVISION, &revision); 655 661 if (ret) 656 662 goto err_revision; 663 + 664 + mc13xxx->variant->print_revision(mc13xxx, revision); 657 665 658 666 /* mask all irqs */ 659 667 ret = mc13xxx_reg_write(mc13xxx, MC13XXX_IRQMASK0, 0x00ffffff);
+16 -6
drivers/mfd/mc13xxx-i2c.c
··· 24 24 static const struct i2c_device_id mc13xxx_i2c_device_id[] = { 25 25 { 26 26 .name = "mc13892", 27 - .driver_data = MC13XXX_ID_MC13892, 27 + .driver_data = (kernel_ulong_t)&mc13xxx_variant_mc13892, 28 + }, { 29 + .name = "mc34708", 30 + .driver_data = (kernel_ulong_t)&mc13xxx_variant_mc34708, 28 31 }, { 29 32 /* sentinel */ 30 33 } ··· 37 34 static const struct of_device_id mc13xxx_dt_ids[] = { 38 35 { 39 36 .compatible = "fsl,mc13892", 40 - .data = (void *) &mc13xxx_i2c_device_id[0], 37 + .data = &mc13xxx_variant_mc13892, 38 + }, { 39 + .compatible = "fsl,mc34708", 40 + .data = &mc13xxx_variant_mc34708, 41 41 }, { 42 42 /* sentinel */ 43 43 } ··· 82 76 return ret; 83 77 } 84 78 85 - ret = mc13xxx_common_init(mc13xxx, pdata, client->irq); 79 + if (client->dev.of_node) { 80 + const struct of_device_id *of_id = 81 + of_match_device(mc13xxx_dt_ids, &client->dev); 82 + mc13xxx->variant = of_id->data; 83 + } else { 84 + mc13xxx->variant = (void *)id->driver_data; 85 + } 86 86 87 - if (ret == 0 && (id->driver_data != mc13xxx->ictype)) 88 - dev_warn(mc13xxx->dev, 89 - "device id doesn't match auto detection!\n"); 87 + ret = mc13xxx_common_init(mc13xxx, pdata, client->irq); 90 88 91 89 return ret; 92 90 }
+16 -13
drivers/mfd/mc13xxx-spi.c
··· 28 28 static const struct spi_device_id mc13xxx_device_id[] = { 29 29 { 30 30 .name = "mc13783", 31 - .driver_data = MC13XXX_ID_MC13783, 31 + .driver_data = (kernel_ulong_t)&mc13xxx_variant_mc13783, 32 32 }, { 33 33 .name = "mc13892", 34 - .driver_data = MC13XXX_ID_MC13892, 34 + .driver_data = (kernel_ulong_t)&mc13xxx_variant_mc13892, 35 + }, { 36 + .name = "mc34708", 37 + .driver_data = (kernel_ulong_t)&mc13xxx_variant_mc34708, 35 38 }, { 36 39 /* sentinel */ 37 40 } ··· 42 39 MODULE_DEVICE_TABLE(spi, mc13xxx_device_id); 43 40 44 41 static const struct of_device_id mc13xxx_dt_ids[] = { 45 - { .compatible = "fsl,mc13783", .data = (void *) MC13XXX_ID_MC13783, }, 46 - { .compatible = "fsl,mc13892", .data = (void *) MC13XXX_ID_MC13892, }, 42 + { .compatible = "fsl,mc13783", .data = &mc13xxx_variant_mc13783, }, 43 + { .compatible = "fsl,mc13892", .data = &mc13xxx_variant_mc13892, }, 44 + { .compatible = "fsl,mc34708", .data = &mc13xxx_variant_mc34708, }, 47 45 { /* sentinel */ } 48 46 }; 49 47 MODULE_DEVICE_TABLE(of, mc13xxx_dt_ids); ··· 148 144 return ret; 149 145 } 150 146 151 - ret = mc13xxx_common_init(mc13xxx, pdata, spi->irq); 147 + if (spi->dev.of_node) { 148 + const struct of_device_id *of_id = 149 + of_match_device(mc13xxx_dt_ids, &spi->dev); 152 150 153 - if (ret) { 154 - dev_set_drvdata(&spi->dev, NULL); 151 + mc13xxx->variant = of_id->data; 155 152 } else { 156 - const struct spi_device_id *devid = 157 - spi_get_device_id(spi); 158 - if (!devid || devid->driver_data != mc13xxx->ictype) 159 - dev_warn(mc13xxx->dev, 160 - "device id doesn't match auto detection!\n"); 153 + const struct spi_device_id *id_entry = spi_get_device_id(spi); 154 + 155 + mc13xxx->variant = (void *)id_entry->driver_data; 161 156 } 162 157 163 - return ret; 158 + return mc13xxx_common_init(mc13xxx, pdata, spi->irq); 164 159 } 165 160 166 161 static int mc13xxx_spi_remove(struct spi_device *spi)
+12 -6
drivers/mfd/mc13xxx.h
··· 13 13 #include <linux/regmap.h> 14 14 #include <linux/mfd/mc13xxx.h> 15 15 16 - enum mc13xxx_id { 17 - MC13XXX_ID_MC13783, 18 - MC13XXX_ID_MC13892, 19 - MC13XXX_ID_INVALID, 16 + #define MC13XXX_NUMREGS 0x3f 17 + 18 + struct mc13xxx; 19 + 20 + struct mc13xxx_variant { 21 + const char *name; 22 + void (*print_revision)(struct mc13xxx *mc13xxx, u32 revision); 20 23 }; 21 24 22 - #define MC13XXX_NUMREGS 0x3f 25 + extern struct mc13xxx_variant 26 + mc13xxx_variant_mc13783, 27 + mc13xxx_variant_mc13892, 28 + mc13xxx_variant_mc34708; 23 29 24 30 struct mc13xxx { 25 31 struct regmap *regmap; 26 32 27 33 struct device *dev; 28 - enum mc13xxx_id ictype; 34 + const struct mc13xxx_variant *variant; 29 35 30 36 struct mutex lock; 31 37 int irq;
+13 -2
drivers/mfd/mfd-core.c
··· 21 21 #include <linux/irqdomain.h> 22 22 #include <linux/of.h> 23 23 24 + static struct device_type mfd_dev_type = { 25 + .name = "mfd_device", 26 + }; 27 + 24 28 int mfd_cell_enable(struct platform_device *pdev) 25 29 { 26 30 const struct mfd_cell *cell = mfd_get_cell(pdev); ··· 95 91 goto fail_device; 96 92 97 93 pdev->dev.parent = parent; 94 + pdev->dev.type = &mfd_dev_type; 98 95 99 96 if (parent->of_node && cell->of_compatible) { 100 97 for_each_child_of_node(parent->of_node, np) { ··· 209 204 210 205 static int mfd_remove_devices_fn(struct device *dev, void *c) 211 206 { 212 - struct platform_device *pdev = to_platform_device(dev); 213 - const struct mfd_cell *cell = mfd_get_cell(pdev); 207 + struct platform_device *pdev; 208 + const struct mfd_cell *cell; 214 209 atomic_t **usage_count = c; 210 + 211 + if (dev->type != &mfd_dev_type) 212 + return 0; 213 + 214 + pdev = to_platform_device(dev); 215 + cell = mfd_get_cell(pdev); 215 216 216 217 /* find the base address of usage_count pointers (for freeing) */ 217 218 if (!*usage_count || (cell->usage_count < *usage_count))
+1 -1
drivers/mfd/rc5t583-irq.c
··· 345 345 mutex_init(&rc5t583->irq_lock); 346 346 347 347 /* Initailize all int register to 0 */ 348 - for (i = 0; i < RC5T583_MAX_INTERRUPT_MASK_REGS; i++) { 348 + for (i = 0; i < RC5T583_MAX_INTERRUPT_EN_REGS; i++) { 349 349 ret = rc5t583_write(rc5t583->dev, irq_en_add[i], 350 350 rc5t583->irq_en_reg[i]); 351 351 if (ret < 0)
+264
drivers/mfd/retu-mfd.c
··· 1 + /* 2 + * Retu MFD driver 3 + * 4 + * Copyright (C) 2004, 2005 Nokia Corporation 5 + * 6 + * Based on code written by Juha Yrjölä, David Weinehall and Mikko Ylinen. 7 + * Rewritten by Aaro Koskinen. 8 + * 9 + * This file is subject to the terms and conditions of the GNU General 10 + * Public License. See the file "COPYING" in the main directory of this 11 + * archive for more details. 12 + * 13 + * This program is distributed in the hope that it will be useful, 14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 + * GNU General Public License for more details. 17 + */ 18 + 19 + #include <linux/err.h> 20 + #include <linux/i2c.h> 21 + #include <linux/irq.h> 22 + #include <linux/init.h> 23 + #include <linux/slab.h> 24 + #include <linux/mutex.h> 25 + #include <linux/module.h> 26 + #include <linux/regmap.h> 27 + #include <linux/mfd/core.h> 28 + #include <linux/mfd/retu.h> 29 + #include <linux/interrupt.h> 30 + #include <linux/moduleparam.h> 31 + 32 + /* Registers */ 33 + #define RETU_REG_ASICR 0x00 /* ASIC ID and revision */ 34 + #define RETU_REG_ASICR_VILMA (1 << 7) /* Bit indicating Vilma */ 35 + #define RETU_REG_IDR 0x01 /* Interrupt ID */ 36 + #define RETU_REG_IMR 0x02 /* Interrupt mask */ 37 + 38 + /* Interrupt sources */ 39 + #define RETU_INT_PWR 0 /* Power button */ 40 + 41 + struct retu_dev { 42 + struct regmap *regmap; 43 + struct device *dev; 44 + struct mutex mutex; 45 + struct regmap_irq_chip_data *irq_data; 46 + }; 47 + 48 + static struct resource retu_pwrbutton_res[] = { 49 + { 50 + .name = "retu-pwrbutton", 51 + .start = RETU_INT_PWR, 52 + .end = RETU_INT_PWR, 53 + .flags = IORESOURCE_IRQ, 54 + }, 55 + }; 56 + 57 + static struct mfd_cell retu_devs[] = { 58 + { 59 + .name = "retu-wdt" 60 + }, 61 + { 62 + .name = "retu-pwrbutton", 63 + .resources = retu_pwrbutton_res, 64 + .num_resources = ARRAY_SIZE(retu_pwrbutton_res), 65 + } 66 + }; 67 + 68 + static struct regmap_irq retu_irqs[] = { 69 + [RETU_INT_PWR] = { 70 + .mask = 1 << RETU_INT_PWR, 71 + } 72 + }; 73 + 74 + static struct regmap_irq_chip retu_irq_chip = { 75 + .name = "RETU", 76 + .irqs = retu_irqs, 77 + .num_irqs = ARRAY_SIZE(retu_irqs), 78 + .num_regs = 1, 79 + .status_base = RETU_REG_IDR, 80 + .mask_base = RETU_REG_IMR, 81 + .ack_base = RETU_REG_IDR, 82 + }; 83 + 84 + /* Retu device registered for the power off. */ 85 + static struct retu_dev *retu_pm_power_off; 86 + 87 + int retu_read(struct retu_dev *rdev, u8 reg) 88 + { 89 + int ret; 90 + int value; 91 + 92 + mutex_lock(&rdev->mutex); 93 + ret = regmap_read(rdev->regmap, reg, &value); 94 + mutex_unlock(&rdev->mutex); 95 + 96 + return ret ? ret : value; 97 + } 98 + EXPORT_SYMBOL_GPL(retu_read); 99 + 100 + int retu_write(struct retu_dev *rdev, u8 reg, u16 data) 101 + { 102 + int ret; 103 + 104 + mutex_lock(&rdev->mutex); 105 + ret = regmap_write(rdev->regmap, reg, data); 106 + mutex_unlock(&rdev->mutex); 107 + 108 + return ret; 109 + } 110 + EXPORT_SYMBOL_GPL(retu_write); 111 + 112 + static void retu_power_off(void) 113 + { 114 + struct retu_dev *rdev = retu_pm_power_off; 115 + int reg; 116 + 117 + mutex_lock(&retu_pm_power_off->mutex); 118 + 119 + /* Ignore power button state */ 120 + regmap_read(rdev->regmap, RETU_REG_CC1, &reg); 121 + regmap_write(rdev->regmap, RETU_REG_CC1, reg | 2); 122 + 123 + /* Expire watchdog immediately */ 124 + regmap_write(rdev->regmap, RETU_REG_WATCHDOG, 0); 125 + 126 + /* Wait for poweroff */ 127 + for (;;) 128 + cpu_relax(); 129 + 130 + mutex_unlock(&retu_pm_power_off->mutex); 131 + } 132 + 133 + static int retu_regmap_read(void *context, const void *reg, size_t reg_size, 134 + void *val, size_t val_size) 135 + { 136 + int ret; 137 + struct device *dev = context; 138 + struct i2c_client *i2c = to_i2c_client(dev); 139 + 140 + BUG_ON(reg_size != 1 || val_size != 2); 141 + 142 + ret = i2c_smbus_read_word_data(i2c, *(u8 const *)reg); 143 + if (ret < 0) 144 + return ret; 145 + 146 + *(u16 *)val = ret; 147 + return 0; 148 + } 149 + 150 + static int retu_regmap_write(void *context, const void *data, size_t count) 151 + { 152 + u8 reg; 153 + u16 val; 154 + struct device *dev = context; 155 + struct i2c_client *i2c = to_i2c_client(dev); 156 + 157 + BUG_ON(count != sizeof(reg) + sizeof(val)); 158 + memcpy(&reg, data, sizeof(reg)); 159 + memcpy(&val, data + sizeof(reg), sizeof(val)); 160 + return i2c_smbus_write_word_data(i2c, reg, val); 161 + } 162 + 163 + static struct regmap_bus retu_bus = { 164 + .read = retu_regmap_read, 165 + .write = retu_regmap_write, 166 + .val_format_endian_default = REGMAP_ENDIAN_NATIVE, 167 + }; 168 + 169 + static struct regmap_config retu_config = { 170 + .reg_bits = 8, 171 + .val_bits = 16, 172 + }; 173 + 174 + static int __devinit retu_probe(struct i2c_client *i2c, 175 + const struct i2c_device_id *id) 176 + { 177 + struct retu_dev *rdev; 178 + int ret; 179 + 180 + rdev = devm_kzalloc(&i2c->dev, sizeof(*rdev), GFP_KERNEL); 181 + if (rdev == NULL) 182 + return -ENOMEM; 183 + 184 + i2c_set_clientdata(i2c, rdev); 185 + rdev->dev = &i2c->dev; 186 + mutex_init(&rdev->mutex); 187 + rdev->regmap = devm_regmap_init(&i2c->dev, &retu_bus, &i2c->dev, 188 + &retu_config); 189 + if (IS_ERR(rdev->regmap)) 190 + return PTR_ERR(rdev->regmap); 191 + 192 + ret = retu_read(rdev, RETU_REG_ASICR); 193 + if (ret < 0) { 194 + dev_err(rdev->dev, "could not read Retu revision: %d\n", ret); 195 + return ret; 196 + } 197 + 198 + dev_info(rdev->dev, "Retu%s v%d.%d found\n", 199 + (ret & RETU_REG_ASICR_VILMA) ? " & Vilma" : "", 200 + (ret >> 4) & 0x7, ret & 0xf); 201 + 202 + /* Mask all RETU interrupts. */ 203 + ret = retu_write(rdev, RETU_REG_IMR, 0xffff); 204 + if (ret < 0) 205 + return ret; 206 + 207 + ret = regmap_add_irq_chip(rdev->regmap, i2c->irq, IRQF_ONESHOT, -1, 208 + &retu_irq_chip, &rdev->irq_data); 209 + if (ret < 0) 210 + return ret; 211 + 212 + ret = mfd_add_devices(rdev->dev, -1, retu_devs, ARRAY_SIZE(retu_devs), 213 + NULL, regmap_irq_chip_get_base(rdev->irq_data), 214 + NULL); 215 + if (ret < 0) { 216 + regmap_del_irq_chip(i2c->irq, rdev->irq_data); 217 + return ret; 218 + } 219 + 220 + if (!pm_power_off) { 221 + retu_pm_power_off = rdev; 222 + pm_power_off = retu_power_off; 223 + } 224 + 225 + return 0; 226 + } 227 + 228 + static int __devexit retu_remove(struct i2c_client *i2c) 229 + { 230 + struct retu_dev *rdev = i2c_get_clientdata(i2c); 231 + 232 + if (retu_pm_power_off == rdev) { 233 + pm_power_off = NULL; 234 + retu_pm_power_off = NULL; 235 + } 236 + mfd_remove_devices(rdev->dev); 237 + regmap_del_irq_chip(i2c->irq, rdev->irq_data); 238 + 239 + return 0; 240 + } 241 + 242 + static const struct i2c_device_id retu_id[] = { 243 + { "retu-mfd", 0 }, 244 + { } 245 + }; 246 + MODULE_DEVICE_TABLE(i2c, retu_id); 247 + 248 + static struct i2c_driver retu_driver = { 249 + .driver = { 250 + .name = "retu-mfd", 251 + .owner = THIS_MODULE, 252 + }, 253 + .probe = retu_probe, 254 + .remove = retu_remove, 255 + .id_table = retu_id, 256 + }; 257 + module_i2c_driver(retu_driver); 258 + 259 + MODULE_DESCRIPTION("Retu MFD driver"); 260 + MODULE_AUTHOR("Juha Yrjölä"); 261 + MODULE_AUTHOR("David Weinehall"); 262 + MODULE_AUTHOR("Mikko Ylinen"); 263 + MODULE_AUTHOR("Aaro Koskinen <aaro.koskinen@iki.fi>"); 264 + MODULE_LICENSE("GPL");
+1
drivers/mfd/rtsx_pcr.c
··· 22 22 23 23 #include <linux/pci.h> 24 24 #include <linux/module.h> 25 + #include <linux/slab.h> 25 26 #include <linux/dma-mapping.h> 26 27 #include <linux/highmem.h> 27 28 #include <linux/interrupt.h>
+51 -51
drivers/mfd/sec-irq.c
··· 24 24 25 25 static struct regmap_irq s2mps11_irqs[] = { 26 26 [S2MPS11_IRQ_PWRONF] = { 27 - .reg_offset = 1, 27 + .reg_offset = 0, 28 28 .mask = S2MPS11_IRQ_PWRONF_MASK, 29 29 }, 30 30 [S2MPS11_IRQ_PWRONR] = { 31 - .reg_offset = 1, 31 + .reg_offset = 0, 32 32 .mask = S2MPS11_IRQ_PWRONR_MASK, 33 33 }, 34 34 [S2MPS11_IRQ_JIGONBF] = { 35 - .reg_offset = 1, 35 + .reg_offset = 0, 36 36 .mask = S2MPS11_IRQ_JIGONBF_MASK, 37 37 }, 38 38 [S2MPS11_IRQ_JIGONBR] = { 39 - .reg_offset = 1, 39 + .reg_offset = 0, 40 40 .mask = S2MPS11_IRQ_JIGONBR_MASK, 41 41 }, 42 42 [S2MPS11_IRQ_ACOKBF] = { 43 - .reg_offset = 1, 43 + .reg_offset = 0, 44 44 .mask = S2MPS11_IRQ_ACOKBF_MASK, 45 45 }, 46 46 [S2MPS11_IRQ_ACOKBR] = { 47 - .reg_offset = 1, 47 + .reg_offset = 0, 48 48 .mask = S2MPS11_IRQ_ACOKBR_MASK, 49 49 }, 50 50 [S2MPS11_IRQ_PWRON1S] = { 51 - .reg_offset = 1, 51 + .reg_offset = 0, 52 52 .mask = S2MPS11_IRQ_PWRON1S_MASK, 53 53 }, 54 54 [S2MPS11_IRQ_MRB] = { 55 - .reg_offset = 1, 55 + .reg_offset = 0, 56 56 .mask = S2MPS11_IRQ_MRB_MASK, 57 57 }, 58 58 [S2MPS11_IRQ_RTC60S] = { 59 - .reg_offset = 2, 59 + .reg_offset = 1, 60 60 .mask = S2MPS11_IRQ_RTC60S_MASK, 61 61 }, 62 62 [S2MPS11_IRQ_RTCA1] = { 63 - .reg_offset = 2, 63 + .reg_offset = 1, 64 64 .mask = S2MPS11_IRQ_RTCA1_MASK, 65 65 }, 66 66 [S2MPS11_IRQ_RTCA2] = { 67 - .reg_offset = 2, 67 + .reg_offset = 1, 68 68 .mask = S2MPS11_IRQ_RTCA2_MASK, 69 69 }, 70 70 [S2MPS11_IRQ_SMPL] = { 71 - .reg_offset = 2, 71 + .reg_offset = 1, 72 72 .mask = S2MPS11_IRQ_SMPL_MASK, 73 73 }, 74 74 [S2MPS11_IRQ_RTC1S] = { 75 - .reg_offset = 2, 75 + .reg_offset = 1, 76 76 .mask = S2MPS11_IRQ_RTC1S_MASK, 77 77 }, 78 78 [S2MPS11_IRQ_WTSR] = { 79 - .reg_offset = 2, 79 + .reg_offset = 1, 80 80 .mask = S2MPS11_IRQ_WTSR_MASK, 81 81 }, 82 82 [S2MPS11_IRQ_INT120C] = { 83 - .reg_offset = 3, 83 + .reg_offset = 2, 84 84 .mask = S2MPS11_IRQ_INT120C_MASK, 85 85 }, 86 86 [S2MPS11_IRQ_INT140C] = { 87 - .reg_offset = 3, 87 + .reg_offset = 2, 88 88 .mask = S2MPS11_IRQ_INT140C_MASK, 89 89 }, 90 90 }; ··· 92 92 93 93 static struct regmap_irq s5m8767_irqs[] = { 94 94 [S5M8767_IRQ_PWRR] = { 95 - .reg_offset = 1, 95 + .reg_offset = 0, 96 96 .mask = S5M8767_IRQ_PWRR_MASK, 97 97 }, 98 98 [S5M8767_IRQ_PWRF] = { 99 - .reg_offset = 1, 99 + .reg_offset = 0, 100 100 .mask = S5M8767_IRQ_PWRF_MASK, 101 101 }, 102 102 [S5M8767_IRQ_PWR1S] = { 103 - .reg_offset = 1, 103 + .reg_offset = 0, 104 104 .mask = S5M8767_IRQ_PWR1S_MASK, 105 105 }, 106 106 [S5M8767_IRQ_JIGR] = { 107 - .reg_offset = 1, 107 + .reg_offset = 0, 108 108 .mask = S5M8767_IRQ_JIGR_MASK, 109 109 }, 110 110 [S5M8767_IRQ_JIGF] = { 111 - .reg_offset = 1, 111 + .reg_offset = 0, 112 112 .mask = S5M8767_IRQ_JIGF_MASK, 113 113 }, 114 114 [S5M8767_IRQ_LOWBAT2] = { 115 - .reg_offset = 1, 115 + .reg_offset = 0, 116 116 .mask = S5M8767_IRQ_LOWBAT2_MASK, 117 117 }, 118 118 [S5M8767_IRQ_LOWBAT1] = { 119 - .reg_offset = 1, 119 + .reg_offset = 0, 120 120 .mask = S5M8767_IRQ_LOWBAT1_MASK, 121 121 }, 122 122 [S5M8767_IRQ_MRB] = { 123 - .reg_offset = 2, 123 + .reg_offset = 1, 124 124 .mask = S5M8767_IRQ_MRB_MASK, 125 125 }, 126 126 [S5M8767_IRQ_DVSOK2] = { 127 - .reg_offset = 2, 127 + .reg_offset = 1, 128 128 .mask = S5M8767_IRQ_DVSOK2_MASK, 129 129 }, 130 130 [S5M8767_IRQ_DVSOK3] = { 131 - .reg_offset = 2, 131 + .reg_offset = 1, 132 132 .mask = S5M8767_IRQ_DVSOK3_MASK, 133 133 }, 134 134 [S5M8767_IRQ_DVSOK4] = { 135 - .reg_offset = 2, 135 + .reg_offset = 1, 136 136 .mask = S5M8767_IRQ_DVSOK4_MASK, 137 137 }, 138 138 [S5M8767_IRQ_RTC60S] = { 139 - .reg_offset = 3, 139 + .reg_offset = 2, 140 140 .mask = S5M8767_IRQ_RTC60S_MASK, 141 141 }, 142 142 [S5M8767_IRQ_RTCA1] = { 143 - .reg_offset = 3, 143 + .reg_offset = 2, 144 144 .mask = S5M8767_IRQ_RTCA1_MASK, 145 145 }, 146 146 [S5M8767_IRQ_RTCA2] = { 147 - .reg_offset = 3, 147 + .reg_offset = 2, 148 148 .mask = S5M8767_IRQ_RTCA2_MASK, 149 149 }, 150 150 [S5M8767_IRQ_SMPL] = { 151 - .reg_offset = 3, 151 + .reg_offset = 2, 152 152 .mask = S5M8767_IRQ_SMPL_MASK, 153 153 }, 154 154 [S5M8767_IRQ_RTC1S] = { 155 - .reg_offset = 3, 155 + .reg_offset = 2, 156 156 .mask = S5M8767_IRQ_RTC1S_MASK, 157 157 }, 158 158 [S5M8767_IRQ_WTSR] = { 159 - .reg_offset = 3, 159 + .reg_offset = 2, 160 160 .mask = S5M8767_IRQ_WTSR_MASK, 161 161 }, 162 162 }; 163 163 164 164 static struct regmap_irq s5m8763_irqs[] = { 165 165 [S5M8763_IRQ_DCINF] = { 166 - .reg_offset = 1, 166 + .reg_offset = 0, 167 167 .mask = S5M8763_IRQ_DCINF_MASK, 168 168 }, 169 169 [S5M8763_IRQ_DCINR] = { 170 - .reg_offset = 1, 170 + .reg_offset = 0, 171 171 .mask = S5M8763_IRQ_DCINR_MASK, 172 172 }, 173 173 [S5M8763_IRQ_JIGF] = { 174 - .reg_offset = 1, 174 + .reg_offset = 0, 175 175 .mask = S5M8763_IRQ_JIGF_MASK, 176 176 }, 177 177 [S5M8763_IRQ_JIGR] = { 178 - .reg_offset = 1, 178 + .reg_offset = 0, 179 179 .mask = S5M8763_IRQ_JIGR_MASK, 180 180 }, 181 181 [S5M8763_IRQ_PWRONF] = { 182 - .reg_offset = 1, 182 + .reg_offset = 0, 183 183 .mask = S5M8763_IRQ_PWRONF_MASK, 184 184 }, 185 185 [S5M8763_IRQ_PWRONR] = { 186 - .reg_offset = 1, 186 + .reg_offset = 0, 187 187 .mask = S5M8763_IRQ_PWRONR_MASK, 188 188 }, 189 189 [S5M8763_IRQ_WTSREVNT] = { 190 - .reg_offset = 2, 190 + .reg_offset = 1, 191 191 .mask = S5M8763_IRQ_WTSREVNT_MASK, 192 192 }, 193 193 [S5M8763_IRQ_SMPLEVNT] = { 194 - .reg_offset = 2, 194 + .reg_offset = 1, 195 195 .mask = S5M8763_IRQ_SMPLEVNT_MASK, 196 196 }, 197 197 [S5M8763_IRQ_ALARM1] = { 198 - .reg_offset = 2, 198 + .reg_offset = 1, 199 199 .mask = S5M8763_IRQ_ALARM1_MASK, 200 200 }, 201 201 [S5M8763_IRQ_ALARM0] = { 202 - .reg_offset = 2, 202 + .reg_offset = 1, 203 203 .mask = S5M8763_IRQ_ALARM0_MASK, 204 204 }, 205 205 [S5M8763_IRQ_ONKEY1S] = { 206 - .reg_offset = 3, 206 + .reg_offset = 2, 207 207 .mask = S5M8763_IRQ_ONKEY1S_MASK, 208 208 }, 209 209 [S5M8763_IRQ_TOPOFFR] = { 210 - .reg_offset = 3, 210 + .reg_offset = 2, 211 211 .mask = S5M8763_IRQ_TOPOFFR_MASK, 212 212 }, 213 213 [S5M8763_IRQ_DCINOVPR] = { 214 - .reg_offset = 3, 214 + .reg_offset = 2, 215 215 .mask = S5M8763_IRQ_DCINOVPR_MASK, 216 216 }, 217 217 [S5M8763_IRQ_CHGRSTF] = { 218 - .reg_offset = 3, 218 + .reg_offset = 2, 219 219 .mask = S5M8763_IRQ_CHGRSTF_MASK, 220 220 }, 221 221 [S5M8763_IRQ_DONER] = { 222 - .reg_offset = 3, 222 + .reg_offset = 2, 223 223 .mask = S5M8763_IRQ_DONER_MASK, 224 224 }, 225 225 [S5M8763_IRQ_CHGFAULT] = { 226 - .reg_offset = 3, 226 + .reg_offset = 2, 227 227 .mask = S5M8763_IRQ_CHGFAULT_MASK, 228 228 }, 229 229 [S5M8763_IRQ_LOBAT1] = { 230 - .reg_offset = 4, 230 + .reg_offset = 3, 231 231 .mask = S5M8763_IRQ_LOBAT1_MASK, 232 232 }, 233 233 [S5M8763_IRQ_LOBAT2] = { 234 - .reg_offset = 4, 234 + .reg_offset = 3, 235 235 .mask = S5M8763_IRQ_LOBAT2_MASK, 236 236 }, 237 237 };
+381 -157
drivers/mfd/sta2x11-mfd.c
··· 1 1 /* 2 2 * Copyright (c) 2009-2011 Wind River Systems, Inc. 3 - * Copyright (c) 2011 ST Microelectronics (Alessandro Rubini) 3 + * Copyright (c) 2011 ST Microelectronics (Alessandro Rubini, Davide Ciminaghi) 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify 6 6 * it under the terms of the GNU General Public License version 2 as ··· 27 27 #include <linux/io.h> 28 28 #include <linux/ioport.h> 29 29 #include <linux/pci.h> 30 - #include <linux/debugfs.h> 31 30 #include <linux/seq_file.h> 32 31 #include <linux/platform_device.h> 33 32 #include <linux/mfd/core.h> 34 33 #include <linux/mfd/sta2x11-mfd.h> 34 + #include <linux/regmap.h> 35 35 36 36 #include <asm/sta2x11.h> 37 + 38 + static inline int __reg_within_range(unsigned int r, 39 + unsigned int start, 40 + unsigned int end) 41 + { 42 + return ((r >= start) && (r <= end)); 43 + } 37 44 38 45 /* This describes STA2X11 MFD chip for us, we may have several */ 39 46 struct sta2x11_mfd { 40 47 struct sta2x11_instance *instance; 41 - spinlock_t lock; 48 + struct regmap *regmap[sta2x11_n_mfd_plat_devs]; 49 + spinlock_t lock[sta2x11_n_mfd_plat_devs]; 42 50 struct list_head list; 43 - void __iomem *sctl_regs; 44 - void __iomem *apbreg_regs; 51 + void __iomem *regs[sta2x11_n_mfd_plat_devs]; 45 52 }; 46 53 47 54 static LIST_HEAD(sta2x11_mfd_list); ··· 78 71 79 72 static int sta2x11_mfd_add(struct pci_dev *pdev, gfp_t flags) 80 73 { 74 + int i; 81 75 struct sta2x11_mfd *mfd = sta2x11_mfd_find(pdev); 82 76 struct sta2x11_instance *instance; 83 77 ··· 91 83 if (!mfd) 92 84 return -ENOMEM; 93 85 INIT_LIST_HEAD(&mfd->list); 94 - spin_lock_init(&mfd->lock); 86 + for (i = 0; i < ARRAY_SIZE(mfd->lock); i++) 87 + spin_lock_init(&mfd->lock[i]); 95 88 mfd->instance = instance; 96 89 list_add(&mfd->list, &sta2x11_mfd_list); 97 90 return 0; ··· 109 100 return 0; 110 101 } 111 102 112 - /* These two functions are exported and are not expected to fail */ 113 - u32 sta2x11_sctl_mask(struct pci_dev *pdev, u32 reg, u32 mask, u32 val) 103 + /* This function is exported and is not expected to fail */ 104 + u32 __sta2x11_mfd_mask(struct pci_dev *pdev, u32 reg, u32 mask, u32 val, 105 + enum sta2x11_mfd_plat_dev index) 114 106 { 115 107 struct sta2x11_mfd *mfd = sta2x11_mfd_find(pdev); 116 108 u32 r; 117 109 unsigned long flags; 110 + void __iomem *regs; 118 111 119 112 if (!mfd) { 120 113 dev_warn(&pdev->dev, ": can't access sctl regs\n"); 121 114 return 0; 122 115 } 123 - if (!mfd->sctl_regs) { 116 + 117 + regs = mfd->regs[index]; 118 + if (!regs) { 124 119 dev_warn(&pdev->dev, ": system ctl not initialized\n"); 125 120 return 0; 126 121 } 127 - spin_lock_irqsave(&mfd->lock, flags); 128 - r = readl(mfd->sctl_regs + reg); 122 + spin_lock_irqsave(&mfd->lock[index], flags); 123 + r = readl(regs + reg); 129 124 r &= ~mask; 130 125 r |= val; 131 126 if (mask) 132 - writel(r, mfd->sctl_regs + reg); 133 - spin_unlock_irqrestore(&mfd->lock, flags); 127 + writel(r, regs + reg); 128 + spin_unlock_irqrestore(&mfd->lock[index], flags); 134 129 return r; 135 130 } 136 - EXPORT_SYMBOL(sta2x11_sctl_mask); 131 + EXPORT_SYMBOL(__sta2x11_mfd_mask); 137 132 138 - u32 sta2x11_apbreg_mask(struct pci_dev *pdev, u32 reg, u32 mask, u32 val) 133 + int sta2x11_mfd_get_regs_data(struct platform_device *dev, 134 + enum sta2x11_mfd_plat_dev index, 135 + void __iomem **regs, 136 + spinlock_t **lock) 139 137 { 140 - struct sta2x11_mfd *mfd = sta2x11_mfd_find(pdev); 141 - u32 r; 142 - unsigned long flags; 138 + struct pci_dev *pdev = *(struct pci_dev **)(dev->dev.platform_data); 139 + struct sta2x11_mfd *mfd; 143 140 144 - if (!mfd) { 145 - dev_warn(&pdev->dev, ": can't access apb regs\n"); 146 - return 0; 147 - } 148 - if (!mfd->apbreg_regs) { 149 - dev_warn(&pdev->dev, ": apb bridge not initialized\n"); 150 - return 0; 151 - } 152 - spin_lock_irqsave(&mfd->lock, flags); 153 - r = readl(mfd->apbreg_regs + reg); 154 - r &= ~mask; 155 - r |= val; 156 - if (mask) 157 - writel(r, mfd->apbreg_regs + reg); 158 - spin_unlock_irqrestore(&mfd->lock, flags); 159 - return r; 141 + if (!pdev) 142 + return -ENODEV; 143 + mfd = sta2x11_mfd_find(pdev); 144 + if (!mfd) 145 + return -ENODEV; 146 + if (index >= sta2x11_n_mfd_plat_devs) 147 + return -ENODEV; 148 + *regs = mfd->regs[index]; 149 + *lock = &mfd->lock[index]; 150 + pr_debug("%s %d *regs = %p\n", __func__, __LINE__, *regs); 151 + return *regs ? 0 : -ENODEV; 160 152 } 161 - EXPORT_SYMBOL(sta2x11_apbreg_mask); 153 + EXPORT_SYMBOL(sta2x11_mfd_get_regs_data); 162 154 163 - /* Two debugfs files, for our registers (FIXME: one instance only) */ 164 - #define REG(regname) {.name = #regname, .offset = SCTL_ ## regname} 165 - static struct debugfs_reg32 sta2x11_sctl_regs[] = { 166 - REG(SCCTL), REG(ARMCFG), REG(SCPLLCTL), REG(SCPLLFCTRL), 167 - REG(SCRESFRACT), REG(SCRESCTRL1), REG(SCRESXTRL2), REG(SCPEREN0), 168 - REG(SCPEREN1), REG(SCPEREN2), REG(SCGRST), REG(SCPCIPMCR1), 169 - REG(SCPCIPMCR2), REG(SCPCIPMSR1), REG(SCPCIPMSR2), REG(SCPCIPMSR3), 170 - REG(SCINTREN), REG(SCRISR), REG(SCCLKSTAT0), REG(SCCLKSTAT1), 171 - REG(SCCLKSTAT2), REG(SCRSTSTA), 155 + /* 156 + * Special sta2x11-mfd regmap lock/unlock functions 157 + */ 158 + 159 + static void sta2x11_regmap_lock(void *__lock) 160 + { 161 + spinlock_t *lock = __lock; 162 + spin_lock(lock); 163 + } 164 + 165 + static void sta2x11_regmap_unlock(void *__lock) 166 + { 167 + spinlock_t *lock = __lock; 168 + spin_unlock(lock); 169 + } 170 + 171 + /* OTP (one time programmable registers do not require locking */ 172 + static void sta2x11_regmap_nolock(void *__lock) 173 + { 174 + } 175 + 176 + static const char *sta2x11_mfd_names[sta2x11_n_mfd_plat_devs] = { 177 + [sta2x11_sctl] = STA2X11_MFD_SCTL_NAME, 178 + [sta2x11_apbreg] = STA2X11_MFD_APBREG_NAME, 179 + [sta2x11_apb_soc_regs] = STA2X11_MFD_APB_SOC_REGS_NAME, 180 + [sta2x11_scr] = STA2X11_MFD_SCR_NAME, 172 181 }; 173 - #undef REG 174 182 175 - static struct debugfs_regset32 sctl_regset = { 176 - .regs = sta2x11_sctl_regs, 177 - .nregs = ARRAY_SIZE(sta2x11_sctl_regs), 183 + static bool sta2x11_sctl_writeable_reg(struct device *dev, unsigned int reg) 184 + { 185 + return !__reg_within_range(reg, SCTL_SCPCIECSBRST, SCTL_SCRSTSTA); 186 + } 187 + 188 + static struct regmap_config sta2x11_sctl_regmap_config = { 189 + .reg_bits = 32, 190 + .reg_stride = 4, 191 + .val_bits = 32, 192 + .lock = sta2x11_regmap_lock, 193 + .unlock = sta2x11_regmap_unlock, 194 + .max_register = SCTL_SCRSTSTA, 195 + .writeable_reg = sta2x11_sctl_writeable_reg, 178 196 }; 179 197 180 - #define REG(regname) {.name = #regname, .offset = regname} 181 - static struct debugfs_reg32 sta2x11_apbreg_regs[] = { 182 - REG(APBREG_BSR), REG(APBREG_PAER), REG(APBREG_PWAC), REG(APBREG_PRAC), 183 - REG(APBREG_PCG), REG(APBREG_PUR), REG(APBREG_EMU_PCG), 198 + static bool sta2x11_scr_readable_reg(struct device *dev, unsigned int reg) 199 + { 200 + return (reg == STA2X11_SECR_CR) || 201 + __reg_within_range(reg, STA2X11_SECR_FVR0, STA2X11_SECR_FVR1); 202 + } 203 + 204 + static bool sta2x11_scr_writeable_reg(struct device *dev, unsigned int reg) 205 + { 206 + return false; 207 + } 208 + 209 + static struct regmap_config sta2x11_scr_regmap_config = { 210 + .reg_bits = 32, 211 + .reg_stride = 4, 212 + .val_bits = 32, 213 + .lock = sta2x11_regmap_nolock, 214 + .unlock = sta2x11_regmap_nolock, 215 + .max_register = STA2X11_SECR_FVR1, 216 + .readable_reg = sta2x11_scr_readable_reg, 217 + .writeable_reg = sta2x11_scr_writeable_reg, 184 218 }; 185 - #undef REG 186 219 187 - static struct debugfs_regset32 apbreg_regset = { 188 - .regs = sta2x11_apbreg_regs, 189 - .nregs = ARRAY_SIZE(sta2x11_apbreg_regs), 220 + static bool sta2x11_apbreg_readable_reg(struct device *dev, unsigned int reg) 221 + { 222 + /* Two blocks (CAN and MLB, SARAC) 0x100 bytes apart */ 223 + if (reg >= APBREG_BSR_SARAC) 224 + reg -= APBREG_BSR_SARAC; 225 + switch (reg) { 226 + case APBREG_BSR: 227 + case APBREG_PAER: 228 + case APBREG_PWAC: 229 + case APBREG_PRAC: 230 + case APBREG_PCG: 231 + case APBREG_PUR: 232 + case APBREG_EMU_PCG: 233 + return true; 234 + default: 235 + return false; 236 + } 237 + } 238 + 239 + static bool sta2x11_apbreg_writeable_reg(struct device *dev, unsigned int reg) 240 + { 241 + if (reg >= APBREG_BSR_SARAC) 242 + reg -= APBREG_BSR_SARAC; 243 + if (!sta2x11_apbreg_readable_reg(dev, reg)) 244 + return false; 245 + return reg != APBREG_PAER; 246 + } 247 + 248 + static struct regmap_config sta2x11_apbreg_regmap_config = { 249 + .reg_bits = 32, 250 + .reg_stride = 4, 251 + .val_bits = 32, 252 + .lock = sta2x11_regmap_lock, 253 + .unlock = sta2x11_regmap_unlock, 254 + .max_register = APBREG_EMU_PCG_SARAC, 255 + .readable_reg = sta2x11_apbreg_readable_reg, 256 + .writeable_reg = sta2x11_apbreg_writeable_reg, 190 257 }; 191 258 192 - static struct dentry *sta2x11_sctl_debugfs; 193 - static struct dentry *sta2x11_apbreg_debugfs; 259 + static bool sta2x11_apb_soc_regs_readable_reg(struct device *dev, 260 + unsigned int reg) 261 + { 262 + return reg <= PCIE_SoC_INT_ROUTER_STATUS3_REG || 263 + __reg_within_range(reg, DMA_IP_CTRL_REG, SPARE3_RESERVED) || 264 + __reg_within_range(reg, MASTER_LOCK_REG, 265 + SYSTEM_CONFIG_STATUS_REG) || 266 + reg == MSP_CLK_CTRL_REG || 267 + __reg_within_range(reg, COMPENSATION_REG1, TEST_CTL_REG); 268 + } 194 269 195 - /* Probe for the two platform devices */ 196 - static int sta2x11_sctl_probe(struct platform_device *dev) 270 + static bool sta2x11_apb_soc_regs_writeable_reg(struct device *dev, 271 + unsigned int reg) 272 + { 273 + if (!sta2x11_apb_soc_regs_readable_reg(dev, reg)) 274 + return false; 275 + switch (reg) { 276 + case PCIE_COMMON_CLOCK_CONFIG_0_4_0: 277 + case SYSTEM_CONFIG_STATUS_REG: 278 + case COMPENSATION_REG1: 279 + case PCIE_SoC_INT_ROUTER_STATUS0_REG...PCIE_SoC_INT_ROUTER_STATUS3_REG: 280 + case PCIE_PM_STATUS_0_PORT_0_4...PCIE_PM_STATUS_7_0_EP4: 281 + return false; 282 + default: 283 + return true; 284 + } 285 + } 286 + 287 + static struct regmap_config sta2x11_apb_soc_regs_regmap_config = { 288 + .reg_bits = 32, 289 + .reg_stride = 4, 290 + .val_bits = 32, 291 + .lock = sta2x11_regmap_lock, 292 + .unlock = sta2x11_regmap_unlock, 293 + .max_register = TEST_CTL_REG, 294 + .readable_reg = sta2x11_apb_soc_regs_readable_reg, 295 + .writeable_reg = sta2x11_apb_soc_regs_writeable_reg, 296 + }; 297 + 298 + static struct regmap_config * 299 + sta2x11_mfd_regmap_configs[sta2x11_n_mfd_plat_devs] = { 300 + [sta2x11_sctl] = &sta2x11_sctl_regmap_config, 301 + [sta2x11_apbreg] = &sta2x11_apbreg_regmap_config, 302 + [sta2x11_apb_soc_regs] = &sta2x11_apb_soc_regs_regmap_config, 303 + [sta2x11_scr] = &sta2x11_scr_regmap_config, 304 + }; 305 + 306 + /* Probe for the four platform devices */ 307 + 308 + static int sta2x11_mfd_platform_probe(struct platform_device *dev, 309 + enum sta2x11_mfd_plat_dev index) 197 310 { 198 311 struct pci_dev **pdev; 199 312 struct sta2x11_mfd *mfd; 200 313 struct resource *res; 314 + const char *name = sta2x11_mfd_names[index]; 315 + struct regmap_config *regmap_config = sta2x11_mfd_regmap_configs[index]; 201 316 202 317 pdev = dev->dev.platform_data; 203 318 mfd = sta2x11_mfd_find(*pdev); 204 319 if (!mfd) 320 + return -ENODEV; 321 + if (!regmap_config) 205 322 return -ENODEV; 206 323 207 324 res = platform_get_resource(dev, IORESOURCE_MEM, 0); 208 325 if (!res) 209 326 return -ENOMEM; 210 327 211 - if (!request_mem_region(res->start, resource_size(res), 212 - "sta2x11-sctl")) 328 + if (!request_mem_region(res->start, resource_size(res), name)) 213 329 return -EBUSY; 214 330 215 - mfd->sctl_regs = ioremap(res->start, resource_size(res)); 216 - if (!mfd->sctl_regs) { 331 + mfd->regs[index] = ioremap(res->start, resource_size(res)); 332 + if (!mfd->regs[index]) { 217 333 release_mem_region(res->start, resource_size(res)); 218 334 return -ENOMEM; 219 335 } 220 - sctl_regset.base = mfd->sctl_regs; 221 - sta2x11_sctl_debugfs = debugfs_create_regset32("sta2x11-sctl", 222 - S_IFREG | S_IRUGO, 223 - NULL, &sctl_regset); 336 + regmap_config->lock_arg = &mfd->lock; 337 + /* 338 + No caching, registers could be reached both via regmap and via 339 + void __iomem * 340 + */ 341 + regmap_config->cache_type = REGCACHE_NONE; 342 + mfd->regmap[index] = devm_regmap_init_mmio(&dev->dev, mfd->regs[index], 343 + regmap_config); 344 + WARN_ON(!mfd->regmap[index]); 345 + 224 346 return 0; 347 + } 348 + 349 + static int sta2x11_sctl_probe(struct platform_device *dev) 350 + { 351 + return sta2x11_mfd_platform_probe(dev, sta2x11_sctl); 225 352 } 226 353 227 354 static int sta2x11_apbreg_probe(struct platform_device *dev) 228 355 { 229 - struct pci_dev **pdev; 230 - struct sta2x11_mfd *mfd; 231 - struct resource *res; 232 - 233 - pdev = dev->dev.platform_data; 234 - dev_dbg(&dev->dev, "%s: pdata is %p\n", __func__, pdev); 235 - dev_dbg(&dev->dev, "%s: *pdata is %p\n", __func__, *pdev); 236 - 237 - mfd = sta2x11_mfd_find(*pdev); 238 - if (!mfd) 239 - return -ENODEV; 240 - 241 - res = platform_get_resource(dev, IORESOURCE_MEM, 0); 242 - if (!res) 243 - return -ENOMEM; 244 - 245 - if (!request_mem_region(res->start, resource_size(res), 246 - "sta2x11-apbreg")) 247 - return -EBUSY; 248 - 249 - mfd->apbreg_regs = ioremap(res->start, resource_size(res)); 250 - if (!mfd->apbreg_regs) { 251 - release_mem_region(res->start, resource_size(res)); 252 - return -ENOMEM; 253 - } 254 - dev_dbg(&dev->dev, "%s: regbase %p\n", __func__, mfd->apbreg_regs); 255 - 256 - apbreg_regset.base = mfd->apbreg_regs; 257 - sta2x11_apbreg_debugfs = debugfs_create_regset32("sta2x11-apbreg", 258 - S_IFREG | S_IRUGO, 259 - NULL, &apbreg_regset); 260 - return 0; 356 + return sta2x11_mfd_platform_probe(dev, sta2x11_apbreg); 261 357 } 262 358 263 - /* The two platform drivers */ 359 + static int sta2x11_apb_soc_regs_probe(struct platform_device *dev) 360 + { 361 + return sta2x11_mfd_platform_probe(dev, sta2x11_apb_soc_regs); 362 + } 363 + 364 + static int sta2x11_scr_probe(struct platform_device *dev) 365 + { 366 + return sta2x11_mfd_platform_probe(dev, sta2x11_scr); 367 + } 368 + 369 + /* The three platform drivers */ 264 370 static struct platform_driver sta2x11_sctl_platform_driver = { 265 371 .driver = { 266 - .name = "sta2x11-sctl", 372 + .name = STA2X11_MFD_SCTL_NAME, 267 373 .owner = THIS_MODULE, 268 374 }, 269 375 .probe = sta2x11_sctl_probe, ··· 392 268 393 269 static struct platform_driver sta2x11_platform_driver = { 394 270 .driver = { 395 - .name = "sta2x11-apbreg", 271 + .name = STA2X11_MFD_APBREG_NAME, 396 272 .owner = THIS_MODULE, 397 273 }, 398 274 .probe = sta2x11_apbreg_probe, ··· 404 280 return platform_driver_register(&sta2x11_platform_driver); 405 281 } 406 282 283 + static struct platform_driver sta2x11_apb_soc_regs_platform_driver = { 284 + .driver = { 285 + .name = STA2X11_MFD_APB_SOC_REGS_NAME, 286 + .owner = THIS_MODULE, 287 + }, 288 + .probe = sta2x11_apb_soc_regs_probe, 289 + }; 290 + 291 + static int __init sta2x11_apb_soc_regs_init(void) 292 + { 293 + pr_info("%s\n", __func__); 294 + return platform_driver_register(&sta2x11_apb_soc_regs_platform_driver); 295 + } 296 + 297 + static struct platform_driver sta2x11_scr_platform_driver = { 298 + .driver = { 299 + .name = STA2X11_MFD_SCR_NAME, 300 + .owner = THIS_MODULE, 301 + }, 302 + .probe = sta2x11_scr_probe, 303 + }; 304 + 305 + static int __init sta2x11_scr_init(void) 306 + { 307 + pr_info("%s\n", __func__); 308 + return platform_driver_register(&sta2x11_scr_platform_driver); 309 + } 310 + 311 + 407 312 /* 408 - * What follows is the PCI device that hosts the above two pdevs. 313 + * What follows are the PCI devices that host the above pdevs. 409 314 * Each logic block is 4kB and they are all consecutive: we use this info. 410 315 */ 411 316 412 - /* Bar 0 */ 413 - enum bar0_cells { 317 + /* Mfd 0 device */ 318 + 319 + /* Mfd 0, Bar 0 */ 320 + enum mfd0_bar0_cells { 414 321 STA2X11_GPIO_0 = 0, 415 322 STA2X11_GPIO_1, 416 323 STA2X11_GPIO_2, ··· 450 295 STA2X11_SCR, 451 296 STA2X11_TIME, 452 297 }; 453 - /* Bar 1 */ 454 - enum bar1_cells { 298 + /* Mfd 0 , Bar 1 */ 299 + enum mfd0_bar1_cells { 455 300 STA2X11_APBREG = 0, 456 301 }; 457 302 #define CELL_4K(_name, _cell) { \ ··· 462 307 463 308 static const struct resource gpio_resources[] = { 464 309 { 465 - .name = "sta2x11_gpio", /* 4 consecutive cells, 1 driver */ 310 + /* 4 consecutive cells, 1 driver */ 311 + .name = STA2X11_MFD_GPIO_NAME, 466 312 .start = 0, 467 313 .end = (4 * 4096) - 1, 468 314 .flags = IORESOURCE_MEM, 469 315 } 470 316 }; 471 317 static const struct resource sctl_resources[] = { 472 - CELL_4K("sta2x11-sctl", STA2X11_SCTL), 318 + CELL_4K(STA2X11_MFD_SCTL_NAME, STA2X11_SCTL), 473 319 }; 474 320 static const struct resource scr_resources[] = { 475 - CELL_4K("sta2x11-scr", STA2X11_SCR), 321 + CELL_4K(STA2X11_MFD_SCR_NAME, STA2X11_SCR), 476 322 }; 477 323 static const struct resource time_resources[] = { 478 - CELL_4K("sta2x11-time", STA2X11_TIME), 324 + CELL_4K(STA2X11_MFD_TIME_NAME, STA2X11_TIME), 479 325 }; 480 326 481 327 static const struct resource apbreg_resources[] = { 482 - CELL_4K("sta2x11-apbreg", STA2X11_APBREG), 328 + CELL_4K(STA2X11_MFD_APBREG_NAME, STA2X11_APBREG), 483 329 }; 484 330 485 331 #define DEV(_name, _r) \ 486 332 { .name = _name, .num_resources = ARRAY_SIZE(_r), .resources = _r, } 487 333 488 - static struct mfd_cell sta2x11_mfd_bar0[] = { 489 - DEV("sta2x11-gpio", gpio_resources), /* offset 0: we add pdata later */ 490 - DEV("sta2x11-sctl", sctl_resources), 491 - DEV("sta2x11-scr", scr_resources), 492 - DEV("sta2x11-time", time_resources), 334 + static struct mfd_cell sta2x11_mfd0_bar0[] = { 335 + /* offset 0: we add pdata later */ 336 + DEV(STA2X11_MFD_GPIO_NAME, gpio_resources), 337 + DEV(STA2X11_MFD_SCTL_NAME, sctl_resources), 338 + DEV(STA2X11_MFD_SCR_NAME, scr_resources), 339 + DEV(STA2X11_MFD_TIME_NAME, time_resources), 493 340 }; 494 341 495 - static struct mfd_cell sta2x11_mfd_bar1[] = { 496 - DEV("sta2x11-apbreg", apbreg_resources), 342 + static struct mfd_cell sta2x11_mfd0_bar1[] = { 343 + DEV(STA2X11_MFD_APBREG_NAME, apbreg_resources), 497 344 }; 345 + 346 + /* Mfd 1 devices */ 347 + 348 + /* Mfd 1, Bar 0 */ 349 + enum mfd1_bar0_cells { 350 + STA2X11_VIC = 0, 351 + }; 352 + 353 + /* Mfd 1, Bar 1 */ 354 + enum mfd1_bar1_cells { 355 + STA2X11_APB_SOC_REGS = 0, 356 + }; 357 + 358 + static const __devinitconst struct resource vic_resources[] = { 359 + CELL_4K(STA2X11_MFD_VIC_NAME, STA2X11_VIC), 360 + }; 361 + 362 + static const __devinitconst struct resource apb_soc_regs_resources[] = { 363 + CELL_4K(STA2X11_MFD_APB_SOC_REGS_NAME, STA2X11_APB_SOC_REGS), 364 + }; 365 + 366 + static __devinitdata struct mfd_cell sta2x11_mfd1_bar0[] = { 367 + DEV(STA2X11_MFD_VIC_NAME, vic_resources), 368 + }; 369 + 370 + static __devinitdata struct mfd_cell sta2x11_mfd1_bar1[] = { 371 + DEV(STA2X11_MFD_APB_SOC_REGS_NAME, apb_soc_regs_resources), 372 + }; 373 + 498 374 499 375 static int sta2x11_mfd_suspend(struct pci_dev *pdev, pm_message_t state) 500 376 { ··· 549 363 return 0; 550 364 } 551 365 366 + struct sta2x11_mfd_bar_setup_data { 367 + struct mfd_cell *cells; 368 + int ncells; 369 + }; 370 + 371 + struct sta2x11_mfd_setup_data { 372 + struct sta2x11_mfd_bar_setup_data bars[2]; 373 + }; 374 + 375 + #define STA2X11_MFD0 0 376 + #define STA2X11_MFD1 1 377 + 378 + static struct sta2x11_mfd_setup_data mfd_setup_data[] = { 379 + /* Mfd 0: gpio, sctl, scr, timers / apbregs */ 380 + [STA2X11_MFD0] = { 381 + .bars = { 382 + [0] = { 383 + .cells = sta2x11_mfd0_bar0, 384 + .ncells = ARRAY_SIZE(sta2x11_mfd0_bar0), 385 + }, 386 + [1] = { 387 + .cells = sta2x11_mfd0_bar1, 388 + .ncells = ARRAY_SIZE(sta2x11_mfd0_bar1), 389 + }, 390 + }, 391 + }, 392 + /* Mfd 1: vic / apb-soc-regs */ 393 + [STA2X11_MFD1] = { 394 + .bars = { 395 + [0] = { 396 + .cells = sta2x11_mfd1_bar0, 397 + .ncells = ARRAY_SIZE(sta2x11_mfd1_bar0), 398 + }, 399 + [1] = { 400 + .cells = sta2x11_mfd1_bar1, 401 + .ncells = ARRAY_SIZE(sta2x11_mfd1_bar1), 402 + }, 403 + }, 404 + }, 405 + }; 406 + 407 + static void sta2x11_mfd_setup(struct pci_dev *pdev, 408 + struct sta2x11_mfd_setup_data *sd) 409 + { 410 + int i, j; 411 + for (i = 0; i < ARRAY_SIZE(sd->bars); i++) 412 + for (j = 0; j < sd->bars[i].ncells; j++) { 413 + sd->bars[i].cells[j].pdata_size = sizeof(pdev); 414 + sd->bars[i].cells[j].platform_data = &pdev; 415 + } 416 + } 417 + 552 418 static int sta2x11_mfd_probe(struct pci_dev *pdev, 553 - const struct pci_device_id *pci_id) 419 + const struct pci_device_id *pci_id) 554 420 { 555 421 int err, i; 556 - struct sta2x11_gpio_pdata *gpio_data; 422 + struct sta2x11_mfd_setup_data *setup_data; 557 423 558 424 dev_info(&pdev->dev, "%s\n", __func__); 559 425 ··· 619 381 if (err) 620 382 dev_info(&pdev->dev, "Enable msi failed\n"); 621 383 622 - /* Read gpio config data as pci device's platform data */ 623 - gpio_data = dev_get_platdata(&pdev->dev); 624 - if (!gpio_data) 625 - dev_warn(&pdev->dev, "no gpio configuration\n"); 626 - 627 - dev_dbg(&pdev->dev, "%s, gpio_data = %p (%p)\n", __func__, 628 - gpio_data, &gpio_data); 629 - dev_dbg(&pdev->dev, "%s, pdev = %p (%p)\n", __func__, 630 - pdev, &pdev); 384 + setup_data = pci_id->device == PCI_DEVICE_ID_STMICRO_GPIO ? 385 + &mfd_setup_data[STA2X11_MFD0] : 386 + &mfd_setup_data[STA2X11_MFD1]; 631 387 632 388 /* platform data is the pci device for all of them */ 633 - for (i = 0; i < ARRAY_SIZE(sta2x11_mfd_bar0); i++) { 634 - sta2x11_mfd_bar0[i].pdata_size = sizeof(pdev); 635 - sta2x11_mfd_bar0[i].platform_data = &pdev; 636 - } 637 - sta2x11_mfd_bar1[0].pdata_size = sizeof(pdev); 638 - sta2x11_mfd_bar1[0].platform_data = &pdev; 389 + sta2x11_mfd_setup(pdev, setup_data); 639 390 640 391 /* Record this pdev before mfd_add_devices: their probe looks for it */ 641 - sta2x11_mfd_add(pdev, GFP_ATOMIC); 392 + if (!sta2x11_mfd_find(pdev)) 393 + sta2x11_mfd_add(pdev, GFP_ATOMIC); 642 394 643 - 644 - err = mfd_add_devices(&pdev->dev, -1, 645 - sta2x11_mfd_bar0, 646 - ARRAY_SIZE(sta2x11_mfd_bar0), 647 - &pdev->resource[0], 648 - 0, NULL); 649 - if (err) { 650 - dev_err(&pdev->dev, "mfd_add_devices[0] failed: %d\n", err); 651 - goto err_disable; 652 - } 653 - 654 - err = mfd_add_devices(&pdev->dev, -1, 655 - sta2x11_mfd_bar1, 656 - ARRAY_SIZE(sta2x11_mfd_bar1), 657 - &pdev->resource[1], 658 - 0, NULL); 659 - if (err) { 660 - dev_err(&pdev->dev, "mfd_add_devices[1] failed: %d\n", err); 661 - goto err_disable; 395 + /* Just 2 bars for all mfd's at present */ 396 + for (i = 0; i < 2; i++) { 397 + err = mfd_add_devices(&pdev->dev, -1, 398 + setup_data->bars[i].cells, 399 + setup_data->bars[i].ncells, 400 + &pdev->resource[i], 401 + 0, NULL); 402 + if (err) { 403 + dev_err(&pdev->dev, 404 + "mfd_add_devices[%d] failed: %d\n", i, err); 405 + goto err_disable; 406 + } 662 407 } 663 408 664 409 return 0; ··· 655 434 656 435 static DEFINE_PCI_DEVICE_TABLE(sta2x11_mfd_tbl) = { 657 436 {PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_GPIO)}, 437 + {PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_VIC)}, 658 438 {0,}, 659 439 }; 660 440 ··· 681 459 */ 682 460 subsys_initcall(sta2x11_apbreg_init); 683 461 subsys_initcall(sta2x11_sctl_init); 462 + subsys_initcall(sta2x11_apb_soc_regs_init); 463 + subsys_initcall(sta2x11_scr_init); 684 464 rootfs_initcall(sta2x11_mfd_init); 685 465 686 466 MODULE_LICENSE("GPL v2");
+5 -3
drivers/mfd/stmpe-i2c.c
··· 82 82 MODULE_DEVICE_TABLE(i2c, stmpe_id); 83 83 84 84 static struct i2c_driver stmpe_i2c_driver = { 85 - .driver.name = "stmpe-i2c", 86 - .driver.owner = THIS_MODULE, 85 + .driver = { 86 + .name = "stmpe-i2c", 87 + .owner = THIS_MODULE, 87 88 #ifdef CONFIG_PM 88 - .driver.pm = &stmpe_dev_pm_ops, 89 + .pm = &stmpe_dev_pm_ops, 89 90 #endif 91 + }, 90 92 .probe = stmpe_i2c_probe, 91 93 .remove = stmpe_i2c_remove, 92 94 .id_table = stmpe_i2c_id,
+121 -85
drivers/mfd/stmpe.c
··· 7 7 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson 8 8 */ 9 9 10 + #include <linux/err.h> 10 11 #include <linux/gpio.h> 11 12 #include <linux/export.h> 12 13 #include <linux/kernel.h> 13 14 #include <linux/interrupt.h> 14 15 #include <linux/irq.h> 16 + #include <linux/irqdomain.h> 17 + #include <linux/of.h> 18 + #include <linux/of_gpio.h> 15 19 #include <linux/pm.h> 16 20 #include <linux/slab.h> 17 21 #include <linux/mfd/core.h> ··· 316 312 static struct resource stmpe_keypad_resources[] = { 317 313 { 318 314 .name = "KEYPAD", 319 - .start = 0, 320 - .end = 0, 321 315 .flags = IORESOURCE_IRQ, 322 316 }, 323 317 { 324 318 .name = "KEYPAD_OVER", 325 - .start = 1, 326 - .end = 1, 327 319 .flags = IORESOURCE_IRQ, 328 320 }, 329 321 }; ··· 399 399 static struct resource stmpe_ts_resources[] = { 400 400 { 401 401 .name = "TOUCH_DET", 402 - .start = 0, 403 - .end = 0, 404 402 .flags = IORESOURCE_IRQ, 405 403 }, 406 404 { 407 405 .name = "FIFO_TH", 408 - .start = 1, 409 - .end = 1, 410 406 .flags = IORESOURCE_IRQ, 411 407 }, 412 408 }; ··· 524 528 static struct stmpe_variant_block stmpe1601_blocks[] = { 525 529 { 526 530 .cell = &stmpe_gpio_cell, 527 - .irq = STMPE24XX_IRQ_GPIOC, 531 + .irq = STMPE1601_IRQ_GPIOC, 528 532 .block = STMPE_BLOCK_GPIO, 529 533 }, 530 534 { 531 535 .cell = &stmpe_keypad_cell, 532 - .irq = STMPE24XX_IRQ_KEYPAD, 536 + .irq = STMPE1601_IRQ_KEYPAD, 533 537 .block = STMPE_BLOCK_KEYPAD, 534 538 }, 535 539 }; ··· 763 767 int i; 764 768 765 769 if (variant->id_val == STMPE801_ID) { 766 - handle_nested_irq(stmpe->irq_base); 770 + int base = irq_create_mapping(stmpe->domain, 0); 771 + 772 + handle_nested_irq(base); 767 773 return IRQ_HANDLED; 768 774 } 769 775 ··· 786 788 while (status) { 787 789 int bit = __ffs(status); 788 790 int line = bank * 8 + bit; 791 + int nestedirq = irq_create_mapping(stmpe->domain, line); 789 792 790 - handle_nested_irq(stmpe->irq_base + line); 793 + handle_nested_irq(nestedirq); 791 794 status &= ~(1 << bit); 792 795 } 793 796 ··· 829 830 static void stmpe_irq_mask(struct irq_data *data) 830 831 { 831 832 struct stmpe *stmpe = irq_data_get_irq_chip_data(data); 832 - int offset = data->irq - stmpe->irq_base; 833 + int offset = data->hwirq; 833 834 int regoffset = offset / 8; 834 835 int mask = 1 << (offset % 8); 835 836 ··· 839 840 static void stmpe_irq_unmask(struct irq_data *data) 840 841 { 841 842 struct stmpe *stmpe = irq_data_get_irq_chip_data(data); 842 - int offset = data->irq - stmpe->irq_base; 843 + int offset = data->hwirq; 843 844 int regoffset = offset / 8; 844 845 int mask = 1 << (offset % 8); 845 846 ··· 854 855 .irq_unmask = stmpe_irq_unmask, 855 856 }; 856 857 857 - static int __devinit stmpe_irq_init(struct stmpe *stmpe) 858 + static int stmpe_irq_map(struct irq_domain *d, unsigned int virq, 859 + irq_hw_number_t hwirq) 858 860 { 861 + struct stmpe *stmpe = d->host_data; 859 862 struct irq_chip *chip = NULL; 860 - int num_irqs = stmpe->variant->num_irqs; 861 - int base = stmpe->irq_base; 862 - int irq; 863 863 864 864 if (stmpe->variant->id_val != STMPE801_ID) 865 865 chip = &stmpe_irq_chip; 866 866 867 - for (irq = base; irq < base + num_irqs; irq++) { 868 - irq_set_chip_data(irq, stmpe); 869 - irq_set_chip_and_handler(irq, chip, handle_edge_irq); 870 - irq_set_nested_thread(irq, 1); 867 + irq_set_chip_data(virq, stmpe); 868 + irq_set_chip_and_handler(virq, chip, handle_edge_irq); 869 + irq_set_nested_thread(virq, 1); 871 870 #ifdef CONFIG_ARM 872 - set_irq_flags(irq, IRQF_VALID); 871 + set_irq_flags(virq, IRQF_VALID); 873 872 #else 874 - irq_set_noprobe(irq); 873 + irq_set_noprobe(virq); 875 874 #endif 876 - } 877 875 878 876 return 0; 879 877 } 880 878 881 - static void stmpe_irq_remove(struct stmpe *stmpe) 879 + static void stmpe_irq_unmap(struct irq_domain *d, unsigned int virq) 882 880 { 883 - int num_irqs = stmpe->variant->num_irqs; 884 - int base = stmpe->irq_base; 885 - int irq; 886 - 887 - for (irq = base; irq < base + num_irqs; irq++) { 888 881 #ifdef CONFIG_ARM 889 - set_irq_flags(irq, 0); 882 + set_irq_flags(virq, 0); 890 883 #endif 891 - irq_set_chip_and_handler(irq, NULL, NULL); 892 - irq_set_chip_data(irq, NULL); 884 + irq_set_chip_and_handler(virq, NULL, NULL); 885 + irq_set_chip_data(virq, NULL); 886 + } 887 + 888 + static struct irq_domain_ops stmpe_irq_ops = { 889 + .map = stmpe_irq_map, 890 + .unmap = stmpe_irq_unmap, 891 + .xlate = irq_domain_xlate_twocell, 892 + }; 893 + 894 + static int __devinit stmpe_irq_init(struct stmpe *stmpe, 895 + struct device_node *np) 896 + { 897 + int base = 0; 898 + int num_irqs = stmpe->variant->num_irqs; 899 + 900 + if (!np) 901 + base = stmpe->irq_base; 902 + 903 + stmpe->domain = irq_domain_add_simple(np, num_irqs, base, 904 + &stmpe_irq_ops, stmpe); 905 + if (!stmpe->domain) { 906 + dev_err(stmpe->dev, "Failed to create irqdomain\n"); 907 + return -ENOSYS; 893 908 } 909 + 910 + return 0; 894 911 } 895 912 896 913 static int __devinit stmpe_chip_init(struct stmpe *stmpe) ··· 957 942 else 958 943 icr |= STMPE_ICR_LSB_HIGH; 959 944 } 960 - 961 - if (stmpe->pdata->irq_invert_polarity) { 962 - if (id == STMPE801_ID) 963 - icr ^= STMPE801_REG_SYS_CTRL_INT_HI; 964 - else 965 - icr ^= STMPE_ICR_LSB_HIGH; 966 - } 967 945 } 968 946 969 947 if (stmpe->pdata->autosleep) { ··· 969 961 } 970 962 971 963 static int __devinit stmpe_add_device(struct stmpe *stmpe, 972 - struct mfd_cell *cell, int irq) 964 + struct mfd_cell *cell) 973 965 { 974 966 return mfd_add_devices(stmpe->dev, stmpe->pdata->id, cell, 1, 975 - NULL, stmpe->irq_base + irq, NULL); 967 + NULL, stmpe->irq_base, stmpe->domain); 976 968 } 977 969 978 970 static int __devinit stmpe_devices_init(struct stmpe *stmpe) ··· 980 972 struct stmpe_variant_info *variant = stmpe->variant; 981 973 unsigned int platform_blocks = stmpe->pdata->blocks; 982 974 int ret = -EINVAL; 983 - int i; 975 + int i, j; 984 976 985 977 for (i = 0; i < variant->num_blocks; i++) { 986 978 struct stmpe_variant_block *block = &variant->blocks[i]; ··· 988 980 if (!(platform_blocks & block->block)) 989 981 continue; 990 982 983 + for (j = 0; j < block->cell->num_resources; j++) { 984 + struct resource *res = 985 + (struct resource *) &block->cell->resources[j]; 986 + 987 + /* Dynamically fill in a variant's IRQ. */ 988 + if (res->flags & IORESOURCE_IRQ) 989 + res->start = res->end = block->irq + j; 990 + } 991 + 991 992 platform_blocks &= ~block->block; 992 - ret = stmpe_add_device(stmpe, block->cell, block->irq); 993 + ret = stmpe_add_device(stmpe, block->cell); 993 994 if (ret) 994 995 return ret; 995 996 } ··· 1011 994 return ret; 1012 995 } 1013 996 997 + void __devinit stmpe_of_probe(struct stmpe_platform_data *pdata, 998 + struct device_node *np) 999 + { 1000 + struct device_node *child; 1001 + 1002 + pdata->id = -1; 1003 + pdata->irq_trigger = IRQF_TRIGGER_NONE; 1004 + 1005 + of_property_read_u32(np, "st,autosleep-timeout", 1006 + &pdata->autosleep_timeout); 1007 + 1008 + pdata->autosleep = (pdata->autosleep_timeout) ? true : false; 1009 + 1010 + for_each_child_of_node(np, child) { 1011 + if (!strcmp(child->name, "stmpe_gpio")) { 1012 + pdata->blocks |= STMPE_BLOCK_GPIO; 1013 + } else if (!strcmp(child->name, "stmpe_keypad")) { 1014 + pdata->blocks |= STMPE_BLOCK_KEYPAD; 1015 + } else if (!strcmp(child->name, "stmpe_touchscreen")) { 1016 + pdata->blocks |= STMPE_BLOCK_TOUCHSCREEN; 1017 + } else if (!strcmp(child->name, "stmpe_adc")) { 1018 + pdata->blocks |= STMPE_BLOCK_ADC; 1019 + } else if (!strcmp(child->name, "stmpe_pwm")) { 1020 + pdata->blocks |= STMPE_BLOCK_PWM; 1021 + } else if (!strcmp(child->name, "stmpe_rotator")) { 1022 + pdata->blocks |= STMPE_BLOCK_ROTATOR; 1023 + } 1024 + } 1025 + } 1026 + 1014 1027 /* Called from client specific probe routines */ 1015 1028 int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum) 1016 1029 { 1017 1030 struct stmpe_platform_data *pdata = dev_get_platdata(ci->dev); 1031 + struct device_node *np = ci->dev->of_node; 1018 1032 struct stmpe *stmpe; 1019 1033 int ret; 1020 1034 1021 - if (!pdata) 1022 - return -EINVAL; 1035 + if (!pdata) { 1036 + if (!np) 1037 + return -EINVAL; 1023 1038 1024 - stmpe = kzalloc(sizeof(struct stmpe), GFP_KERNEL); 1039 + pdata = devm_kzalloc(ci->dev, sizeof(*pdata), GFP_KERNEL); 1040 + if (!pdata) 1041 + return -ENOMEM; 1042 + 1043 + stmpe_of_probe(pdata, np); 1044 + } 1045 + 1046 + stmpe = devm_kzalloc(ci->dev, sizeof(struct stmpe), GFP_KERNEL); 1025 1047 if (!stmpe) 1026 1048 return -ENOMEM; 1027 1049 ··· 1082 1026 ci->init(stmpe); 1083 1027 1084 1028 if (pdata->irq_over_gpio) { 1085 - ret = gpio_request_one(pdata->irq_gpio, GPIOF_DIR_IN, "stmpe"); 1029 + ret = devm_gpio_request_one(ci->dev, pdata->irq_gpio, 1030 + GPIOF_DIR_IN, "stmpe"); 1086 1031 if (ret) { 1087 1032 dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n", 1088 1033 ret); 1089 - goto out_free; 1034 + return ret; 1090 1035 } 1091 1036 1092 1037 stmpe->irq = gpio_to_irq(pdata->irq_gpio); ··· 1104 1047 dev_err(stmpe->dev, 1105 1048 "%s does not support no-irq mode!\n", 1106 1049 stmpe->variant->name); 1107 - ret = -ENODEV; 1108 - goto free_gpio; 1050 + return -ENODEV; 1109 1051 } 1110 1052 stmpe->variant = stmpe_noirq_variant_info[stmpe->partnum]; 1053 + } else if (pdata->irq_trigger == IRQF_TRIGGER_NONE) { 1054 + pdata->irq_trigger = 1055 + irqd_get_trigger_type(irq_get_irq_data(stmpe->irq)); 1111 1056 } 1112 1057 1113 1058 ret = stmpe_chip_init(stmpe); 1114 1059 if (ret) 1115 - goto free_gpio; 1060 + return ret; 1116 1061 1117 1062 if (stmpe->irq >= 0) { 1118 - ret = stmpe_irq_init(stmpe); 1063 + ret = stmpe_irq_init(stmpe, np); 1119 1064 if (ret) 1120 - goto free_gpio; 1065 + return ret; 1121 1066 1122 - ret = request_threaded_irq(stmpe->irq, NULL, stmpe_irq, 1123 - pdata->irq_trigger | IRQF_ONESHOT, 1067 + ret = devm_request_threaded_irq(ci->dev, stmpe->irq, NULL, 1068 + stmpe_irq, pdata->irq_trigger | IRQF_ONESHOT, 1124 1069 "stmpe", stmpe); 1125 1070 if (ret) { 1126 1071 dev_err(stmpe->dev, "failed to request IRQ: %d\n", 1127 1072 ret); 1128 - goto out_removeirq; 1073 + return ret; 1129 1074 } 1130 1075 } 1131 1076 1132 1077 ret = stmpe_devices_init(stmpe); 1133 - if (ret) { 1134 - dev_err(stmpe->dev, "failed to add children\n"); 1135 - goto out_removedevs; 1136 - } 1078 + if (!ret) 1079 + return 0; 1137 1080 1138 - return 0; 1139 - 1140 - out_removedevs: 1081 + dev_err(stmpe->dev, "failed to add children\n"); 1141 1082 mfd_remove_devices(stmpe->dev); 1142 - if (stmpe->irq >= 0) 1143 - free_irq(stmpe->irq, stmpe); 1144 - out_removeirq: 1145 - if (stmpe->irq >= 0) 1146 - stmpe_irq_remove(stmpe); 1147 - free_gpio: 1148 - if (pdata->irq_over_gpio) 1149 - gpio_free(pdata->irq_gpio); 1150 - out_free: 1151 - kfree(stmpe); 1083 + 1152 1084 return ret; 1153 1085 } 1154 1086 1155 1087 int stmpe_remove(struct stmpe *stmpe) 1156 1088 { 1157 1089 mfd_remove_devices(stmpe->dev); 1158 - 1159 - if (stmpe->irq >= 0) { 1160 - free_irq(stmpe->irq, stmpe); 1161 - stmpe_irq_remove(stmpe); 1162 - } 1163 - 1164 - if (stmpe->pdata->irq_over_gpio) 1165 - gpio_free(stmpe->pdata->irq_gpio); 1166 - 1167 - kfree(stmpe); 1168 1090 1169 1091 return 0; 1170 1092 }
+274
drivers/mfd/ti_am335x_tscadc.c
··· 1 + /* 2 + * TI Touch Screen / ADC MFD driver 3 + * 4 + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License as 8 + * published by the Free Software Foundation version 2. 9 + * 10 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 11 + * kind, whether express or implied; without even the implied warranty 12 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + */ 15 + 16 + #include <linux/module.h> 17 + #include <linux/init.h> 18 + #include <linux/slab.h> 19 + #include <linux/err.h> 20 + #include <linux/io.h> 21 + #include <linux/clk.h> 22 + #include <linux/regmap.h> 23 + #include <linux/mfd/core.h> 24 + #include <linux/pm_runtime.h> 25 + 26 + #include <linux/mfd/ti_am335x_tscadc.h> 27 + #include <linux/input/ti_am335x_tsc.h> 28 + #include <linux/platform_data/ti_am335x_adc.h> 29 + 30 + static unsigned int tscadc_readl(struct ti_tscadc_dev *tsadc, unsigned int reg) 31 + { 32 + unsigned int val; 33 + 34 + regmap_read(tsadc->regmap_tscadc, reg, &val); 35 + return val; 36 + } 37 + 38 + static void tscadc_writel(struct ti_tscadc_dev *tsadc, unsigned int reg, 39 + unsigned int val) 40 + { 41 + regmap_write(tsadc->regmap_tscadc, reg, val); 42 + } 43 + 44 + static const struct regmap_config tscadc_regmap_config = { 45 + .name = "ti_tscadc", 46 + .reg_bits = 32, 47 + .reg_stride = 4, 48 + .val_bits = 32, 49 + }; 50 + 51 + static void tscadc_idle_config(struct ti_tscadc_dev *config) 52 + { 53 + unsigned int idleconfig; 54 + 55 + idleconfig = STEPCONFIG_YNN | STEPCONFIG_INM_ADCREFM | 56 + STEPCONFIG_INP_ADCREFM | STEPCONFIG_YPN; 57 + 58 + tscadc_writel(config, REG_IDLECONFIG, idleconfig); 59 + } 60 + 61 + static int __devinit ti_tscadc_probe(struct platform_device *pdev) 62 + { 63 + struct ti_tscadc_dev *tscadc; 64 + struct resource *res; 65 + struct clk *clk; 66 + struct mfd_tscadc_board *pdata = pdev->dev.platform_data; 67 + struct mfd_cell *cell; 68 + int err, ctrl; 69 + int clk_value, clock_rate; 70 + int tsc_wires, adc_channels = 0, total_channels; 71 + 72 + if (!pdata) { 73 + dev_err(&pdev->dev, "Could not find platform data\n"); 74 + return -EINVAL; 75 + } 76 + 77 + if (pdata->adc_init) 78 + adc_channels = pdata->adc_init->adc_channels; 79 + 80 + tsc_wires = pdata->tsc_init->wires; 81 + total_channels = tsc_wires + adc_channels; 82 + 83 + if (total_channels > 8) { 84 + dev_err(&pdev->dev, "Number of i/p channels more than 8\n"); 85 + return -EINVAL; 86 + } 87 + 88 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 89 + if (!res) { 90 + dev_err(&pdev->dev, "no memory resource defined.\n"); 91 + return -EINVAL; 92 + } 93 + 94 + /* Allocate memory for device */ 95 + tscadc = devm_kzalloc(&pdev->dev, 96 + sizeof(struct ti_tscadc_dev), GFP_KERNEL); 97 + if (!tscadc) { 98 + dev_err(&pdev->dev, "failed to allocate memory.\n"); 99 + return -ENOMEM; 100 + } 101 + tscadc->dev = &pdev->dev; 102 + 103 + err = platform_get_irq(pdev, 0); 104 + if (err < 0) { 105 + dev_err(&pdev->dev, "no irq ID is specified.\n"); 106 + goto ret; 107 + } else 108 + tscadc->irq = err; 109 + 110 + res = devm_request_mem_region(&pdev->dev, 111 + res->start, resource_size(res), pdev->name); 112 + if (!res) { 113 + dev_err(&pdev->dev, "failed to reserve registers.\n"); 114 + return -EBUSY; 115 + } 116 + 117 + tscadc->tscadc_base = devm_ioremap(&pdev->dev, 118 + res->start, resource_size(res)); 119 + if (!tscadc->tscadc_base) { 120 + dev_err(&pdev->dev, "failed to map registers.\n"); 121 + return -ENOMEM; 122 + } 123 + 124 + tscadc->regmap_tscadc = devm_regmap_init_mmio(&pdev->dev, 125 + tscadc->tscadc_base, &tscadc_regmap_config); 126 + if (IS_ERR(tscadc->regmap_tscadc)) { 127 + dev_err(&pdev->dev, "regmap init failed\n"); 128 + err = PTR_ERR(tscadc->regmap_tscadc); 129 + goto ret; 130 + } 131 + 132 + pm_runtime_enable(&pdev->dev); 133 + pm_runtime_get_sync(&pdev->dev); 134 + 135 + /* 136 + * The TSC_ADC_Subsystem has 2 clock domains 137 + * OCP_CLK and ADC_CLK. 138 + * The ADC clock is expected to run at target of 3MHz, 139 + * and expected to capture 12-bit data at a rate of 200 KSPS. 140 + * The TSC_ADC_SS controller design assumes the OCP clock is 141 + * at least 6x faster than the ADC clock. 142 + */ 143 + clk = clk_get(&pdev->dev, "adc_tsc_fck"); 144 + if (IS_ERR(clk)) { 145 + dev_err(&pdev->dev, "failed to get TSC fck\n"); 146 + err = PTR_ERR(clk); 147 + goto err_disable_clk; 148 + } 149 + clock_rate = clk_get_rate(clk); 150 + clk_put(clk); 151 + clk_value = clock_rate / ADC_CLK; 152 + if (clk_value < MAX_CLK_DIV) { 153 + dev_err(&pdev->dev, "clock input less than min clock requirement\n"); 154 + err = -EINVAL; 155 + goto err_disable_clk; 156 + } 157 + /* TSCADC_CLKDIV needs to be configured to the value minus 1 */ 158 + clk_value = clk_value - 1; 159 + tscadc_writel(tscadc, REG_CLKDIV, clk_value); 160 + 161 + /* Set the control register bits */ 162 + ctrl = CNTRLREG_STEPCONFIGWRT | 163 + CNTRLREG_TSCENB | 164 + CNTRLREG_STEPID | 165 + CNTRLREG_4WIRE; 166 + tscadc_writel(tscadc, REG_CTRL, ctrl); 167 + 168 + /* Set register bits for Idle Config Mode */ 169 + tscadc_idle_config(tscadc); 170 + 171 + /* Enable the TSC module enable bit */ 172 + ctrl = tscadc_readl(tscadc, REG_CTRL); 173 + ctrl |= CNTRLREG_TSCSSENB; 174 + tscadc_writel(tscadc, REG_CTRL, ctrl); 175 + 176 + /* TSC Cell */ 177 + cell = &tscadc->cells[TSC_CELL]; 178 + cell->name = "tsc"; 179 + cell->platform_data = tscadc; 180 + cell->pdata_size = sizeof(*tscadc); 181 + 182 + /* ADC Cell */ 183 + cell = &tscadc->cells[ADC_CELL]; 184 + cell->name = "tiadc"; 185 + cell->platform_data = tscadc; 186 + cell->pdata_size = sizeof(*tscadc); 187 + 188 + err = mfd_add_devices(&pdev->dev, pdev->id, tscadc->cells, 189 + TSCADC_CELLS, NULL, 0, NULL); 190 + if (err < 0) 191 + goto err_disable_clk; 192 + 193 + device_init_wakeup(&pdev->dev, true); 194 + platform_set_drvdata(pdev, tscadc); 195 + 196 + return 0; 197 + 198 + err_disable_clk: 199 + pm_runtime_put_sync(&pdev->dev); 200 + pm_runtime_disable(&pdev->dev); 201 + ret: 202 + return err; 203 + } 204 + 205 + static int __devexit ti_tscadc_remove(struct platform_device *pdev) 206 + { 207 + struct ti_tscadc_dev *tscadc = platform_get_drvdata(pdev); 208 + 209 + tscadc_writel(tscadc, REG_SE, 0x00); 210 + 211 + pm_runtime_put_sync(&pdev->dev); 212 + pm_runtime_disable(&pdev->dev); 213 + 214 + mfd_remove_devices(tscadc->dev); 215 + 216 + return 0; 217 + } 218 + 219 + #ifdef CONFIG_PM 220 + static int tscadc_suspend(struct device *dev) 221 + { 222 + struct ti_tscadc_dev *tscadc_dev = dev_get_drvdata(dev); 223 + 224 + tscadc_writel(tscadc_dev, REG_SE, 0x00); 225 + pm_runtime_put_sync(dev); 226 + 227 + return 0; 228 + } 229 + 230 + static int tscadc_resume(struct device *dev) 231 + { 232 + struct ti_tscadc_dev *tscadc_dev = dev_get_drvdata(dev); 233 + unsigned int restore, ctrl; 234 + 235 + pm_runtime_get_sync(dev); 236 + 237 + /* context restore */ 238 + ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_TSCENB | 239 + CNTRLREG_STEPID | CNTRLREG_4WIRE; 240 + tscadc_writel(tscadc_dev, REG_CTRL, ctrl); 241 + tscadc_idle_config(tscadc_dev); 242 + tscadc_writel(tscadc_dev, REG_SE, STPENB_STEPENB); 243 + restore = tscadc_readl(tscadc_dev, REG_CTRL); 244 + tscadc_writel(tscadc_dev, REG_CTRL, 245 + (restore | CNTRLREG_TSCSSENB)); 246 + 247 + return 0; 248 + } 249 + 250 + static const struct dev_pm_ops tscadc_pm_ops = { 251 + .suspend = tscadc_suspend, 252 + .resume = tscadc_resume, 253 + }; 254 + #define TSCADC_PM_OPS (&tscadc_pm_ops) 255 + #else 256 + #define TSCADC_PM_OPS NULL 257 + #endif 258 + 259 + static struct platform_driver ti_tscadc_driver = { 260 + .driver = { 261 + .name = "ti_tscadc", 262 + .owner = THIS_MODULE, 263 + .pm = TSCADC_PM_OPS, 264 + }, 265 + .probe = ti_tscadc_probe, 266 + .remove = __devexit_p(ti_tscadc_remove), 267 + 268 + }; 269 + 270 + module_platform_driver(ti_tscadc_driver); 271 + 272 + MODULE_DESCRIPTION("TI touchscreen / ADC MFD controller driver"); 273 + MODULE_AUTHOR("Rachna Patil <rachna@ti.com>"); 274 + MODULE_LICENSE("GPL");
+4 -17
drivers/mfd/tps6507x.c
··· 86 86 const struct i2c_device_id *id) 87 87 { 88 88 struct tps6507x_dev *tps6507x; 89 - int ret = 0; 90 89 91 - tps6507x = kzalloc(sizeof(struct tps6507x_dev), GFP_KERNEL); 90 + tps6507x = devm_kzalloc(&i2c->dev, sizeof(struct tps6507x_dev), 91 + GFP_KERNEL); 92 92 if (tps6507x == NULL) 93 93 return -ENOMEM; 94 94 ··· 98 98 tps6507x->read_dev = tps6507x_i2c_read_device; 99 99 tps6507x->write_dev = tps6507x_i2c_write_device; 100 100 101 - ret = mfd_add_devices(tps6507x->dev, -1, 102 - tps6507x_devs, ARRAY_SIZE(tps6507x_devs), 103 - NULL, 0, NULL); 104 - 105 - if (ret < 0) 106 - goto err; 107 - 108 - return ret; 109 - 110 - err: 111 - mfd_remove_devices(tps6507x->dev); 112 - kfree(tps6507x); 113 - return ret; 101 + return mfd_add_devices(tps6507x->dev, -1, tps6507x_devs, 102 + ARRAY_SIZE(tps6507x_devs), NULL, 0, NULL); 114 103 } 115 104 116 105 static int tps6507x_i2c_remove(struct i2c_client *i2c) ··· 107 118 struct tps6507x_dev *tps6507x = i2c_get_clientdata(i2c); 108 119 109 120 mfd_remove_devices(tps6507x->dev); 110 - kfree(tps6507x); 111 - 112 121 return 0; 113 122 } 114 123
+104 -208
drivers/mfd/tps65090.c
··· 25 25 #include <linux/i2c.h> 26 26 #include <linux/mfd/core.h> 27 27 #include <linux/mfd/tps65090.h> 28 - #include <linux/regmap.h> 29 28 #include <linux/err.h> 30 29 31 30 #define NUM_INT_REG 2 ··· 38 39 #define TPS65090_INT_MSK 0x2 39 40 #define TPS65090_INT_MSK2 0x3 40 41 41 - struct tps65090_irq_data { 42 - u8 mask_reg; 43 - u8 mask_pos; 44 - }; 45 - 46 - #define TPS65090_IRQ(_reg, _mask_pos) \ 47 - { \ 48 - .mask_reg = (_reg), \ 49 - .mask_pos = (_mask_pos), \ 50 - } 51 - 52 - static const struct tps65090_irq_data tps65090_irqs[] = { 53 - [0] = TPS65090_IRQ(0, 0), 54 - [1] = TPS65090_IRQ(0, 1), 55 - [2] = TPS65090_IRQ(0, 2), 56 - [3] = TPS65090_IRQ(0, 3), 57 - [4] = TPS65090_IRQ(0, 4), 58 - [5] = TPS65090_IRQ(0, 5), 59 - [6] = TPS65090_IRQ(0, 6), 60 - [7] = TPS65090_IRQ(0, 7), 61 - [8] = TPS65090_IRQ(1, 0), 62 - [9] = TPS65090_IRQ(1, 1), 63 - [10] = TPS65090_IRQ(1, 2), 64 - [11] = TPS65090_IRQ(1, 3), 65 - [12] = TPS65090_IRQ(1, 4), 66 - [13] = TPS65090_IRQ(1, 5), 67 - [14] = TPS65090_IRQ(1, 6), 68 - [15] = TPS65090_IRQ(1, 7), 69 - }; 42 + #define TPS65090_INT1_MASK_VAC_STATUS_CHANGE 1 43 + #define TPS65090_INT1_MASK_VSYS_STATUS_CHANGE 2 44 + #define TPS65090_INT1_MASK_BAT_STATUS_CHANGE 3 45 + #define TPS65090_INT1_MASK_CHARGING_STATUS_CHANGE 4 46 + #define TPS65090_INT1_MASK_CHARGING_COMPLETE 5 47 + #define TPS65090_INT1_MASK_OVERLOAD_DCDC1 6 48 + #define TPS65090_INT1_MASK_OVERLOAD_DCDC2 7 49 + #define TPS65090_INT2_MASK_OVERLOAD_DCDC3 0 50 + #define TPS65090_INT2_MASK_OVERLOAD_FET1 1 51 + #define TPS65090_INT2_MASK_OVERLOAD_FET2 2 52 + #define TPS65090_INT2_MASK_OVERLOAD_FET3 3 53 + #define TPS65090_INT2_MASK_OVERLOAD_FET4 4 54 + #define TPS65090_INT2_MASK_OVERLOAD_FET5 5 55 + #define TPS65090_INT2_MASK_OVERLOAD_FET6 6 56 + #define TPS65090_INT2_MASK_OVERLOAD_FET7 7 70 57 71 58 static struct mfd_cell tps65090s[] = { 72 59 { 73 60 .name = "tps65090-pmic", 74 61 }, 75 62 { 76 - .name = "tps65090-regulator", 63 + .name = "tps65090-charger", 77 64 }, 78 65 }; 79 66 80 - int tps65090_write(struct device *dev, int reg, uint8_t val) 81 - { 82 - struct tps65090 *tps = dev_get_drvdata(dev); 83 - return regmap_write(tps->rmap, reg, val); 84 - } 85 - EXPORT_SYMBOL_GPL(tps65090_write); 67 + static const struct regmap_irq tps65090_irqs[] = { 68 + /* INT1 IRQs*/ 69 + [TPS65090_IRQ_VAC_STATUS_CHANGE] = { 70 + .mask = TPS65090_INT1_MASK_VAC_STATUS_CHANGE, 71 + }, 72 + [TPS65090_IRQ_VSYS_STATUS_CHANGE] = { 73 + .mask = TPS65090_INT1_MASK_VSYS_STATUS_CHANGE, 74 + }, 75 + [TPS65090_IRQ_BAT_STATUS_CHANGE] = { 76 + .mask = TPS65090_INT1_MASK_BAT_STATUS_CHANGE, 77 + }, 78 + [TPS65090_IRQ_CHARGING_STATUS_CHANGE] = { 79 + .mask = TPS65090_INT1_MASK_CHARGING_STATUS_CHANGE, 80 + }, 81 + [TPS65090_IRQ_CHARGING_COMPLETE] = { 82 + .mask = TPS65090_INT1_MASK_CHARGING_COMPLETE, 83 + }, 84 + [TPS65090_IRQ_OVERLOAD_DCDC1] = { 85 + .mask = TPS65090_INT1_MASK_OVERLOAD_DCDC1, 86 + }, 87 + [TPS65090_IRQ_OVERLOAD_DCDC2] = { 88 + .mask = TPS65090_INT1_MASK_OVERLOAD_DCDC2, 89 + }, 90 + /* INT2 IRQs*/ 91 + [TPS65090_IRQ_OVERLOAD_DCDC3] = { 92 + .reg_offset = 1, 93 + .mask = TPS65090_INT2_MASK_OVERLOAD_DCDC3, 94 + }, 95 + [TPS65090_IRQ_OVERLOAD_FET1] = { 96 + .reg_offset = 1, 97 + .mask = TPS65090_INT2_MASK_OVERLOAD_FET1, 98 + }, 99 + [TPS65090_IRQ_OVERLOAD_FET2] = { 100 + .reg_offset = 1, 101 + .mask = TPS65090_INT2_MASK_OVERLOAD_FET2, 102 + }, 103 + [TPS65090_IRQ_OVERLOAD_FET3] = { 104 + .reg_offset = 1, 105 + .mask = TPS65090_INT2_MASK_OVERLOAD_FET3, 106 + }, 107 + [TPS65090_IRQ_OVERLOAD_FET4] = { 108 + .reg_offset = 1, 109 + .mask = TPS65090_INT2_MASK_OVERLOAD_FET4, 110 + }, 111 + [TPS65090_IRQ_OVERLOAD_FET5] = { 112 + .reg_offset = 1, 113 + .mask = TPS65090_INT2_MASK_OVERLOAD_FET5, 114 + }, 115 + [TPS65090_IRQ_OVERLOAD_FET6] = { 116 + .reg_offset = 1, 117 + .mask = TPS65090_INT2_MASK_OVERLOAD_FET6, 118 + }, 119 + [TPS65090_IRQ_OVERLOAD_FET7] = { 120 + .reg_offset = 1, 121 + .mask = TPS65090_INT2_MASK_OVERLOAD_FET7, 122 + }, 123 + }; 86 124 87 - int tps65090_read(struct device *dev, int reg, uint8_t *val) 88 - { 89 - struct tps65090 *tps = dev_get_drvdata(dev); 90 - unsigned int temp_val; 91 - int ret; 92 - ret = regmap_read(tps->rmap, reg, &temp_val); 93 - if (!ret) 94 - *val = temp_val; 95 - return ret; 96 - } 97 - EXPORT_SYMBOL_GPL(tps65090_read); 98 - 99 - int tps65090_set_bits(struct device *dev, int reg, uint8_t bit_num) 100 - { 101 - struct tps65090 *tps = dev_get_drvdata(dev); 102 - return regmap_update_bits(tps->rmap, reg, BIT(bit_num), ~0u); 103 - } 104 - EXPORT_SYMBOL_GPL(tps65090_set_bits); 105 - 106 - int tps65090_clr_bits(struct device *dev, int reg, uint8_t bit_num) 107 - { 108 - struct tps65090 *tps = dev_get_drvdata(dev); 109 - return regmap_update_bits(tps->rmap, reg, BIT(bit_num), 0u); 110 - } 111 - EXPORT_SYMBOL_GPL(tps65090_clr_bits); 112 - 113 - static void tps65090_irq_lock(struct irq_data *data) 114 - { 115 - struct tps65090 *tps65090 = irq_data_get_irq_chip_data(data); 116 - 117 - mutex_lock(&tps65090->irq_lock); 118 - } 119 - 120 - static void tps65090_irq_mask(struct irq_data *irq_data) 121 - { 122 - struct tps65090 *tps65090 = irq_data_get_irq_chip_data(irq_data); 123 - unsigned int __irq = irq_data->hwirq; 124 - const struct tps65090_irq_data *data = &tps65090_irqs[__irq]; 125 - 126 - tps65090_set_bits(tps65090->dev, (TPS65090_INT_MSK + data->mask_reg), 127 - data->mask_pos); 128 - } 129 - 130 - static void tps65090_irq_unmask(struct irq_data *irq_data) 131 - { 132 - struct tps65090 *tps65090 = irq_data_get_irq_chip_data(irq_data); 133 - unsigned int __irq = irq_data->irq - tps65090->irq_base; 134 - const struct tps65090_irq_data *data = &tps65090_irqs[__irq]; 135 - 136 - tps65090_clr_bits(tps65090->dev, (TPS65090_INT_MSK + data->mask_reg), 137 - data->mask_pos); 138 - } 139 - 140 - static void tps65090_irq_sync_unlock(struct irq_data *data) 141 - { 142 - struct tps65090 *tps65090 = irq_data_get_irq_chip_data(data); 143 - 144 - mutex_unlock(&tps65090->irq_lock); 145 - } 146 - 147 - static irqreturn_t tps65090_irq(int irq, void *data) 148 - { 149 - struct tps65090 *tps65090 = data; 150 - int ret = 0; 151 - u8 status, mask; 152 - unsigned long int acks = 0; 153 - int i; 154 - 155 - for (i = 0; i < NUM_INT_REG; i++) { 156 - ret = tps65090_read(tps65090->dev, TPS65090_INT_MSK + i, &mask); 157 - if (ret < 0) { 158 - dev_err(tps65090->dev, 159 - "failed to read mask reg [addr:%d]\n", 160 - TPS65090_INT_MSK + i); 161 - return IRQ_NONE; 162 - } 163 - ret = tps65090_read(tps65090->dev, TPS65090_INT_STS + i, 164 - &status); 165 - if (ret < 0) { 166 - dev_err(tps65090->dev, 167 - "failed to read status reg [addr:%d]\n", 168 - TPS65090_INT_STS + i); 169 - return IRQ_NONE; 170 - } 171 - if (status) { 172 - /* Ack only those interrupts which are not masked */ 173 - status &= (~mask); 174 - ret = tps65090_write(tps65090->dev, 175 - TPS65090_INT_STS + i, status); 176 - if (ret < 0) { 177 - dev_err(tps65090->dev, 178 - "failed to write interrupt status\n"); 179 - return IRQ_NONE; 180 - } 181 - acks |= (status << (i * 8)); 182 - } 183 - } 184 - 185 - for_each_set_bit(i, &acks, ARRAY_SIZE(tps65090_irqs)) 186 - handle_nested_irq(tps65090->irq_base + i); 187 - return acks ? IRQ_HANDLED : IRQ_NONE; 188 - } 189 - 190 - static int tps65090_irq_init(struct tps65090 *tps65090, int irq, 191 - int irq_base) 192 - { 193 - int i, ret; 194 - 195 - if (!irq_base) { 196 - dev_err(tps65090->dev, "IRQ base not set\n"); 197 - return -EINVAL; 198 - } 199 - 200 - mutex_init(&tps65090->irq_lock); 201 - 202 - for (i = 0; i < NUM_INT_REG; i++) 203 - tps65090_write(tps65090->dev, TPS65090_INT_MSK + i, 0xFF); 204 - 205 - for (i = 0; i < NUM_INT_REG; i++) 206 - tps65090_write(tps65090->dev, TPS65090_INT_STS + i, 0xff); 207 - 208 - tps65090->irq_base = irq_base; 209 - tps65090->irq_chip.name = "tps65090"; 210 - tps65090->irq_chip.irq_mask = tps65090_irq_mask; 211 - tps65090->irq_chip.irq_unmask = tps65090_irq_unmask; 212 - tps65090->irq_chip.irq_bus_lock = tps65090_irq_lock; 213 - tps65090->irq_chip.irq_bus_sync_unlock = tps65090_irq_sync_unlock; 214 - 215 - for (i = 0; i < ARRAY_SIZE(tps65090_irqs); i++) { 216 - int __irq = i + tps65090->irq_base; 217 - irq_set_chip_data(__irq, tps65090); 218 - irq_set_chip_and_handler(__irq, &tps65090->irq_chip, 219 - handle_simple_irq); 220 - irq_set_nested_thread(__irq, 1); 221 - #ifdef CONFIG_ARM 222 - set_irq_flags(__irq, IRQF_VALID); 223 - #endif 224 - } 225 - 226 - ret = request_threaded_irq(irq, NULL, tps65090_irq, IRQF_ONESHOT, 227 - "tps65090", tps65090); 228 - if (!ret) { 229 - device_init_wakeup(tps65090->dev, 1); 230 - enable_irq_wake(irq); 231 - } 232 - 233 - return ret; 234 - } 125 + static struct regmap_irq_chip tps65090_irq_chip = { 126 + .name = "tps65090", 127 + .irqs = tps65090_irqs, 128 + .num_irqs = ARRAY_SIZE(tps65090_irqs), 129 + .num_regs = NUM_INT_REG, 130 + .status_base = TPS65090_INT_STS, 131 + .mask_base = TPS65090_INT_MSK, 132 + .mask_invert = true, 133 + }; 235 134 236 135 static bool is_volatile_reg(struct device *dev, unsigned int reg) 237 136 { 238 - if (reg == TPS65090_INT_STS) 137 + if ((reg == TPS65090_INT_STS) || (reg == TPS65090_INT_STS2)) 239 138 return true; 240 139 else 241 140 return false; ··· 160 263 return -EINVAL; 161 264 } 162 265 163 - tps65090 = devm_kzalloc(&client->dev, sizeof(struct tps65090), 164 - GFP_KERNEL); 165 - if (tps65090 == NULL) 266 + tps65090 = devm_kzalloc(&client->dev, sizeof(*tps65090), GFP_KERNEL); 267 + if (!tps65090) { 268 + dev_err(&client->dev, "mem alloc for tps65090 failed\n"); 166 269 return -ENOMEM; 270 + } 167 271 168 - tps65090->client = client; 169 272 tps65090->dev = &client->dev; 170 273 i2c_set_clientdata(client, tps65090); 171 274 172 - mutex_init(&tps65090->lock); 173 - 174 - if (client->irq) { 175 - ret = tps65090_irq_init(tps65090, client->irq, pdata->irq_base); 176 - if (ret) { 177 - dev_err(&client->dev, "IRQ init failed with err: %d\n", 178 - ret); 179 - goto err_exit; 180 - } 181 - } 182 - 183 - tps65090->rmap = devm_regmap_init_i2c(tps65090->client, 184 - &tps65090_regmap_config); 275 + tps65090->rmap = devm_regmap_init_i2c(client, &tps65090_regmap_config); 185 276 if (IS_ERR(tps65090->rmap)) { 186 277 ret = PTR_ERR(tps65090->rmap); 187 278 dev_err(&client->dev, "regmap_init failed with err: %d\n", ret); 188 - goto err_irq_exit; 279 + return ret; 280 + } 281 + 282 + if (client->irq) { 283 + ret = regmap_add_irq_chip(tps65090->rmap, client->irq, 284 + IRQF_ONESHOT | IRQF_TRIGGER_LOW, pdata->irq_base, 285 + &tps65090_irq_chip, &tps65090->irq_data); 286 + if (ret) { 287 + dev_err(&client->dev, 288 + "IRQ init failed with err: %d\n", ret); 289 + return ret; 290 + } 189 291 } 190 292 191 293 ret = mfd_add_devices(tps65090->dev, -1, tps65090s, 192 - ARRAY_SIZE(tps65090s), NULL, 0, NULL); 294 + ARRAY_SIZE(tps65090s), NULL, 295 + regmap_irq_chip_get_base(tps65090->irq_data), NULL); 193 296 if (ret) { 194 297 dev_err(&client->dev, "add mfd devices failed with err: %d\n", 195 298 ret); ··· 200 303 201 304 err_irq_exit: 202 305 if (client->irq) 203 - free_irq(client->irq, tps65090); 204 - err_exit: 306 + regmap_del_irq_chip(client->irq, tps65090->irq_data); 205 307 return ret; 206 308 } 207 309 ··· 210 314 211 315 mfd_remove_devices(tps65090->dev); 212 316 if (client->irq) 213 - free_irq(client->irq, tps65090); 317 + regmap_del_irq_chip(client->irq, tps65090->irq_data); 214 318 215 319 return 0; 216 320 }
+12
drivers/mfd/tps65217.c
··· 160 160 unsigned int version; 161 161 unsigned int chip_id = ids->driver_data; 162 162 const struct of_device_id *match; 163 + bool status_off = false; 163 164 int ret; 164 165 165 166 if (client->dev.of_node) { ··· 171 170 return -EINVAL; 172 171 } 173 172 chip_id = (unsigned int)match->data; 173 + status_off = of_property_read_bool(client->dev.of_node, 174 + "ti,pmic-shutdown-controller"); 174 175 } 175 176 176 177 if (!chip_id) { ··· 208 205 dev_err(tps->dev, "Failed to read revision register: %d\n", 209 206 ret); 210 207 return ret; 208 + } 209 + 210 + /* Set the PMIC to shutdown on PWR_EN toggle */ 211 + if (status_off) { 212 + ret = tps65217_set_bits(tps, TPS65217_REG_STATUS, 213 + TPS65217_STATUS_OFF, TPS65217_STATUS_OFF, 214 + TPS65217_PROTECT_NONE); 215 + if (ret) 216 + dev_warn(tps->dev, "unable to set the status OFF\n"); 211 217 } 212 218 213 219 dev_info(tps->dev, "TPS65217 ID %#x version 1.%d\n",
+77 -26
drivers/mfd/tps6586x.c
··· 17 17 18 18 #include <linux/interrupt.h> 19 19 #include <linux/irq.h> 20 + #include <linux/irqdomain.h> 20 21 #include <linux/kernel.h> 21 22 #include <linux/module.h> 22 23 #include <linux/mutex.h> 23 24 #include <linux/slab.h> 24 25 #include <linux/err.h> 25 26 #include <linux/i2c.h> 27 + #include <linux/platform_device.h> 26 28 #include <linux/regmap.h> 27 29 28 30 #include <linux/mfd/core.h> ··· 94 92 [TPS6586X_INT_RTC_ALM2] = TPS6586X_IRQ(TPS6586X_INT_MASK4, 1 << 1), 95 93 }; 96 94 95 + static struct resource tps6586x_rtc_resources[] = { 96 + { 97 + .start = TPS6586X_INT_RTC_ALM1, 98 + .end = TPS6586X_INT_RTC_ALM1, 99 + .flags = IORESOURCE_IRQ, 100 + }, 101 + }; 102 + 97 103 static struct mfd_cell tps6586x_cell[] = { 98 104 { 99 105 .name = "tps6586x-gpio", ··· 111 101 }, 112 102 { 113 103 .name = "tps6586x-rtc", 104 + .num_resources = ARRAY_SIZE(tps6586x_rtc_resources), 105 + .resources = &tps6586x_rtc_resources[0], 114 106 }, 115 107 { 116 108 .name = "tps6586x-onkey", ··· 129 117 int irq_base; 130 118 u32 irq_en; 131 119 u8 mask_reg[5]; 120 + struct irq_domain *irq_domain; 132 121 }; 133 122 134 123 static inline struct tps6586x *dev_to_tps6586x(struct device *dev) ··· 198 185 } 199 186 EXPORT_SYMBOL_GPL(tps6586x_update); 200 187 188 + int tps6586x_irq_get_virq(struct device *dev, int irq) 189 + { 190 + struct tps6586x *tps6586x = dev_to_tps6586x(dev); 191 + 192 + return irq_create_mapping(tps6586x->irq_domain, irq); 193 + } 194 + EXPORT_SYMBOL_GPL(tps6586x_irq_get_virq); 195 + 201 196 static int __remove_subdev(struct device *dev, void *unused) 202 197 { 203 198 platform_device_unregister(to_platform_device(dev)); ··· 227 206 static void tps6586x_irq_enable(struct irq_data *irq_data) 228 207 { 229 208 struct tps6586x *tps6586x = irq_data_get_irq_chip_data(irq_data); 230 - unsigned int __irq = irq_data->irq - tps6586x->irq_base; 209 + unsigned int __irq = irq_data->hwirq; 231 210 const struct tps6586x_irq_data *data = &tps6586x_irqs[__irq]; 232 211 233 212 tps6586x->mask_reg[data->mask_reg] &= ~data->mask_mask; ··· 238 217 { 239 218 struct tps6586x *tps6586x = irq_data_get_irq_chip_data(irq_data); 240 219 241 - unsigned int __irq = irq_data->irq - tps6586x->irq_base; 220 + unsigned int __irq = irq_data->hwirq; 242 221 const struct tps6586x_irq_data *data = &tps6586x_irqs[__irq]; 243 222 244 223 tps6586x->mask_reg[data->mask_reg] |= data->mask_mask; ··· 261 240 mutex_unlock(&tps6586x->irq_lock); 262 241 } 263 242 243 + static struct irq_chip tps6586x_irq_chip = { 244 + .name = "tps6586x", 245 + .irq_bus_lock = tps6586x_irq_lock, 246 + .irq_bus_sync_unlock = tps6586x_irq_sync_unlock, 247 + .irq_disable = tps6586x_irq_disable, 248 + .irq_enable = tps6586x_irq_enable, 249 + }; 250 + 251 + static int tps6586x_irq_map(struct irq_domain *h, unsigned int virq, 252 + irq_hw_number_t hw) 253 + { 254 + struct tps6586x *tps6586x = h->host_data; 255 + 256 + irq_set_chip_data(virq, tps6586x); 257 + irq_set_chip_and_handler(virq, &tps6586x_irq_chip, handle_simple_irq); 258 + irq_set_nested_thread(virq, 1); 259 + 260 + /* ARM needs us to explicitly flag the IRQ as valid 261 + * and will set them noprobe when we do so. */ 262 + #ifdef CONFIG_ARM 263 + set_irq_flags(virq, IRQF_VALID); 264 + #else 265 + irq_set_noprobe(virq); 266 + #endif 267 + 268 + return 0; 269 + } 270 + 271 + static struct irq_domain_ops tps6586x_domain_ops = { 272 + .map = tps6586x_irq_map, 273 + .xlate = irq_domain_xlate_twocell, 274 + }; 275 + 264 276 static irqreturn_t tps6586x_irq(int irq, void *data) 265 277 { 266 278 struct tps6586x *tps6586x = data; ··· 314 260 int i = __ffs(acks); 315 261 316 262 if (tps6586x->irq_en & (1 << i)) 317 - handle_nested_irq(tps6586x->irq_base + i); 263 + handle_nested_irq( 264 + irq_find_mapping(tps6586x->irq_domain, i)); 318 265 319 266 acks &= ~(1 << i); 320 267 } ··· 328 273 { 329 274 int i, ret; 330 275 u8 tmp[4]; 331 - 332 - if (!irq_base) { 333 - dev_warn(tps6586x->dev, "No interrupt support on IRQ base\n"); 334 - return -EINVAL; 335 - } 276 + int new_irq_base; 277 + int irq_num = ARRAY_SIZE(tps6586x_irqs); 336 278 337 279 mutex_init(&tps6586x->irq_lock); 338 280 for (i = 0; i < 5; i++) { ··· 339 287 340 288 tps6586x_reads(tps6586x->dev, TPS6586X_INT_ACK1, sizeof(tmp), tmp); 341 289 342 - tps6586x->irq_base = irq_base; 343 - 344 - tps6586x->irq_chip.name = "tps6586x"; 345 - tps6586x->irq_chip.irq_enable = tps6586x_irq_enable; 346 - tps6586x->irq_chip.irq_disable = tps6586x_irq_disable; 347 - tps6586x->irq_chip.irq_bus_lock = tps6586x_irq_lock; 348 - tps6586x->irq_chip.irq_bus_sync_unlock = tps6586x_irq_sync_unlock; 349 - 350 - for (i = 0; i < ARRAY_SIZE(tps6586x_irqs); i++) { 351 - int __irq = i + tps6586x->irq_base; 352 - irq_set_chip_data(__irq, tps6586x); 353 - irq_set_chip_and_handler(__irq, &tps6586x->irq_chip, 354 - handle_simple_irq); 355 - irq_set_nested_thread(__irq, 1); 356 - #ifdef CONFIG_ARM 357 - set_irq_flags(__irq, IRQF_VALID); 358 - #endif 290 + if (irq_base > 0) { 291 + new_irq_base = irq_alloc_descs(irq_base, 0, irq_num, -1); 292 + if (new_irq_base < 0) { 293 + dev_err(tps6586x->dev, 294 + "Failed to alloc IRQs: %d\n", new_irq_base); 295 + return new_irq_base; 296 + } 297 + } else { 298 + new_irq_base = 0; 359 299 } 360 300 301 + tps6586x->irq_domain = irq_domain_add_simple(tps6586x->dev->of_node, 302 + irq_num, new_irq_base, &tps6586x_domain_ops, 303 + tps6586x); 304 + if (!tps6586x->irq_domain) { 305 + dev_err(tps6586x->dev, "Failed to create IRQ domain\n"); 306 + return -ENOMEM; 307 + } 361 308 ret = request_threaded_irq(irq, NULL, tps6586x_irq, IRQF_ONESHOT, 362 309 "tps6586x", tps6586x); 363 310 ··· 512 461 513 462 ret = mfd_add_devices(tps6586x->dev, -1, 514 463 tps6586x_cell, ARRAY_SIZE(tps6586x_cell), 515 - NULL, 0, NULL); 464 + NULL, 0, tps6586x->irq_domain); 516 465 if (ret < 0) { 517 466 dev_err(&client->dev, "mfd_add_devices failed: %d\n", ret); 518 467 goto err_mfd_add;
-260
drivers/mfd/tps65910-irq.c
··· 1 - /* 2 - * tps65910-irq.c -- TI TPS6591x 3 - * 4 - * Copyright 2010 Texas Instruments Inc. 5 - * 6 - * Author: Graeme Gregory <gg@slimlogic.co.uk> 7 - * Author: Jorge Eduardo Candelaria <jedu@slimlogic.co.uk> 8 - * 9 - * This program is free software; you can redistribute it and/or modify it 10 - * under the terms of the GNU General Public License as published by the 11 - * Free Software Foundation; either version 2 of the License, or (at your 12 - * option) any later version. 13 - * 14 - */ 15 - 16 - #include <linux/kernel.h> 17 - #include <linux/module.h> 18 - #include <linux/init.h> 19 - #include <linux/bug.h> 20 - #include <linux/device.h> 21 - #include <linux/interrupt.h> 22 - #include <linux/irq.h> 23 - #include <linux/irqdomain.h> 24 - #include <linux/gpio.h> 25 - #include <linux/mfd/tps65910.h> 26 - 27 - /* 28 - * This is a threaded IRQ handler so can access I2C/SPI. Since all 29 - * interrupts are clear on read the IRQ line will be reasserted and 30 - * the physical IRQ will be handled again if another interrupt is 31 - * asserted while we run - in the normal course of events this is a 32 - * rare occurrence so we save I2C/SPI reads. We're also assuming that 33 - * it's rare to get lots of interrupts firing simultaneously so try to 34 - * minimise I/O. 35 - */ 36 - static irqreturn_t tps65910_irq(int irq, void *irq_data) 37 - { 38 - struct tps65910 *tps65910 = irq_data; 39 - unsigned int reg; 40 - u32 irq_sts; 41 - u32 irq_mask; 42 - int i; 43 - 44 - tps65910_reg_read(tps65910, TPS65910_INT_STS, &reg); 45 - irq_sts = reg; 46 - tps65910_reg_read(tps65910, TPS65910_INT_STS2, &reg); 47 - irq_sts |= reg << 8; 48 - switch (tps65910_chip_id(tps65910)) { 49 - case TPS65911: 50 - tps65910_reg_read(tps65910, TPS65910_INT_STS3, &reg); 51 - irq_sts |= reg << 16; 52 - } 53 - 54 - tps65910_reg_read(tps65910, TPS65910_INT_MSK, &reg); 55 - irq_mask = reg; 56 - tps65910_reg_read(tps65910, TPS65910_INT_MSK2, &reg); 57 - irq_mask |= reg << 8; 58 - switch (tps65910_chip_id(tps65910)) { 59 - case TPS65911: 60 - tps65910_reg_read(tps65910, TPS65910_INT_MSK3, &reg); 61 - irq_mask |= reg << 16; 62 - } 63 - 64 - irq_sts &= ~irq_mask; 65 - 66 - if (!irq_sts) 67 - return IRQ_NONE; 68 - 69 - for (i = 0; i < tps65910->irq_num; i++) { 70 - 71 - if (!(irq_sts & (1 << i))) 72 - continue; 73 - 74 - handle_nested_irq(irq_find_mapping(tps65910->domain, i)); 75 - } 76 - 77 - /* Write the STS register back to clear IRQs we handled */ 78 - reg = irq_sts & 0xFF; 79 - irq_sts >>= 8; 80 - tps65910_reg_write(tps65910, TPS65910_INT_STS, reg); 81 - reg = irq_sts & 0xFF; 82 - tps65910_reg_write(tps65910, TPS65910_INT_STS2, reg); 83 - switch (tps65910_chip_id(tps65910)) { 84 - case TPS65911: 85 - reg = irq_sts >> 8; 86 - tps65910_reg_write(tps65910, TPS65910_INT_STS3, reg); 87 - } 88 - 89 - return IRQ_HANDLED; 90 - } 91 - 92 - static void tps65910_irq_lock(struct irq_data *data) 93 - { 94 - struct tps65910 *tps65910 = irq_data_get_irq_chip_data(data); 95 - 96 - mutex_lock(&tps65910->irq_lock); 97 - } 98 - 99 - static void tps65910_irq_sync_unlock(struct irq_data *data) 100 - { 101 - struct tps65910 *tps65910 = irq_data_get_irq_chip_data(data); 102 - u32 reg_mask; 103 - unsigned int reg; 104 - 105 - tps65910_reg_read(tps65910, TPS65910_INT_MSK, &reg); 106 - reg_mask = reg; 107 - tps65910_reg_read(tps65910, TPS65910_INT_MSK2, &reg); 108 - reg_mask |= reg << 8; 109 - switch (tps65910_chip_id(tps65910)) { 110 - case TPS65911: 111 - tps65910_reg_read(tps65910, TPS65910_INT_MSK3, &reg); 112 - reg_mask |= reg << 16; 113 - } 114 - 115 - if (tps65910->irq_mask != reg_mask) { 116 - reg = tps65910->irq_mask & 0xFF; 117 - tps65910_reg_write(tps65910, TPS65910_INT_MSK, reg); 118 - reg = tps65910->irq_mask >> 8 & 0xFF; 119 - tps65910_reg_write(tps65910, TPS65910_INT_MSK2, reg); 120 - switch (tps65910_chip_id(tps65910)) { 121 - case TPS65911: 122 - reg = tps65910->irq_mask >> 16; 123 - tps65910_reg_write(tps65910, TPS65910_INT_MSK3, reg); 124 - } 125 - } 126 - mutex_unlock(&tps65910->irq_lock); 127 - } 128 - 129 - static void tps65910_irq_enable(struct irq_data *data) 130 - { 131 - struct tps65910 *tps65910 = irq_data_get_irq_chip_data(data); 132 - 133 - tps65910->irq_mask &= ~(1 << data->hwirq); 134 - } 135 - 136 - static void tps65910_irq_disable(struct irq_data *data) 137 - { 138 - struct tps65910 *tps65910 = irq_data_get_irq_chip_data(data); 139 - 140 - tps65910->irq_mask |= (1 << data->hwirq); 141 - } 142 - 143 - #ifdef CONFIG_PM_SLEEP 144 - static int tps65910_irq_set_wake(struct irq_data *data, unsigned int enable) 145 - { 146 - struct tps65910 *tps65910 = irq_data_get_irq_chip_data(data); 147 - return irq_set_irq_wake(tps65910->chip_irq, enable); 148 - } 149 - #else 150 - #define tps65910_irq_set_wake NULL 151 - #endif 152 - 153 - static struct irq_chip tps65910_irq_chip = { 154 - .name = "tps65910", 155 - .irq_bus_lock = tps65910_irq_lock, 156 - .irq_bus_sync_unlock = tps65910_irq_sync_unlock, 157 - .irq_disable = tps65910_irq_disable, 158 - .irq_enable = tps65910_irq_enable, 159 - .irq_set_wake = tps65910_irq_set_wake, 160 - }; 161 - 162 - static int tps65910_irq_map(struct irq_domain *h, unsigned int virq, 163 - irq_hw_number_t hw) 164 - { 165 - struct tps65910 *tps65910 = h->host_data; 166 - 167 - irq_set_chip_data(virq, tps65910); 168 - irq_set_chip_and_handler(virq, &tps65910_irq_chip, handle_edge_irq); 169 - irq_set_nested_thread(virq, 1); 170 - 171 - /* ARM needs us to explicitly flag the IRQ as valid 172 - * and will set them noprobe when we do so. */ 173 - #ifdef CONFIG_ARM 174 - set_irq_flags(virq, IRQF_VALID); 175 - #else 176 - irq_set_noprobe(virq); 177 - #endif 178 - 179 - return 0; 180 - } 181 - 182 - static struct irq_domain_ops tps65910_domain_ops = { 183 - .map = tps65910_irq_map, 184 - .xlate = irq_domain_xlate_twocell, 185 - }; 186 - 187 - int tps65910_irq_init(struct tps65910 *tps65910, int irq, 188 - struct tps65910_platform_data *pdata) 189 - { 190 - int ret; 191 - int flags = IRQF_ONESHOT; 192 - 193 - if (!irq) { 194 - dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n"); 195 - return -EINVAL; 196 - } 197 - 198 - if (!pdata) { 199 - dev_warn(tps65910->dev, "No interrupt support, no pdata\n"); 200 - return -EINVAL; 201 - } 202 - 203 - switch (tps65910_chip_id(tps65910)) { 204 - case TPS65910: 205 - tps65910->irq_num = TPS65910_NUM_IRQ; 206 - break; 207 - case TPS65911: 208 - tps65910->irq_num = TPS65911_NUM_IRQ; 209 - break; 210 - } 211 - 212 - if (pdata->irq_base > 0) { 213 - pdata->irq_base = irq_alloc_descs(pdata->irq_base, 0, 214 - tps65910->irq_num, -1); 215 - if (pdata->irq_base < 0) { 216 - dev_warn(tps65910->dev, "Failed to alloc IRQs: %d\n", 217 - pdata->irq_base); 218 - return pdata->irq_base; 219 - } 220 - } 221 - 222 - tps65910->irq_mask = 0xFFFFFF; 223 - 224 - mutex_init(&tps65910->irq_lock); 225 - tps65910->chip_irq = irq; 226 - tps65910->irq_base = pdata->irq_base; 227 - 228 - if (pdata->irq_base > 0) 229 - tps65910->domain = irq_domain_add_legacy(tps65910->dev->of_node, 230 - tps65910->irq_num, 231 - pdata->irq_base, 232 - 0, 233 - &tps65910_domain_ops, tps65910); 234 - else 235 - tps65910->domain = irq_domain_add_linear(tps65910->dev->of_node, 236 - tps65910->irq_num, 237 - &tps65910_domain_ops, tps65910); 238 - 239 - if (!tps65910->domain) { 240 - dev_err(tps65910->dev, "Failed to create IRQ domain\n"); 241 - return -ENOMEM; 242 - } 243 - 244 - ret = request_threaded_irq(irq, NULL, tps65910_irq, flags, 245 - "tps65910", tps65910); 246 - 247 - irq_set_irq_type(irq, IRQ_TYPE_LEVEL_LOW); 248 - 249 - if (ret != 0) 250 - dev_err(tps65910->dev, "Failed to request IRQ: %d\n", ret); 251 - 252 - return ret; 253 - } 254 - 255 - int tps65910_irq_exit(struct tps65910 *tps65910) 256 - { 257 - if (tps65910->chip_irq) 258 - free_irq(tps65910->chip_irq, tps65910); 259 - return 0; 260 - }
+225 -9
drivers/mfd/tps65910.c
··· 19 19 #include <linux/err.h> 20 20 #include <linux/slab.h> 21 21 #include <linux/i2c.h> 22 + #include <linux/interrupt.h> 23 + #include <linux/irq.h> 24 + #include <linux/irqdomain.h> 22 25 #include <linux/mfd/core.h> 23 26 #include <linux/regmap.h> 24 27 #include <linux/mfd/tps65910.h> ··· 52 49 }, 53 50 }; 54 51 52 + 53 + static const struct regmap_irq tps65911_irqs[] = { 54 + /* INT_STS */ 55 + [TPS65911_IRQ_PWRHOLD_F] = { 56 + .mask = INT_MSK_PWRHOLD_F_IT_MSK_MASK, 57 + .reg_offset = 0, 58 + }, 59 + [TPS65911_IRQ_VBAT_VMHI] = { 60 + .mask = INT_MSK_VMBHI_IT_MSK_MASK, 61 + .reg_offset = 0, 62 + }, 63 + [TPS65911_IRQ_PWRON] = { 64 + .mask = INT_MSK_PWRON_IT_MSK_MASK, 65 + .reg_offset = 0, 66 + }, 67 + [TPS65911_IRQ_PWRON_LP] = { 68 + .mask = INT_MSK_PWRON_LP_IT_MSK_MASK, 69 + .reg_offset = 0, 70 + }, 71 + [TPS65911_IRQ_PWRHOLD_R] = { 72 + .mask = INT_MSK_PWRHOLD_R_IT_MSK_MASK, 73 + .reg_offset = 0, 74 + }, 75 + [TPS65911_IRQ_HOTDIE] = { 76 + .mask = INT_MSK_HOTDIE_IT_MSK_MASK, 77 + .reg_offset = 0, 78 + }, 79 + [TPS65911_IRQ_RTC_ALARM] = { 80 + .mask = INT_MSK_RTC_ALARM_IT_MSK_MASK, 81 + .reg_offset = 0, 82 + }, 83 + [TPS65911_IRQ_RTC_PERIOD] = { 84 + .mask = INT_MSK_RTC_PERIOD_IT_MSK_MASK, 85 + .reg_offset = 0, 86 + }, 87 + 88 + /* INT_STS2 */ 89 + [TPS65911_IRQ_GPIO0_R] = { 90 + .mask = INT_MSK2_GPIO0_R_IT_MSK_MASK, 91 + .reg_offset = 1, 92 + }, 93 + [TPS65911_IRQ_GPIO0_F] = { 94 + .mask = INT_MSK2_GPIO0_F_IT_MSK_MASK, 95 + .reg_offset = 1, 96 + }, 97 + [TPS65911_IRQ_GPIO1_R] = { 98 + .mask = INT_MSK2_GPIO1_R_IT_MSK_MASK, 99 + .reg_offset = 1, 100 + }, 101 + [TPS65911_IRQ_GPIO1_F] = { 102 + .mask = INT_MSK2_GPIO1_F_IT_MSK_MASK, 103 + .reg_offset = 1, 104 + }, 105 + [TPS65911_IRQ_GPIO2_R] = { 106 + .mask = INT_MSK2_GPIO2_R_IT_MSK_MASK, 107 + .reg_offset = 1, 108 + }, 109 + [TPS65911_IRQ_GPIO2_F] = { 110 + .mask = INT_MSK2_GPIO2_F_IT_MSK_MASK, 111 + .reg_offset = 1, 112 + }, 113 + [TPS65911_IRQ_GPIO3_R] = { 114 + .mask = INT_MSK2_GPIO3_R_IT_MSK_MASK, 115 + .reg_offset = 1, 116 + }, 117 + [TPS65911_IRQ_GPIO3_F] = { 118 + .mask = INT_MSK2_GPIO3_F_IT_MSK_MASK, 119 + .reg_offset = 1, 120 + }, 121 + 122 + /* INT_STS2 */ 123 + [TPS65911_IRQ_GPIO4_R] = { 124 + .mask = INT_MSK3_GPIO4_R_IT_MSK_MASK, 125 + .reg_offset = 2, 126 + }, 127 + [TPS65911_IRQ_GPIO4_F] = { 128 + .mask = INT_MSK3_GPIO4_F_IT_MSK_MASK, 129 + .reg_offset = 2, 130 + }, 131 + [TPS65911_IRQ_GPIO5_R] = { 132 + .mask = INT_MSK3_GPIO5_R_IT_MSK_MASK, 133 + .reg_offset = 2, 134 + }, 135 + [TPS65911_IRQ_GPIO5_F] = { 136 + .mask = INT_MSK3_GPIO5_F_IT_MSK_MASK, 137 + .reg_offset = 2, 138 + }, 139 + [TPS65911_IRQ_WTCHDG] = { 140 + .mask = INT_MSK3_WTCHDG_IT_MSK_MASK, 141 + .reg_offset = 2, 142 + }, 143 + [TPS65911_IRQ_VMBCH2_H] = { 144 + .mask = INT_MSK3_VMBCH2_H_IT_MSK_MASK, 145 + .reg_offset = 2, 146 + }, 147 + [TPS65911_IRQ_VMBCH2_L] = { 148 + .mask = INT_MSK3_VMBCH2_L_IT_MSK_MASK, 149 + .reg_offset = 2, 150 + }, 151 + [TPS65911_IRQ_PWRDN] = { 152 + .mask = INT_MSK3_PWRDN_IT_MSK_MASK, 153 + .reg_offset = 2, 154 + }, 155 + }; 156 + 157 + static const struct regmap_irq tps65910_irqs[] = { 158 + /* INT_STS */ 159 + [TPS65910_IRQ_VBAT_VMBDCH] = { 160 + .mask = TPS65910_INT_MSK_VMBDCH_IT_MSK_MASK, 161 + .reg_offset = 0, 162 + }, 163 + [TPS65910_IRQ_VBAT_VMHI] = { 164 + .mask = TPS65910_INT_MSK_VMBHI_IT_MSK_MASK, 165 + .reg_offset = 0, 166 + }, 167 + [TPS65910_IRQ_PWRON] = { 168 + .mask = TPS65910_INT_MSK_PWRON_IT_MSK_MASK, 169 + .reg_offset = 0, 170 + }, 171 + [TPS65910_IRQ_PWRON_LP] = { 172 + .mask = TPS65910_INT_MSK_PWRON_LP_IT_MSK_MASK, 173 + .reg_offset = 0, 174 + }, 175 + [TPS65910_IRQ_PWRHOLD] = { 176 + .mask = TPS65910_INT_MSK_PWRHOLD_IT_MSK_MASK, 177 + .reg_offset = 0, 178 + }, 179 + [TPS65910_IRQ_HOTDIE] = { 180 + .mask = TPS65910_INT_MSK_HOTDIE_IT_MSK_MASK, 181 + .reg_offset = 0, 182 + }, 183 + [TPS65910_IRQ_RTC_ALARM] = { 184 + .mask = TPS65910_INT_MSK_RTC_ALARM_IT_MSK_MASK, 185 + .reg_offset = 0, 186 + }, 187 + [TPS65910_IRQ_RTC_PERIOD] = { 188 + .mask = TPS65910_INT_MSK_RTC_PERIOD_IT_MSK_MASK, 189 + .reg_offset = 0, 190 + }, 191 + 192 + /* INT_STS2 */ 193 + [TPS65910_IRQ_GPIO_R] = { 194 + .mask = TPS65910_INT_MSK2_GPIO0_F_IT_MSK_MASK, 195 + .reg_offset = 1, 196 + }, 197 + [TPS65910_IRQ_GPIO_F] = { 198 + .mask = TPS65910_INT_MSK2_GPIO0_R_IT_MSK_MASK, 199 + .reg_offset = 1, 200 + }, 201 + }; 202 + 203 + static struct regmap_irq_chip tps65911_irq_chip = { 204 + .name = "tps65910", 205 + .irqs = tps65911_irqs, 206 + .num_irqs = ARRAY_SIZE(tps65911_irqs), 207 + .num_regs = 3, 208 + .irq_reg_stride = 2, 209 + .status_base = TPS65910_INT_STS, 210 + .mask_base = TPS65910_INT_MSK, 211 + .ack_base = TPS65910_INT_STS, 212 + }; 213 + 214 + static struct regmap_irq_chip tps65910_irq_chip = { 215 + .name = "tps65910", 216 + .irqs = tps65910_irqs, 217 + .num_irqs = ARRAY_SIZE(tps65910_irqs), 218 + .num_regs = 2, 219 + .irq_reg_stride = 2, 220 + .status_base = TPS65910_INT_STS, 221 + .mask_base = TPS65910_INT_MSK, 222 + .ack_base = TPS65910_INT_STS, 223 + }; 224 + 225 + static int tps65910_irq_init(struct tps65910 *tps65910, int irq, 226 + struct tps65910_platform_data *pdata) 227 + { 228 + int ret = 0; 229 + static struct regmap_irq_chip *tps6591x_irqs_chip; 230 + 231 + if (!irq) { 232 + dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n"); 233 + return -EINVAL; 234 + } 235 + 236 + if (!pdata) { 237 + dev_warn(tps65910->dev, "No interrupt support, no pdata\n"); 238 + return -EINVAL; 239 + } 240 + 241 + switch (tps65910_chip_id(tps65910)) { 242 + case TPS65910: 243 + tps6591x_irqs_chip = &tps65910_irq_chip; 244 + break; 245 + case TPS65911: 246 + tps6591x_irqs_chip = &tps65911_irq_chip; 247 + break; 248 + } 249 + 250 + tps65910->chip_irq = irq; 251 + ret = regmap_add_irq_chip(tps65910->regmap, tps65910->chip_irq, 252 + IRQF_ONESHOT, pdata->irq_base, 253 + tps6591x_irqs_chip, &tps65910->irq_data); 254 + if (ret < 0) 255 + dev_warn(tps65910->dev, "Failed to add irq_chip %d\n", ret); 256 + return ret; 257 + } 258 + 259 + static int tps65910_irq_exit(struct tps65910 *tps65910) 260 + { 261 + if (tps65910->chip_irq > 0) 262 + regmap_del_irq_chip(tps65910->chip_irq, tps65910->irq_data); 263 + return 0; 264 + } 55 265 56 266 static bool is_volatile_reg(struct device *dev, unsigned int reg) 57 267 { ··· 486 270 tps65910->dev = &i2c->dev; 487 271 tps65910->i2c_client = i2c; 488 272 tps65910->id = chip_id; 489 - mutex_init(&tps65910->io_mutex); 490 273 491 274 tps65910->regmap = devm_regmap_init_i2c(i2c, &tps65910_regmap_config); 492 275 if (IS_ERR(tps65910->regmap)) { 493 276 ret = PTR_ERR(tps65910->regmap); 494 277 dev_err(&i2c->dev, "regmap initialization failed: %d\n", ret); 495 - return ret; 496 - } 497 - 498 - ret = mfd_add_devices(tps65910->dev, -1, 499 - tps65910s, ARRAY_SIZE(tps65910s), 500 - NULL, 0, NULL); 501 - if (ret < 0) { 502 - dev_err(&i2c->dev, "mfd_add_devices failed: %d\n", ret); 503 278 return ret; 504 279 } 505 280 ··· 504 297 if (pmic_plat_data->pm_off && !pm_power_off) { 505 298 tps65910_i2c_client = i2c; 506 299 pm_power_off = tps65910_power_off; 300 + } 301 + 302 + ret = mfd_add_devices(tps65910->dev, -1, 303 + tps65910s, ARRAY_SIZE(tps65910s), 304 + NULL, 0, 305 + regmap_irq_get_domain(tps65910->irq_data)); 306 + if (ret < 0) { 307 + dev_err(&i2c->dev, "mfd_add_devices failed: %d\n", ret); 308 + return ret; 507 309 } 508 310 509 311 return ret;
+574
drivers/mfd/tps80031.c
··· 1 + /* 2 + * tps80031.c -- TI TPS80031/TPS80032 mfd core driver. 3 + * 4 + * MFD core driver for TI TPS80031/TPS80032 Fully Integrated 5 + * Power Management with Power Path and Battery Charger 6 + * 7 + * Copyright (c) 2012, NVIDIA Corporation. 8 + * 9 + * Author: Laxman Dewangan <ldewangan@nvidia.com> 10 + * 11 + * This program is free software; you can redistribute it and/or 12 + * modify it under the terms of the GNU General Public License as 13 + * published by the Free Software Foundation version 2. 14 + * 15 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind, 16 + * whether express or implied; without even the implied warranty of 17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 + * General Public License for more details. 19 + * 20 + * You should have received a copy of the GNU General Public License 21 + * along with this program; if not, write to the Free Software 22 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 23 + * 02111-1307, USA 24 + */ 25 + 26 + #include <linux/err.h> 27 + #include <linux/i2c.h> 28 + #include <linux/init.h> 29 + #include <linux/interrupt.h> 30 + #include <linux/irq.h> 31 + #include <linux/mfd/core.h> 32 + #include <linux/mfd/tps80031.h> 33 + #include <linux/module.h> 34 + #include <linux/pm.h> 35 + #include <linux/regmap.h> 36 + #include <linux/slab.h> 37 + 38 + static struct resource tps80031_rtc_resources[] = { 39 + { 40 + .start = TPS80031_INT_RTC_ALARM, 41 + .end = TPS80031_INT_RTC_ALARM, 42 + .flags = IORESOURCE_IRQ, 43 + }, 44 + }; 45 + 46 + /* TPS80031 sub mfd devices */ 47 + static struct mfd_cell tps80031_cell[] = { 48 + { 49 + .name = "tps80031-pmic", 50 + }, 51 + { 52 + .name = "tps80031-clock", 53 + }, 54 + { 55 + .name = "tps80031-rtc", 56 + .num_resources = ARRAY_SIZE(tps80031_rtc_resources), 57 + .resources = tps80031_rtc_resources, 58 + }, 59 + { 60 + .name = "tps80031-gpadc", 61 + }, 62 + { 63 + .name = "tps80031-fuel-gauge", 64 + }, 65 + { 66 + .name = "tps80031-charger", 67 + }, 68 + }; 69 + 70 + static int tps80031_slave_address[TPS80031_NUM_SLAVES] = { 71 + TPS80031_I2C_ID0_ADDR, 72 + TPS80031_I2C_ID1_ADDR, 73 + TPS80031_I2C_ID2_ADDR, 74 + TPS80031_I2C_ID3_ADDR, 75 + }; 76 + 77 + struct tps80031_pupd_data { 78 + u8 reg; 79 + u8 pullup_bit; 80 + u8 pulldown_bit; 81 + }; 82 + 83 + #define TPS80031_IRQ(_reg, _mask) \ 84 + { \ 85 + .reg_offset = (TPS80031_INT_MSK_LINE_##_reg) - \ 86 + TPS80031_INT_MSK_LINE_A, \ 87 + .mask = BIT(_mask), \ 88 + } 89 + 90 + static const struct regmap_irq tps80031_main_irqs[] = { 91 + [TPS80031_INT_PWRON] = TPS80031_IRQ(A, 0), 92 + [TPS80031_INT_RPWRON] = TPS80031_IRQ(A, 1), 93 + [TPS80031_INT_SYS_VLOW] = TPS80031_IRQ(A, 2), 94 + [TPS80031_INT_RTC_ALARM] = TPS80031_IRQ(A, 3), 95 + [TPS80031_INT_RTC_PERIOD] = TPS80031_IRQ(A, 4), 96 + [TPS80031_INT_HOT_DIE] = TPS80031_IRQ(A, 5), 97 + [TPS80031_INT_VXX_SHORT] = TPS80031_IRQ(A, 6), 98 + [TPS80031_INT_SPDURATION] = TPS80031_IRQ(A, 7), 99 + [TPS80031_INT_WATCHDOG] = TPS80031_IRQ(B, 0), 100 + [TPS80031_INT_BAT] = TPS80031_IRQ(B, 1), 101 + [TPS80031_INT_SIM] = TPS80031_IRQ(B, 2), 102 + [TPS80031_INT_MMC] = TPS80031_IRQ(B, 3), 103 + [TPS80031_INT_RES] = TPS80031_IRQ(B, 4), 104 + [TPS80031_INT_GPADC_RT] = TPS80031_IRQ(B, 5), 105 + [TPS80031_INT_GPADC_SW2_EOC] = TPS80031_IRQ(B, 6), 106 + [TPS80031_INT_CC_AUTOCAL] = TPS80031_IRQ(B, 7), 107 + [TPS80031_INT_ID_WKUP] = TPS80031_IRQ(C, 0), 108 + [TPS80031_INT_VBUSS_WKUP] = TPS80031_IRQ(C, 1), 109 + [TPS80031_INT_ID] = TPS80031_IRQ(C, 2), 110 + [TPS80031_INT_VBUS] = TPS80031_IRQ(C, 3), 111 + [TPS80031_INT_CHRG_CTRL] = TPS80031_IRQ(C, 4), 112 + [TPS80031_INT_EXT_CHRG] = TPS80031_IRQ(C, 5), 113 + [TPS80031_INT_INT_CHRG] = TPS80031_IRQ(C, 6), 114 + [TPS80031_INT_RES2] = TPS80031_IRQ(C, 7), 115 + }; 116 + 117 + static struct regmap_irq_chip tps80031_irq_chip = { 118 + .name = "tps80031", 119 + .irqs = tps80031_main_irqs, 120 + .num_irqs = ARRAY_SIZE(tps80031_main_irqs), 121 + .num_regs = 3, 122 + .status_base = TPS80031_INT_STS_A, 123 + .mask_base = TPS80031_INT_MSK_LINE_A, 124 + }; 125 + 126 + #define PUPD_DATA(_reg, _pulldown_bit, _pullup_bit) \ 127 + { \ 128 + .reg = TPS80031_CFG_INPUT_PUPD##_reg, \ 129 + .pulldown_bit = _pulldown_bit, \ 130 + .pullup_bit = _pullup_bit, \ 131 + } 132 + 133 + static const struct tps80031_pupd_data tps80031_pupds[] = { 134 + [TPS80031_PREQ1] = PUPD_DATA(1, BIT(0), BIT(1)), 135 + [TPS80031_PREQ2A] = PUPD_DATA(1, BIT(2), BIT(3)), 136 + [TPS80031_PREQ2B] = PUPD_DATA(1, BIT(4), BIT(5)), 137 + [TPS80031_PREQ2C] = PUPD_DATA(1, BIT(6), BIT(7)), 138 + [TPS80031_PREQ3] = PUPD_DATA(2, BIT(0), BIT(1)), 139 + [TPS80031_NRES_WARM] = PUPD_DATA(2, 0, BIT(2)), 140 + [TPS80031_PWM_FORCE] = PUPD_DATA(2, BIT(5), 0), 141 + [TPS80031_CHRG_EXT_CHRG_STATZ] = PUPD_DATA(2, 0, BIT(6)), 142 + [TPS80031_SIM] = PUPD_DATA(3, BIT(0), BIT(1)), 143 + [TPS80031_MMC] = PUPD_DATA(3, BIT(2), BIT(3)), 144 + [TPS80031_GPADC_START] = PUPD_DATA(3, BIT(4), 0), 145 + [TPS80031_DVSI2C_SCL] = PUPD_DATA(4, 0, BIT(0)), 146 + [TPS80031_DVSI2C_SDA] = PUPD_DATA(4, 0, BIT(1)), 147 + [TPS80031_CTLI2C_SCL] = PUPD_DATA(4, 0, BIT(2)), 148 + [TPS80031_CTLI2C_SDA] = PUPD_DATA(4, 0, BIT(3)), 149 + }; 150 + static struct tps80031 *tps80031_power_off_dev; 151 + 152 + int tps80031_ext_power_req_config(struct device *dev, 153 + unsigned long ext_ctrl_flag, int preq_bit, 154 + int state_reg_add, int trans_reg_add) 155 + { 156 + u8 res_ass_reg = 0; 157 + int preq_mask_bit = 0; 158 + int ret; 159 + 160 + if (!(ext_ctrl_flag & TPS80031_EXT_PWR_REQ)) 161 + return 0; 162 + 163 + if (ext_ctrl_flag & TPS80031_PWR_REQ_INPUT_PREQ1) { 164 + res_ass_reg = TPS80031_PREQ1_RES_ASS_A + (preq_bit >> 3); 165 + preq_mask_bit = 5; 166 + } else if (ext_ctrl_flag & TPS80031_PWR_REQ_INPUT_PREQ2) { 167 + res_ass_reg = TPS80031_PREQ2_RES_ASS_A + (preq_bit >> 3); 168 + preq_mask_bit = 6; 169 + } else if (ext_ctrl_flag & TPS80031_PWR_REQ_INPUT_PREQ3) { 170 + res_ass_reg = TPS80031_PREQ3_RES_ASS_A + (preq_bit >> 3); 171 + preq_mask_bit = 7; 172 + } 173 + 174 + /* Configure REQ_ASS registers */ 175 + ret = tps80031_set_bits(dev, TPS80031_SLAVE_ID1, res_ass_reg, 176 + BIT(preq_bit & 0x7)); 177 + if (ret < 0) { 178 + dev_err(dev, "reg 0x%02x setbit failed, err = %d\n", 179 + res_ass_reg, ret); 180 + return ret; 181 + } 182 + 183 + /* Unmask the PREQ */ 184 + ret = tps80031_clr_bits(dev, TPS80031_SLAVE_ID1, 185 + TPS80031_PHOENIX_MSK_TRANSITION, BIT(preq_mask_bit)); 186 + if (ret < 0) { 187 + dev_err(dev, "reg 0x%02x clrbit failed, err = %d\n", 188 + TPS80031_PHOENIX_MSK_TRANSITION, ret); 189 + return ret; 190 + } 191 + 192 + /* Switch regulator control to resource now */ 193 + if (ext_ctrl_flag & (TPS80031_PWR_REQ_INPUT_PREQ2 | 194 + TPS80031_PWR_REQ_INPUT_PREQ3)) { 195 + ret = tps80031_update(dev, TPS80031_SLAVE_ID1, state_reg_add, 196 + 0x0, TPS80031_STATE_MASK); 197 + if (ret < 0) 198 + dev_err(dev, "reg 0x%02x update failed, err = %d\n", 199 + state_reg_add, ret); 200 + } else { 201 + ret = tps80031_update(dev, TPS80031_SLAVE_ID1, trans_reg_add, 202 + TPS80031_TRANS_SLEEP_OFF, 203 + TPS80031_TRANS_SLEEP_MASK); 204 + if (ret < 0) 205 + dev_err(dev, "reg 0x%02x update failed, err = %d\n", 206 + trans_reg_add, ret); 207 + } 208 + return ret; 209 + } 210 + EXPORT_SYMBOL_GPL(tps80031_ext_power_req_config); 211 + 212 + static void tps80031_power_off(void) 213 + { 214 + dev_info(tps80031_power_off_dev->dev, "switching off PMU\n"); 215 + tps80031_write(tps80031_power_off_dev->dev, TPS80031_SLAVE_ID1, 216 + TPS80031_PHOENIX_DEV_ON, TPS80031_DEVOFF); 217 + } 218 + 219 + static void tps80031_pupd_init(struct tps80031 *tps80031, 220 + struct tps80031_platform_data *pdata) 221 + { 222 + struct tps80031_pupd_init_data *pupd_init_data = pdata->pupd_init_data; 223 + int data_size = pdata->pupd_init_data_size; 224 + int i; 225 + 226 + for (i = 0; i < data_size; ++i) { 227 + struct tps80031_pupd_init_data *pupd_init = &pupd_init_data[i]; 228 + const struct tps80031_pupd_data *pupd = 229 + &tps80031_pupds[pupd_init->input_pin]; 230 + u8 update_value = 0; 231 + u8 update_mask = pupd->pulldown_bit | pupd->pullup_bit; 232 + 233 + if (pupd_init->setting == TPS80031_PUPD_PULLDOWN) 234 + update_value = pupd->pulldown_bit; 235 + else if (pupd_init->setting == TPS80031_PUPD_PULLUP) 236 + update_value = pupd->pullup_bit; 237 + 238 + tps80031_update(tps80031->dev, TPS80031_SLAVE_ID1, pupd->reg, 239 + update_value, update_mask); 240 + } 241 + } 242 + 243 + static int tps80031_init_ext_control(struct tps80031 *tps80031, 244 + struct tps80031_platform_data *pdata) 245 + { 246 + struct device *dev = tps80031->dev; 247 + int ret; 248 + int i; 249 + 250 + /* Clear all external control for this rail */ 251 + for (i = 0; i < 9; ++i) { 252 + ret = tps80031_write(dev, TPS80031_SLAVE_ID1, 253 + TPS80031_PREQ1_RES_ASS_A + i, 0); 254 + if (ret < 0) { 255 + dev_err(dev, "reg 0x%02x write failed, err = %d\n", 256 + TPS80031_PREQ1_RES_ASS_A + i, ret); 257 + return ret; 258 + } 259 + } 260 + 261 + /* Mask the PREQ */ 262 + ret = tps80031_set_bits(dev, TPS80031_SLAVE_ID1, 263 + TPS80031_PHOENIX_MSK_TRANSITION, 0x7 << 5); 264 + if (ret < 0) { 265 + dev_err(dev, "reg 0x%02x set_bits failed, err = %d\n", 266 + TPS80031_PHOENIX_MSK_TRANSITION, ret); 267 + return ret; 268 + } 269 + return ret; 270 + } 271 + 272 + static int __devinit tps80031_irq_init(struct tps80031 *tps80031, int irq, 273 + int irq_base) 274 + { 275 + struct device *dev = tps80031->dev; 276 + int i, ret; 277 + 278 + /* 279 + * The MASK register used for updating status register when 280 + * interrupt occurs and LINE register used to pass the status 281 + * to actual interrupt line. As per datasheet: 282 + * When INT_MSK_LINE [i] is set to 1, the associated interrupt 283 + * number i is INT line masked, which means that no interrupt is 284 + * generated on the INT line. 285 + * When INT_MSK_LINE [i] is set to 0, the associated interrupt 286 + * number i is line enabled: An interrupt is generated on the 287 + * INT line. 288 + * In any case, the INT_STS [i] status bit may or may not be updated, 289 + * only linked to the INT_MSK_STS [i] configuration register bit. 290 + * 291 + * When INT_MSK_STS [i] is set to 1, the associated interrupt number 292 + * i is status masked, which means that no interrupt is stored in 293 + * the INT_STS[i] status bit. Note that no interrupt number i is 294 + * generated on the INT line, even if the INT_MSK_LINE [i] register 295 + * bit is set to 0. 296 + * When INT_MSK_STS [i] is set to 0, the associated interrupt number i 297 + * is status enabled: An interrupt status is updated in the INT_STS [i] 298 + * register. The interrupt may or may not be generated on the INT line, 299 + * depending on the INT_MSK_LINE [i] configuration register bit. 300 + */ 301 + for (i = 0; i < 3; i++) 302 + tps80031_write(dev, TPS80031_SLAVE_ID2, 303 + TPS80031_INT_MSK_STS_A + i, 0x00); 304 + 305 + ret = regmap_add_irq_chip(tps80031->regmap[TPS80031_SLAVE_ID2], irq, 306 + IRQF_ONESHOT, irq_base, 307 + &tps80031_irq_chip, &tps80031->irq_data); 308 + if (ret < 0) { 309 + dev_err(dev, "add irq failed, err = %d\n", ret); 310 + return ret; 311 + } 312 + return ret; 313 + } 314 + 315 + static bool rd_wr_reg_id0(struct device *dev, unsigned int reg) 316 + { 317 + switch (reg) { 318 + case TPS80031_SMPS1_CFG_FORCE ... TPS80031_SMPS2_CFG_VOLTAGE: 319 + return true; 320 + default: 321 + return false; 322 + } 323 + } 324 + 325 + static bool rd_wr_reg_id1(struct device *dev, unsigned int reg) 326 + { 327 + switch (reg) { 328 + case TPS80031_SECONDS_REG ... TPS80031_RTC_RESET_STATUS_REG: 329 + case TPS80031_VALIDITY0 ... TPS80031_VALIDITY7: 330 + case TPS80031_PHOENIX_START_CONDITION ... TPS80031_KEY_PRESS_DUR_CFG: 331 + case TPS80031_SMPS4_CFG_TRANS ... TPS80031_SMPS3_CFG_VOLTAGE: 332 + case TPS80031_BROADCAST_ADDR_ALL ... TPS80031_BROADCAST_ADDR_CLK_RST: 333 + case TPS80031_VANA_CFG_TRANS ... TPS80031_LDO7_CFG_VOLTAGE: 334 + case TPS80031_REGEN1_CFG_TRANS ... TPS80031_TMP_CFG_STATE: 335 + case TPS80031_PREQ1_RES_ASS_A ... TPS80031_PREQ3_RES_ASS_C: 336 + case TPS80031_SMPS_OFFSET ... TPS80031_BATDEBOUNCING: 337 + case TPS80031_CFG_INPUT_PUPD1 ... TPS80031_CFG_SMPS_PD: 338 + case TPS80031_BACKUP_REG: 339 + return true; 340 + default: 341 + return false; 342 + } 343 + } 344 + 345 + static bool is_volatile_reg_id1(struct device *dev, unsigned int reg) 346 + { 347 + switch (reg) { 348 + case TPS80031_SMPS4_CFG_TRANS ... TPS80031_SMPS3_CFG_VOLTAGE: 349 + case TPS80031_VANA_CFG_TRANS ... TPS80031_LDO7_CFG_VOLTAGE: 350 + case TPS80031_REGEN1_CFG_TRANS ... TPS80031_TMP_CFG_STATE: 351 + case TPS80031_PREQ1_RES_ASS_A ... TPS80031_PREQ3_RES_ASS_C: 352 + case TPS80031_SMPS_OFFSET ... TPS80031_BATDEBOUNCING: 353 + case TPS80031_CFG_INPUT_PUPD1 ... TPS80031_CFG_SMPS_PD: 354 + return true; 355 + default: 356 + return false; 357 + } 358 + } 359 + 360 + static bool rd_wr_reg_id2(struct device *dev, unsigned int reg) 361 + { 362 + switch (reg) { 363 + case TPS80031_USB_VENDOR_ID_LSB ... TPS80031_USB_OTG_REVISION: 364 + case TPS80031_GPADC_CTRL ... TPS80031_CTRL_P1: 365 + case TPS80031_RTCH0_LSB ... TPS80031_GPCH0_MSB: 366 + case TPS80031_TOGGLE1 ... TPS80031_VIBMODE: 367 + case TPS80031_PWM1ON ... TPS80031_PWM2OFF: 368 + case TPS80031_FG_REG_00 ... TPS80031_FG_REG_11: 369 + case TPS80031_INT_STS_A ... TPS80031_INT_MSK_STS_C: 370 + case TPS80031_CONTROLLER_CTRL2 ... TPS80031_LED_PWM_CTRL2: 371 + return true; 372 + default: 373 + return false; 374 + } 375 + } 376 + 377 + static bool rd_wr_reg_id3(struct device *dev, unsigned int reg) 378 + { 379 + switch (reg) { 380 + case TPS80031_GPADC_TRIM0 ... TPS80031_GPADC_TRIM18: 381 + return true; 382 + default: 383 + return false; 384 + } 385 + } 386 + 387 + static const struct regmap_config tps80031_regmap_configs[] = { 388 + { 389 + .reg_bits = 8, 390 + .val_bits = 8, 391 + .writeable_reg = rd_wr_reg_id0, 392 + .readable_reg = rd_wr_reg_id0, 393 + .max_register = TPS80031_MAX_REGISTER, 394 + }, 395 + { 396 + .reg_bits = 8, 397 + .val_bits = 8, 398 + .writeable_reg = rd_wr_reg_id1, 399 + .readable_reg = rd_wr_reg_id1, 400 + .volatile_reg = is_volatile_reg_id1, 401 + .max_register = TPS80031_MAX_REGISTER, 402 + }, 403 + { 404 + .reg_bits = 8, 405 + .val_bits = 8, 406 + .writeable_reg = rd_wr_reg_id2, 407 + .readable_reg = rd_wr_reg_id2, 408 + .max_register = TPS80031_MAX_REGISTER, 409 + }, 410 + { 411 + .reg_bits = 8, 412 + .val_bits = 8, 413 + .writeable_reg = rd_wr_reg_id3, 414 + .readable_reg = rd_wr_reg_id3, 415 + .max_register = TPS80031_MAX_REGISTER, 416 + }, 417 + }; 418 + 419 + static int __devinit tps80031_probe(struct i2c_client *client, 420 + const struct i2c_device_id *id) 421 + { 422 + struct tps80031_platform_data *pdata = client->dev.platform_data; 423 + struct tps80031 *tps80031; 424 + int ret; 425 + uint8_t es_version; 426 + uint8_t ep_ver; 427 + int i; 428 + 429 + if (!pdata) { 430 + dev_err(&client->dev, "tps80031 requires platform data\n"); 431 + return -EINVAL; 432 + } 433 + 434 + tps80031 = devm_kzalloc(&client->dev, sizeof(*tps80031), GFP_KERNEL); 435 + if (!tps80031) { 436 + dev_err(&client->dev, "Malloc failed for tps80031\n"); 437 + return -ENOMEM; 438 + } 439 + 440 + for (i = 0; i < TPS80031_NUM_SLAVES; i++) { 441 + if (tps80031_slave_address[i] == client->addr) 442 + tps80031->clients[i] = client; 443 + else 444 + tps80031->clients[i] = i2c_new_dummy(client->adapter, 445 + tps80031_slave_address[i]); 446 + if (!tps80031->clients[i]) { 447 + dev_err(&client->dev, "can't attach client %d\n", i); 448 + ret = -ENOMEM; 449 + goto fail_client_reg; 450 + } 451 + 452 + i2c_set_clientdata(tps80031->clients[i], tps80031); 453 + tps80031->regmap[i] = devm_regmap_init_i2c(tps80031->clients[i], 454 + &tps80031_regmap_configs[i]); 455 + if (IS_ERR(tps80031->regmap[i])) { 456 + ret = PTR_ERR(tps80031->regmap[i]); 457 + dev_err(&client->dev, 458 + "regmap %d init failed, err %d\n", i, ret); 459 + goto fail_client_reg; 460 + } 461 + } 462 + 463 + ret = tps80031_read(&client->dev, TPS80031_SLAVE_ID3, 464 + TPS80031_JTAGVERNUM, &es_version); 465 + if (ret < 0) { 466 + dev_err(&client->dev, 467 + "Silicon version number read failed: %d\n", ret); 468 + goto fail_client_reg; 469 + } 470 + 471 + ret = tps80031_read(&client->dev, TPS80031_SLAVE_ID3, 472 + TPS80031_EPROM_REV, &ep_ver); 473 + if (ret < 0) { 474 + dev_err(&client->dev, 475 + "Silicon eeprom version read failed: %d\n", ret); 476 + goto fail_client_reg; 477 + } 478 + 479 + dev_info(&client->dev, "ES version 0x%02x and EPROM version 0x%02x\n", 480 + es_version, ep_ver); 481 + tps80031->es_version = es_version; 482 + tps80031->dev = &client->dev; 483 + i2c_set_clientdata(client, tps80031); 484 + tps80031->chip_info = id->driver_data; 485 + 486 + ret = tps80031_irq_init(tps80031, client->irq, pdata->irq_base); 487 + if (ret) { 488 + dev_err(&client->dev, "IRQ init failed: %d\n", ret); 489 + goto fail_client_reg; 490 + } 491 + 492 + tps80031_pupd_init(tps80031, pdata); 493 + 494 + tps80031_init_ext_control(tps80031, pdata); 495 + 496 + ret = mfd_add_devices(tps80031->dev, -1, 497 + tps80031_cell, ARRAY_SIZE(tps80031_cell), 498 + NULL, 0, 499 + regmap_irq_get_domain(tps80031->irq_data)); 500 + if (ret < 0) { 501 + dev_err(&client->dev, "mfd_add_devices failed: %d\n", ret); 502 + goto fail_mfd_add; 503 + } 504 + 505 + if (pdata->use_power_off && !pm_power_off) { 506 + tps80031_power_off_dev = tps80031; 507 + pm_power_off = tps80031_power_off; 508 + } 509 + return 0; 510 + 511 + fail_mfd_add: 512 + regmap_del_irq_chip(client->irq, tps80031->irq_data); 513 + 514 + fail_client_reg: 515 + for (i = 0; i < TPS80031_NUM_SLAVES; i++) { 516 + if (tps80031->clients[i] && (tps80031->clients[i] != client)) 517 + i2c_unregister_device(tps80031->clients[i]); 518 + } 519 + return ret; 520 + } 521 + 522 + static int __devexit tps80031_remove(struct i2c_client *client) 523 + { 524 + struct tps80031 *tps80031 = i2c_get_clientdata(client); 525 + int i; 526 + 527 + if (tps80031_power_off_dev == tps80031) { 528 + tps80031_power_off_dev = NULL; 529 + pm_power_off = NULL; 530 + } 531 + 532 + mfd_remove_devices(tps80031->dev); 533 + 534 + regmap_del_irq_chip(client->irq, tps80031->irq_data); 535 + 536 + for (i = 0; i < TPS80031_NUM_SLAVES; i++) { 537 + if (tps80031->clients[i] != client) 538 + i2c_unregister_device(tps80031->clients[i]); 539 + } 540 + return 0; 541 + } 542 + 543 + static const struct i2c_device_id tps80031_id_table[] = { 544 + { "tps80031", TPS80031 }, 545 + { "tps80032", TPS80032 }, 546 + { } 547 + }; 548 + MODULE_DEVICE_TABLE(i2c, tps80031_id_table); 549 + 550 + static struct i2c_driver tps80031_driver = { 551 + .driver = { 552 + .name = "tps80031", 553 + .owner = THIS_MODULE, 554 + }, 555 + .probe = tps80031_probe, 556 + .remove = __devexit_p(tps80031_remove), 557 + .id_table = tps80031_id_table, 558 + }; 559 + 560 + static int __init tps80031_init(void) 561 + { 562 + return i2c_add_driver(&tps80031_driver); 563 + } 564 + subsys_initcall(tps80031_init); 565 + 566 + static void __exit tps80031_exit(void) 567 + { 568 + i2c_del_driver(&tps80031_driver); 569 + } 570 + module_exit(tps80031_exit); 571 + 572 + MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>"); 573 + MODULE_DESCRIPTION("TPS80031 core driver"); 574 + MODULE_LICENSE("GPL v2");
+116 -107
drivers/mfd/twl-core.c
··· 32 32 #include <linux/mutex.h> 33 33 #include <linux/module.h> 34 34 #include <linux/platform_device.h> 35 + #include <linux/regmap.h> 35 36 #include <linux/clk.h> 36 37 #include <linux/err.h> 37 38 #include <linux/device.h> ··· 65 64 #define DRIVER_NAME "twl" 66 65 67 66 /* Triton Core internal information (BEGIN) */ 68 - 69 - /* Last - for index max*/ 70 - #define TWL4030_MODULE_LAST TWL4030_MODULE_SECURED_REG 71 67 72 68 #define TWL_NUM_SLAVES 4 73 69 ··· 169 171 /* Structure for each TWL4030/TWL6030 Slave */ 170 172 struct twl_client { 171 173 struct i2c_client *client; 172 - u8 address; 173 - 174 - /* max numb of i2c_msg required is for read =2 */ 175 - struct i2c_msg xfer_msg[2]; 176 - 177 - /* To lock access to xfer_msg */ 178 - struct mutex xfer_lock; 174 + struct regmap *regmap; 179 175 }; 180 176 181 177 static struct twl_client twl_modules[TWL_NUM_SLAVES]; ··· 181 189 }; 182 190 static struct twl_mapping *twl_map; 183 191 184 - static struct twl_mapping twl4030_map[TWL4030_MODULE_LAST + 1] = { 192 + static struct twl_mapping twl4030_map[] = { 185 193 /* 186 194 * NOTE: don't change this table without updating the 187 195 * <linux/i2c/twl.h> defines for TWL4030_MODULE_* ··· 189 197 */ 190 198 191 199 { 0, TWL4030_BASEADD_USB }, 192 - 193 200 { 1, TWL4030_BASEADD_AUDIO_VOICE }, 194 201 { 1, TWL4030_BASEADD_GPIO }, 195 202 { 1, TWL4030_BASEADD_INTBR }, 196 203 { 1, TWL4030_BASEADD_PIH }, 197 - { 1, TWL4030_BASEADD_TEST }, 198 204 205 + { 1, TWL4030_BASEADD_TEST }, 199 206 { 2, TWL4030_BASEADD_KEYPAD }, 200 207 { 2, TWL4030_BASEADD_MADC }, 201 208 { 2, TWL4030_BASEADD_INTERRUPTS }, 202 209 { 2, TWL4030_BASEADD_LED }, 210 + 203 211 { 2, TWL4030_BASEADD_MAIN_CHARGE }, 204 212 { 2, TWL4030_BASEADD_PRECHARGE }, 205 213 { 2, TWL4030_BASEADD_PWM0 }, 206 214 { 2, TWL4030_BASEADD_PWM1 }, 207 215 { 2, TWL4030_BASEADD_PWMA }, 216 + 208 217 { 2, TWL4030_BASEADD_PWMB }, 209 218 { 2, TWL5031_BASEADD_ACCESSORY }, 210 219 { 2, TWL5031_BASEADD_INTERRUPTS }, 211 - 212 220 { 3, TWL4030_BASEADD_BACKUP }, 213 221 { 3, TWL4030_BASEADD_INT }, 222 + 214 223 { 3, TWL4030_BASEADD_PM_MASTER }, 215 224 { 3, TWL4030_BASEADD_PM_RECEIVER }, 216 225 { 3, TWL4030_BASEADD_RTC }, 217 226 { 3, TWL4030_BASEADD_SECURED_REG }, 227 + }; 228 + 229 + static struct regmap_config twl4030_regmap_config[4] = { 230 + { 231 + /* Address 0x48 */ 232 + .reg_bits = 8, 233 + .val_bits = 8, 234 + .max_register = 0xff, 235 + }, 236 + { 237 + /* Address 0x49 */ 238 + .reg_bits = 8, 239 + .val_bits = 8, 240 + .max_register = 0xff, 241 + }, 242 + { 243 + /* Address 0x4a */ 244 + .reg_bits = 8, 245 + .val_bits = 8, 246 + .max_register = 0xff, 247 + }, 248 + { 249 + /* Address 0x4b */ 250 + .reg_bits = 8, 251 + .val_bits = 8, 252 + .max_register = 0xff, 253 + }, 218 254 }; 219 255 220 256 static struct twl_mapping twl6030_map[] = { ··· 274 254 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 275 255 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 276 256 { SUB_CHIP_ID2, TWL6030_BASEADD_RSV }, 257 + 277 258 { SUB_CHIP_ID0, TWL6030_BASEADD_PM_MASTER }, 278 259 { SUB_CHIP_ID0, TWL6030_BASEADD_PM_SLAVE_MISC }, 279 - 280 260 { SUB_CHIP_ID0, TWL6030_BASEADD_RTC }, 281 261 { SUB_CHIP_ID0, TWL6030_BASEADD_MEM }, 282 262 { SUB_CHIP_ID1, TWL6025_BASEADD_CHARGER }, 263 + }; 264 + 265 + static struct regmap_config twl6030_regmap_config[3] = { 266 + { 267 + /* Address 0x48 */ 268 + .reg_bits = 8, 269 + .val_bits = 8, 270 + .max_register = 0xff, 271 + }, 272 + { 273 + /* Address 0x49 */ 274 + .reg_bits = 8, 275 + .val_bits = 8, 276 + .max_register = 0xff, 277 + }, 278 + { 279 + /* Address 0x4a */ 280 + .reg_bits = 8, 281 + .val_bits = 8, 282 + .max_register = 0xff, 283 + }, 283 284 }; 284 285 285 286 /*----------------------------------------------------------------------*/ ··· 324 283 int ret; 325 284 int sid; 326 285 struct twl_client *twl; 327 - struct i2c_msg *msg; 328 286 329 - if (unlikely(mod_no > TWL_MODULE_LAST)) { 287 + if (unlikely(mod_no >= TWL_MODULE_LAST)) { 330 288 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 331 289 return -EPERM; 332 290 } ··· 341 301 } 342 302 twl = &twl_modules[sid]; 343 303 344 - mutex_lock(&twl->xfer_lock); 345 - /* 346 - * [MSG1]: fill the register address data 347 - * fill the data Tx buffer 348 - */ 349 - msg = &twl->xfer_msg[0]; 350 - msg->addr = twl->address; 351 - msg->len = num_bytes + 1; 352 - msg->flags = 0; 353 - msg->buf = value; 354 - /* over write the first byte of buffer with the register address */ 355 - *value = twl_map[mod_no].base + reg; 356 - ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 1); 357 - mutex_unlock(&twl->xfer_lock); 304 + ret = regmap_bulk_write(twl->regmap, twl_map[mod_no].base + reg, 305 + value, num_bytes); 358 306 359 - /* i2c_transfer returns number of messages transferred */ 360 - if (ret != 1) { 361 - pr_err("%s: i2c_write failed to transfer all messages\n", 362 - DRIVER_NAME); 363 - if (ret < 0) 364 - return ret; 365 - else 366 - return -EIO; 367 - } else { 368 - return 0; 369 - } 307 + if (ret) 308 + pr_err("%s: Write failed (mod %d, reg 0x%02x count %d)\n", 309 + DRIVER_NAME, mod_no, reg, num_bytes); 310 + 311 + return ret; 370 312 } 371 313 EXPORT_SYMBOL(twl_i2c_write); 372 314 ··· 364 342 int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes) 365 343 { 366 344 int ret; 367 - u8 val; 368 345 int sid; 369 346 struct twl_client *twl; 370 - struct i2c_msg *msg; 371 347 372 - if (unlikely(mod_no > TWL_MODULE_LAST)) { 348 + if (unlikely(mod_no >= TWL_MODULE_LAST)) { 373 349 pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no); 374 350 return -EPERM; 375 351 } ··· 383 363 } 384 364 twl = &twl_modules[sid]; 385 365 386 - mutex_lock(&twl->xfer_lock); 387 - /* [MSG1] fill the register address data */ 388 - msg = &twl->xfer_msg[0]; 389 - msg->addr = twl->address; 390 - msg->len = 1; 391 - msg->flags = 0; /* Read the register value */ 392 - val = twl_map[mod_no].base + reg; 393 - msg->buf = &val; 394 - /* [MSG2] fill the data rx buffer */ 395 - msg = &twl->xfer_msg[1]; 396 - msg->addr = twl->address; 397 - msg->flags = I2C_M_RD; /* Read the register value */ 398 - msg->len = num_bytes; /* only n bytes */ 399 - msg->buf = value; 400 - ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 2); 401 - mutex_unlock(&twl->xfer_lock); 366 + ret = regmap_bulk_read(twl->regmap, twl_map[mod_no].base + reg, 367 + value, num_bytes); 402 368 403 - /* i2c_transfer returns number of messages transferred */ 404 - if (ret != 2) { 405 - pr_err("%s: i2c_read failed to transfer all messages\n", 406 - DRIVER_NAME); 407 - if (ret < 0) 408 - return ret; 409 - else 410 - return -EIO; 411 - } else { 412 - return 0; 413 - } 369 + if (ret) 370 + pr_err("%s: Read failed (mod %d, reg 0x%02x count %d)\n", 371 + DRIVER_NAME, mod_no, reg, num_bytes); 372 + 373 + return ret; 414 374 } 415 375 EXPORT_SYMBOL(twl_i2c_read); 416 376 ··· 404 404 */ 405 405 int twl_i2c_write_u8(u8 mod_no, u8 value, u8 reg) 406 406 { 407 - 408 - /* 2 bytes offset 1 contains the data offset 0 is used by i2c_write */ 409 - u8 temp_buffer[2] = { 0 }; 410 - /* offset 1 contains the data */ 411 - temp_buffer[1] = value; 412 - return twl_i2c_write(mod_no, temp_buffer, reg, 1); 407 + return twl_i2c_write(mod_no, &value, reg, 1); 413 408 } 414 409 EXPORT_SYMBOL(twl_i2c_write_u8); 415 410 ··· 641 646 return PTR_ERR(child); 642 647 } 643 648 644 - if (IS_ENABLED(CONFIG_TWL4030_MADC) && pdata->madc) { 645 - child = add_child(2, "twl4030_madc", 649 + if (IS_ENABLED(CONFIG_TWL4030_MADC) && pdata->madc && 650 + twl_class_is_4030()) { 651 + child = add_child(SUB_CHIP_ID2, "twl4030_madc", 646 652 pdata->madc, sizeof(*pdata->madc), 647 653 true, irq_base + MADC_INTR_OFFSET, 0); 648 654 if (IS_ERR(child)) ··· 659 663 * HW security concerns, and "least privilege". 660 664 */ 661 665 sub_chip_id = twl_map[TWL_MODULE_RTC].sid; 662 - child = add_child(sub_chip_id, "twl_rtc", 663 - NULL, 0, 666 + child = add_child(sub_chip_id, "twl_rtc", NULL, 0, 664 667 true, irq_base + RTC_INTR_OFFSET, 0); 665 668 if (IS_ERR(child)) 666 669 return PTR_ERR(child); 667 670 } 668 671 669 - if (IS_ENABLED(CONFIG_PWM_TWL6030) && twl_class_is_6030()) { 670 - child = add_child(SUB_CHIP_ID1, "twl6030-pwm", NULL, 0, 672 + if (IS_ENABLED(CONFIG_PWM_TWL)) { 673 + child = add_child(SUB_CHIP_ID1, "twl-pwm", NULL, 0, 674 + false, 0, 0); 675 + if (IS_ERR(child)) 676 + return PTR_ERR(child); 677 + } 678 + 679 + if (IS_ENABLED(CONFIG_PWM_TWL_LED)) { 680 + child = add_child(SUB_CHIP_ID1, "twl-pwmled", NULL, 0, 671 681 false, 0, 0); 672 682 if (IS_ERR(child)) 673 683 return PTR_ERR(child); ··· 725 723 726 724 } 727 725 728 - child = add_child(0, "twl4030_usb", 729 - pdata->usb, sizeof(*pdata->usb), 730 - true, 726 + child = add_child(SUB_CHIP_ID0, "twl4030_usb", 727 + pdata->usb, sizeof(*pdata->usb), true, 731 728 /* irq0 = USB_PRES, irq1 = USB */ 732 729 irq_base + USB_PRES_INTR_OFFSET, 733 730 irq_base + USB_INTR_OFFSET); ··· 774 773 775 774 pdata->usb->features = features; 776 775 777 - child = add_child(0, "twl6030_usb", 778 - pdata->usb, sizeof(*pdata->usb), 779 - true, 776 + child = add_child(SUB_CHIP_ID0, "twl6030_usb", 777 + pdata->usb, sizeof(*pdata->usb), true, 780 778 /* irq1 = VBUS_PRES, irq0 = USB ID */ 781 779 irq_base + USBOTG_INTR_OFFSET, 782 780 irq_base + USB_PRES_INTR_OFFSET); ··· 799 799 } 800 800 801 801 if (IS_ENABLED(CONFIG_TWL4030_WATCHDOG) && twl_class_is_4030()) { 802 - child = add_child(0, "twl4030_wdt", NULL, 0, false, 0, 0); 802 + child = add_child(SUB_CHIP_ID3, "twl4030_wdt", NULL, 0, 803 + false, 0, 0); 803 804 if (IS_ERR(child)) 804 805 return PTR_ERR(child); 805 806 } 806 807 807 808 if (IS_ENABLED(CONFIG_INPUT_TWL4030_PWRBUTTON) && twl_class_is_4030()) { 808 - child = add_child(1, "twl4030_pwrbutton", 809 - NULL, 0, true, irq_base + 8 + 0, 0); 809 + child = add_child(SUB_CHIP_ID3, "twl4030_pwrbutton", NULL, 0, 810 + true, irq_base + 8 + 0, 0); 810 811 if (IS_ERR(child)) 811 812 return PTR_ERR(child); 812 813 } 813 814 814 815 if (IS_ENABLED(CONFIG_MFD_TWL4030_AUDIO) && pdata->audio && 815 816 twl_class_is_4030()) { 816 - sub_chip_id = twl_map[TWL_MODULE_AUDIO_VOICE].sid; 817 - child = add_child(sub_chip_id, "twl4030-audio", 817 + child = add_child(SUB_CHIP_ID1, "twl4030-audio", 818 818 pdata->audio, sizeof(*pdata->audio), 819 819 false, 0, 0); 820 820 if (IS_ERR(child)) ··· 1054 1054 1055 1055 if (IS_ENABLED(CONFIG_CHARGER_TWL4030) && pdata->bci && 1056 1056 !(features & (TPS_SUBSET | TWL5031))) { 1057 - child = add_child(3, "twl4030_bci", 1057 + child = add_child(SUB_CHIP_ID3, "twl4030_bci", 1058 1058 pdata->bci, sizeof(*pdata->bci), false, 1059 1059 /* irq0 = CHG_PRES, irq1 = BCI */ 1060 1060 irq_base + BCI_PRES_INTR_OFFSET, ··· 1077 1077 { 1078 1078 int e = 0; 1079 1079 1080 - e = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, 1081 - TWL4030_PM_MASTER_PROTECT_KEY); 1080 + e = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 0, 1081 + TWL4030_PM_MASTER_PROTECT_KEY); 1082 1082 return e; 1083 1083 } 1084 1084 ··· 1086 1086 { 1087 1087 int e = 0; 1088 1088 1089 - e |= twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 1090 - TWL4030_PM_MASTER_KEY_CFG1, 1091 - TWL4030_PM_MASTER_PROTECT_KEY); 1092 - e |= twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 1093 - TWL4030_PM_MASTER_KEY_CFG2, 1094 - TWL4030_PM_MASTER_PROTECT_KEY); 1089 + e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1, 1090 + TWL4030_PM_MASTER_PROTECT_KEY); 1091 + e |= twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG2, 1092 + TWL4030_PM_MASTER_PROTECT_KEY); 1095 1093 1096 1094 return e; 1097 1095 } ··· 1174 1176 struct twl4030_platform_data *pdata = client->dev.platform_data; 1175 1177 struct device_node *node = client->dev.of_node; 1176 1178 struct platform_device *pdev; 1179 + struct regmap_config *twl_regmap_config; 1177 1180 int irq_base = 0; 1178 1181 int status; 1179 1182 unsigned i, num_slaves; ··· 1228 1229 if ((id->driver_data) & TWL6030_CLASS) { 1229 1230 twl_id = TWL6030_CLASS_ID; 1230 1231 twl_map = &twl6030_map[0]; 1232 + twl_regmap_config = twl6030_regmap_config; 1231 1233 num_slaves = TWL_NUM_SLAVES - 1; 1232 1234 } else { 1233 1235 twl_id = TWL4030_CLASS_ID; 1234 1236 twl_map = &twl4030_map[0]; 1237 + twl_regmap_config = twl4030_regmap_config; 1235 1238 num_slaves = TWL_NUM_SLAVES; 1236 1239 } 1237 1240 1238 1241 for (i = 0; i < num_slaves; i++) { 1239 1242 struct twl_client *twl = &twl_modules[i]; 1240 1243 1241 - twl->address = client->addr + i; 1242 1244 if (i == 0) { 1243 1245 twl->client = client; 1244 1246 } else { 1245 1247 twl->client = i2c_new_dummy(client->adapter, 1246 - twl->address); 1248 + client->addr + i); 1247 1249 if (!twl->client) { 1248 1250 dev_err(&client->dev, 1249 1251 "can't attach client %d\n", i); ··· 1252 1252 goto fail; 1253 1253 } 1254 1254 } 1255 - mutex_init(&twl->xfer_lock); 1255 + 1256 + twl->regmap = devm_regmap_init_i2c(twl->client, 1257 + &twl_regmap_config[i]); 1258 + if (IS_ERR(twl->regmap)) { 1259 + status = PTR_ERR(twl->regmap); 1260 + dev_err(&client->dev, 1261 + "Failed to allocate regmap %d, err: %d\n", i, 1262 + status); 1263 + goto fail; 1264 + } 1256 1265 } 1257 1266 1258 1267 inuse = true;
+5 -5
drivers/mfd/twl4030-irq.c
··· 295 295 irqreturn_t ret; 296 296 u8 pih_isr; 297 297 298 - ret = twl_i2c_read_u8(TWL4030_MODULE_PIH, &pih_isr, 299 - REG_PIH_ISR_P1); 298 + ret = twl_i2c_read_u8(TWL_MODULE_PIH, &pih_isr, 299 + REG_PIH_ISR_P1); 300 300 if (ret) { 301 301 pr_warning("twl4030: I2C error %d reading PIH ISR\n", ret); 302 302 return IRQ_NONE; ··· 501 501 } imr; 502 502 503 503 /* byte[0] gets overwritten as we write ... */ 504 - imr.word = cpu_to_le32(agent->imr << 8); 504 + imr.word = cpu_to_le32(agent->imr); 505 505 agent->imr_change_pending = false; 506 506 507 507 /* write the whole mask ... simpler than subsetting it */ ··· 526 526 * any processor on the other IRQ line, EDR registers are 527 527 * shared. 528 528 */ 529 - status = twl_i2c_read(sih->module, bytes + 1, 529 + status = twl_i2c_read(sih->module, bytes, 530 530 sih->edr_offset, sih->bytes_edr); 531 531 if (status) { 532 532 pr_err("twl4030: %s, %s --> %d\n", __func__, ··· 538 538 while (edge_change) { 539 539 int i = fls(edge_change) - 1; 540 540 struct irq_data *idata; 541 - int byte = 1 + (i >> 2); 541 + int byte = i >> 2; 542 542 int off = (i & 0x3) * 2; 543 543 unsigned int type; 544 544
+7 -7
drivers/mfd/twl4030-madc.c
··· 173 173 174 174 volt = (raw_volt * TEMP_STEP_SIZE) / TEMP_PSR_R; 175 175 /* Getting and calculating the supply current in micro ampers */ 176 - ret = twl_i2c_read_u8(TWL4030_MODULE_MAIN_CHARGE, &val, 176 + ret = twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE, &val, 177 177 REG_BCICTL2); 178 178 if (ret < 0) 179 179 return ret; ··· 196 196 int ret; 197 197 u8 val; 198 198 199 - ret = twl_i2c_read_u8(TWL4030_MODULE_MAIN_CHARGE, &val, 199 + ret = twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE, &val, 200 200 TWL4030_BCI_BCICTL1); 201 201 if (ret) 202 202 return ret; ··· 635 635 int ret; 636 636 u8 regval; 637 637 638 - ret = twl_i2c_read_u8(TWL4030_MODULE_MAIN_CHARGE, 638 + ret = twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE, 639 639 &regval, TWL4030_BCI_BCICTL1); 640 640 if (ret) { 641 641 dev_err(madc->dev, "unable to read BCICTL1 reg 0x%X", ··· 646 646 regval |= chan ? TWL4030_BCI_ITHEN : TWL4030_BCI_TYPEN; 647 647 else 648 648 regval &= chan ? ~TWL4030_BCI_ITHEN : ~TWL4030_BCI_TYPEN; 649 - ret = twl_i2c_write_u8(TWL4030_MODULE_MAIN_CHARGE, 649 + ret = twl_i2c_write_u8(TWL_MODULE_MAIN_CHARGE, 650 650 regval, TWL4030_BCI_BCICTL1); 651 651 if (ret) { 652 652 dev_err(madc->dev, "unable to write BCICTL1 reg 0x%X\n", ··· 668 668 u8 regval; 669 669 int ret; 670 670 671 - ret = twl_i2c_read_u8(TWL4030_MODULE_MAIN_CHARGE, 671 + ret = twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE, 672 672 &regval, TWL4030_MADC_CTRL1); 673 673 if (ret) { 674 674 dev_err(madc->dev, "unable to read madc ctrl1 reg 0x%X\n", ··· 725 725 if (ret < 0) 726 726 goto err_current_generator; 727 727 728 - ret = twl_i2c_read_u8(TWL4030_MODULE_MAIN_CHARGE, 728 + ret = twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE, 729 729 &regval, TWL4030_BCI_BCICTL1); 730 730 if (ret) { 731 731 dev_err(&pdev->dev, "unable to read reg BCI CTL1 0x%X\n", ··· 733 733 goto err_i2c; 734 734 } 735 735 regval |= TWL4030_BCI_MESBAT; 736 - ret = twl_i2c_write_u8(TWL4030_MODULE_MAIN_CHARGE, 736 + ret = twl_i2c_write_u8(TWL_MODULE_MAIN_CHARGE, 737 737 regval, TWL4030_BCI_BCICTL1); 738 738 if (ret) { 739 739 dev_err(&pdev->dev, "unable to write reg BCI Ctl1 0x%X\n",
+58 -80
drivers/mfd/twl4030-power.c
··· 128 128 { 129 129 int err; 130 130 131 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 132 - R_MEMORY_ADDRESS); 131 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_MEMORY_ADDRESS); 133 132 if (err) 134 133 goto out; 135 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, byte, 136 - R_MEMORY_DATA); 134 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, byte, R_MEMORY_DATA); 137 135 out: 138 136 return err; 139 137 } ··· 187 189 u8 data; 188 190 189 191 /* Set SLEEP to ACTIVE SEQ address for P3 */ 190 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 191 - R_SEQ_ADD_S2A3); 192 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_SEQ_ADD_S2A3); 192 193 if (err) 193 194 goto out; 194 195 195 196 /* P3 LVL_WAKEUP should be on LEVEL */ 196 - err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 197 - R_P3_SW_EVENTS); 197 + err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &data, R_P3_SW_EVENTS); 198 198 if (err) 199 199 goto out; 200 200 data |= LVL_WAKEUP; 201 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data, 202 - R_P3_SW_EVENTS); 201 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data, R_P3_SW_EVENTS); 203 202 out: 204 203 if (err) 205 204 pr_err("TWL4030 wakeup sequence for P3 config error\n"); ··· 209 214 u8 data; 210 215 211 216 /* Set SLEEP to ACTIVE SEQ address for P1 and P2 */ 212 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 213 - R_SEQ_ADD_S2A12); 217 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_SEQ_ADD_S2A12); 214 218 if (err) 215 219 goto out; 216 220 217 221 /* P1/P2 LVL_WAKEUP should be on LEVEL */ 218 - err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 219 - R_P1_SW_EVENTS); 222 + err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &data, R_P1_SW_EVENTS); 220 223 if (err) 221 224 goto out; 222 225 223 226 data |= LVL_WAKEUP; 224 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data, 225 - R_P1_SW_EVENTS); 227 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data, R_P1_SW_EVENTS); 226 228 if (err) 227 229 goto out; 228 230 229 - err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 230 - R_P2_SW_EVENTS); 231 + err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &data, R_P2_SW_EVENTS); 231 232 if (err) 232 233 goto out; 233 234 234 235 data |= LVL_WAKEUP; 235 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data, 236 - R_P2_SW_EVENTS); 236 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data, R_P2_SW_EVENTS); 237 237 if (err) 238 238 goto out; 239 239 240 240 if (machine_is_omap_3430sdp() || machine_is_omap_ldp()) { 241 241 /* Disabling AC charger effect on sleep-active transitions */ 242 - err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data, 243 - R_CFG_P1_TRANSITION); 242 + err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &data, 243 + R_CFG_P1_TRANSITION); 244 244 if (err) 245 245 goto out; 246 246 data &= ~(1<<1); 247 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data , 248 - R_CFG_P1_TRANSITION); 247 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, data, 248 + R_CFG_P1_TRANSITION); 249 249 if (err) 250 250 goto out; 251 251 } ··· 257 267 int err; 258 268 259 269 /* Set ACTIVE to SLEEP SEQ address in T2 memory*/ 260 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 261 - R_SEQ_ADD_A2S); 270 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_SEQ_ADD_A2S); 262 271 263 272 if (err) 264 273 pr_err("TWL4030 sleep sequence config error\n"); ··· 271 282 u8 rd_data; 272 283 273 284 /* Set WARM RESET SEQ address for P1 */ 274 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, 275 - R_SEQ_ADD_WARM); 285 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, address, R_SEQ_ADD_WARM); 276 286 if (err) 277 287 goto out; 278 288 279 289 /* P1/P2/P3 enable WARMRESET */ 280 - err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data, 281 - R_P1_SW_EVENTS); 290 + err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &rd_data, R_P1_SW_EVENTS); 282 291 if (err) 283 292 goto out; 284 293 285 294 rd_data |= ENABLE_WARMRESET; 286 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data, 287 - R_P1_SW_EVENTS); 295 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, rd_data, R_P1_SW_EVENTS); 288 296 if (err) 289 297 goto out; 290 298 291 - err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data, 292 - R_P2_SW_EVENTS); 293 - if (err) 294 - goto out; 295 - 296 - rd_data |= ENABLE_WARMRESET; 297 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data, 298 - R_P2_SW_EVENTS); 299 - if (err) 300 - goto out; 301 - 302 - err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data, 303 - R_P3_SW_EVENTS); 299 + err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &rd_data, R_P2_SW_EVENTS); 304 300 if (err) 305 301 goto out; 306 302 307 303 rd_data |= ENABLE_WARMRESET; 308 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data, 309 - R_P3_SW_EVENTS); 304 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, rd_data, R_P2_SW_EVENTS); 305 + if (err) 306 + goto out; 307 + 308 + err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &rd_data, R_P3_SW_EVENTS); 309 + if (err) 310 + goto out; 311 + 312 + rd_data |= ENABLE_WARMRESET; 313 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, rd_data, R_P3_SW_EVENTS); 310 314 out: 311 315 if (err) 312 316 pr_err("TWL4030 warmreset seq config error\n"); ··· 323 341 rconfig_addr = res_config_addrs[rconfig->resource]; 324 342 325 343 /* Set resource group */ 326 - err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &grp, 344 + err = twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &grp, 327 345 rconfig_addr + DEV_GRP_OFFSET); 328 346 if (err) { 329 347 pr_err("TWL4030 Resource %d group could not be read\n", ··· 334 352 if (rconfig->devgroup != TWL4030_RESCONFIG_UNDEF) { 335 353 grp &= ~DEV_GRP_MASK; 336 354 grp |= rconfig->devgroup << DEV_GRP_SHIFT; 337 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 355 + err = twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 338 356 grp, rconfig_addr + DEV_GRP_OFFSET); 339 357 if (err < 0) { 340 358 pr_err("TWL4030 failed to program devgroup\n"); ··· 343 361 } 344 362 345 363 /* Set resource types */ 346 - err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &type, 364 + err = twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &type, 347 365 rconfig_addr + TYPE_OFFSET); 348 366 if (err < 0) { 349 367 pr_err("TWL4030 Resource %d type could not be read\n", ··· 361 379 type |= rconfig->type2 << TYPE2_SHIFT; 362 380 } 363 381 364 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 382 + err = twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 365 383 type, rconfig_addr + TYPE_OFFSET); 366 384 if (err < 0) { 367 385 pr_err("TWL4030 failed to program resource type\n"); ··· 369 387 } 370 388 371 389 /* Set remap states */ 372 - err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &remap, 390 + err = twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &remap, 373 391 rconfig_addr + REMAP_OFFSET); 374 392 if (err < 0) { 375 393 pr_err("TWL4030 Resource %d remap could not be read\n", ··· 387 405 remap |= rconfig->remap_sleep << SLEEP_STATE_SHIFT; 388 406 } 389 407 390 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 408 + err = twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 391 409 remap, 392 410 rconfig_addr + REMAP_OFFSET); 393 411 if (err < 0) { ··· 445 463 { 446 464 int err = 0; 447 465 448 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 449 - TWL4030_PM_MASTER_KEY_CFG1, 450 - TWL4030_PM_MASTER_PROTECT_KEY); 466 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1, 467 + TWL4030_PM_MASTER_PROTECT_KEY); 451 468 if (err) { 452 469 pr_err("twl4030: unable to unlock PROTECT_KEY\n"); 453 470 return err; 454 471 } 455 472 456 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 457 - TWL4030_PM_MASTER_KEY_CFG2, 458 - TWL4030_PM_MASTER_PROTECT_KEY); 473 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG2, 474 + TWL4030_PM_MASTER_PROTECT_KEY); 459 475 if (err) { 460 476 pr_err("twl4030: unable to unlock PROTECT_KEY\n"); 461 477 return err; 462 478 } 463 479 464 480 if (flags & TWL4030_WRST_SCRIPT) { 465 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, 466 - R_SEQ_ADD_WARM); 481 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, END_OF_SCRIPT, 482 + R_SEQ_ADD_WARM); 467 483 if (err) 468 484 return err; 469 485 } 470 486 if (flags & TWL4030_WAKEUP12_SCRIPT) { 471 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, 472 - R_SEQ_ADD_S2A12); 487 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, END_OF_SCRIPT, 488 + R_SEQ_ADD_S2A12); 473 489 if (err) 474 490 return err; 475 491 } 476 492 if (flags & TWL4030_WAKEUP3_SCRIPT) { 477 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, 478 - R_SEQ_ADD_S2A3); 493 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, END_OF_SCRIPT, 494 + R_SEQ_ADD_S2A3); 479 495 if (err) 480 496 return err; 481 497 } 482 498 if (flags & TWL4030_SLEEP_SCRIPT) { 483 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, 484 - R_SEQ_ADD_A2S); 499 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, END_OF_SCRIPT, 500 + R_SEQ_ADD_A2S); 485 501 if (err) 486 502 return err; 487 503 } 488 504 489 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, 490 - TWL4030_PM_MASTER_PROTECT_KEY); 505 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 0, 506 + TWL4030_PM_MASTER_PROTECT_KEY); 491 507 if (err) 492 508 pr_err("TWL4030 Unable to relock registers\n"); 493 509 ··· 501 521 { 502 522 int err; 503 523 504 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, PWR_DEVOFF, 524 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, PWR_DEVOFF, 505 525 TWL4030_PM_MASTER_P1_SW_EVENTS); 506 526 if (err) 507 527 pr_err("TWL4030 Unable to power off\n"); ··· 514 534 struct twl4030_resconfig *resconfig; 515 535 u8 val, address = twl4030_start_script_address; 516 536 517 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 518 - TWL4030_PM_MASTER_KEY_CFG1, 519 - TWL4030_PM_MASTER_PROTECT_KEY); 537 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1, 538 + TWL4030_PM_MASTER_PROTECT_KEY); 520 539 if (err) 521 540 goto unlock; 522 541 523 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 524 - TWL4030_PM_MASTER_KEY_CFG2, 525 - TWL4030_PM_MASTER_PROTECT_KEY); 542 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG2, 543 + TWL4030_PM_MASTER_PROTECT_KEY); 526 544 if (err) 527 545 goto unlock; 528 546 ··· 545 567 /* Board has to be wired properly to use this feature */ 546 568 if (twl4030_scripts->use_poweroff && !pm_power_off) { 547 569 /* Default for SEQ_OFFSYNC is set, lets ensure this */ 548 - err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &val, 570 + err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &val, 549 571 TWL4030_PM_MASTER_CFG_P123_TRANSITION); 550 572 if (err) { 551 573 pr_warning("TWL4030 Unable to read registers\n"); 552 574 553 575 } else if (!(val & SEQ_OFFSYNC)) { 554 576 val |= SEQ_OFFSYNC; 555 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, val, 577 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, val, 556 578 TWL4030_PM_MASTER_CFG_P123_TRANSITION); 557 579 if (err) { 558 580 pr_err("TWL4030 Unable to setup SEQ_OFFSYNC\n"); ··· 564 586 } 565 587 566 588 relock: 567 - err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, 568 - TWL4030_PM_MASTER_PROTECT_KEY); 589 + err = twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 0, 590 + TWL4030_PM_MASTER_PROTECT_KEY); 569 591 if (err) 570 592 pr_err("TWL4030 Unable to relock registers\n"); 571 593 return;
+2 -2
drivers/mfd/twl6030-irq.c
··· 355 355 static struct irq_chip twl6030_irq_chip; 356 356 int status = 0; 357 357 int i; 358 - u8 mask[4]; 358 + u8 mask[3]; 359 359 360 360 nr_irqs = TWL6030_NR_IRQS; 361 361 ··· 370 370 371 371 irq_end = irq_base + nr_irqs; 372 372 373 + mask[0] = 0xFF; 373 374 mask[1] = 0xFF; 374 375 mask[2] = 0xFF; 375 - mask[3] = 0xFF; 376 376 377 377 /* mask all int lines */ 378 378 twl_i2c_write(TWL_MODULE_PIH, &mask[0], REG_INT_MSK_LINE_A, 3);
+84 -54
drivers/mfd/twl6040-core.c drivers/mfd/twl6040.c
··· 37 37 #include <linux/delay.h> 38 38 #include <linux/i2c.h> 39 39 #include <linux/regmap.h> 40 - #include <linux/err.h> 41 40 #include <linux/mfd/core.h> 42 41 #include <linux/mfd/twl6040.h> 43 42 #include <linux/regulator/consumer.h> ··· 103 104 EXPORT_SYMBOL(twl6040_clear_bits); 104 105 105 106 /* twl6040 codec manual power-up sequence */ 106 - static int twl6040_power_up(struct twl6040 *twl6040) 107 + static int twl6040_power_up_manual(struct twl6040 *twl6040) 107 108 { 108 109 u8 ldoctl, ncpctl, lppllctl; 109 110 int ret; ··· 157 158 ldoctl &= ~(TWL6040_HSLDOENA | TWL6040_REFENA | TWL6040_OSCENA); 158 159 twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl); 159 160 161 + dev_err(twl6040->dev, "manual power-up failed\n"); 160 162 return ret; 161 163 } 162 164 163 165 /* twl6040 manual power-down sequence */ 164 - static void twl6040_power_down(struct twl6040 *twl6040) 166 + static void twl6040_power_down_manual(struct twl6040 *twl6040) 165 167 { 166 168 u8 ncpctl, ldoctl, lppllctl; 167 169 ··· 192 192 twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl); 193 193 } 194 194 195 - static irqreturn_t twl6040_naudint_handler(int irq, void *data) 195 + static irqreturn_t twl6040_readyint_handler(int irq, void *data) 196 196 { 197 197 struct twl6040 *twl6040 = data; 198 - u8 intid, status; 199 198 200 - intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID); 199 + complete(&twl6040->ready); 201 200 202 - if (intid & TWL6040_READYINT) 203 - complete(&twl6040->ready); 201 + return IRQ_HANDLED; 202 + } 204 203 205 - if (intid & TWL6040_THINT) { 206 - status = twl6040_reg_read(twl6040, TWL6040_REG_STATUS); 207 - if (status & TWL6040_TSHUTDET) { 208 - dev_warn(twl6040->dev, 209 - "Thermal shutdown, powering-off"); 210 - twl6040_power(twl6040, 0); 211 - } else { 212 - dev_warn(twl6040->dev, 213 - "Leaving thermal shutdown, powering-on"); 214 - twl6040_power(twl6040, 1); 215 - } 204 + static irqreturn_t twl6040_thint_handler(int irq, void *data) 205 + { 206 + struct twl6040 *twl6040 = data; 207 + u8 status; 208 + 209 + status = twl6040_reg_read(twl6040, TWL6040_REG_STATUS); 210 + if (status & TWL6040_TSHUTDET) { 211 + dev_warn(twl6040->dev, "Thermal shutdown, powering-off"); 212 + twl6040_power(twl6040, 0); 213 + } else { 214 + dev_warn(twl6040->dev, "Leaving thermal shutdown, powering-on"); 215 + twl6040_power(twl6040, 1); 216 216 } 217 217 218 218 return IRQ_HANDLED; 219 219 } 220 220 221 - static int twl6040_power_up_completion(struct twl6040 *twl6040, 222 - int naudint) 221 + static int twl6040_power_up_automatic(struct twl6040 *twl6040) 223 222 { 224 223 int time_left; 225 - u8 intid; 224 + 225 + gpio_set_value(twl6040->audpwron, 1); 226 226 227 227 time_left = wait_for_completion_timeout(&twl6040->ready, 228 228 msecs_to_jiffies(144)); 229 229 if (!time_left) { 230 + u8 intid; 231 + 232 + dev_warn(twl6040->dev, "timeout waiting for READYINT\n"); 230 233 intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID); 231 234 if (!(intid & TWL6040_READYINT)) { 232 - dev_err(twl6040->dev, 233 - "timeout waiting for READYINT\n"); 235 + dev_err(twl6040->dev, "automatic power-up failed\n"); 236 + gpio_set_value(twl6040->audpwron, 0); 234 237 return -ETIMEDOUT; 235 238 } 236 239 } ··· 243 240 244 241 int twl6040_power(struct twl6040 *twl6040, int on) 245 242 { 246 - int audpwron = twl6040->audpwron; 247 - int naudint = twl6040->irq; 248 243 int ret = 0; 249 244 250 245 mutex_lock(&twl6040->mutex); ··· 252 251 if (twl6040->power_count++) 253 252 goto out; 254 253 255 - if (gpio_is_valid(audpwron)) { 256 - /* use AUDPWRON line */ 257 - gpio_set_value(audpwron, 1); 258 - /* wait for power-up completion */ 259 - ret = twl6040_power_up_completion(twl6040, naudint); 254 + if (gpio_is_valid(twl6040->audpwron)) { 255 + /* use automatic power-up sequence */ 256 + ret = twl6040_power_up_automatic(twl6040); 260 257 if (ret) { 261 - dev_err(twl6040->dev, 262 - "automatic power-down failed\n"); 263 258 twl6040->power_count = 0; 264 259 goto out; 265 260 } 266 261 } else { 267 262 /* use manual power-up sequence */ 268 - ret = twl6040_power_up(twl6040); 263 + ret = twl6040_power_up_manual(twl6040); 269 264 if (ret) { 270 - dev_err(twl6040->dev, 271 - "manual power-up failed\n"); 272 265 twl6040->power_count = 0; 273 266 goto out; 274 267 } ··· 283 288 if (--twl6040->power_count) 284 289 goto out; 285 290 286 - if (gpio_is_valid(audpwron)) { 291 + if (gpio_is_valid(twl6040->audpwron)) { 287 292 /* use AUDPWRON line */ 288 - gpio_set_value(audpwron, 0); 293 + gpio_set_value(twl6040->audpwron, 0); 289 294 290 295 /* power-down sequence latency */ 291 296 usleep_range(500, 700); 292 297 } else { 293 298 /* use manual power-down sequence */ 294 - twl6040_power_down(twl6040); 299 + twl6040_power_down_manual(twl6040); 295 300 } 296 301 twl6040->sysclk = 0; 297 302 twl6040->mclk = 0; ··· 498 503 .readable_reg = twl6040_readable_reg, 499 504 }; 500 505 506 + static const struct regmap_irq twl6040_irqs[] = { 507 + { .reg_offset = 0, .mask = TWL6040_THINT, }, 508 + { .reg_offset = 0, .mask = TWL6040_PLUGINT | TWL6040_UNPLUGINT, }, 509 + { .reg_offset = 0, .mask = TWL6040_HOOKINT, }, 510 + { .reg_offset = 0, .mask = TWL6040_HFINT, }, 511 + { .reg_offset = 0, .mask = TWL6040_VIBINT, }, 512 + { .reg_offset = 0, .mask = TWL6040_READYINT, }, 513 + }; 514 + 515 + static struct regmap_irq_chip twl6040_irq_chip = { 516 + .name = "twl6040", 517 + .irqs = twl6040_irqs, 518 + .num_irqs = ARRAY_SIZE(twl6040_irqs), 519 + 520 + .num_regs = 1, 521 + .status_base = TWL6040_REG_INTID, 522 + .mask_base = TWL6040_REG_INTMR, 523 + }; 524 + 501 525 static int __devinit twl6040_probe(struct i2c_client *client, 502 526 const struct i2c_device_id *id) 503 527 { ··· 592 578 goto gpio_err; 593 579 } 594 580 595 - /* codec interrupt */ 596 - ret = twl6040_irq_init(twl6040); 597 - if (ret) 581 + ret = regmap_add_irq_chip(twl6040->regmap, twl6040->irq, 582 + IRQF_ONESHOT, 0, &twl6040_irq_chip, 583 + &twl6040->irq_data); 584 + if (ret < 0) 598 585 goto irq_init_err; 599 586 600 - ret = request_threaded_irq(twl6040->irq_base + TWL6040_IRQ_READY, 601 - NULL, twl6040_naudint_handler, IRQF_ONESHOT, 587 + twl6040->irq_ready = regmap_irq_get_virq(twl6040->irq_data, 588 + TWL6040_IRQ_READY); 589 + twl6040->irq_th = regmap_irq_get_virq(twl6040->irq_data, 590 + TWL6040_IRQ_TH); 591 + 592 + ret = request_threaded_irq(twl6040->irq_ready, NULL, 593 + twl6040_readyint_handler, IRQF_ONESHOT, 602 594 "twl6040_irq_ready", twl6040); 603 595 if (ret) { 604 - dev_err(twl6040->dev, "READY IRQ request failed: %d\n", 605 - ret); 606 - goto irq_err; 596 + dev_err(twl6040->dev, "READY IRQ request failed: %d\n", ret); 597 + goto readyirq_err; 598 + } 599 + 600 + ret = request_threaded_irq(twl6040->irq_th, NULL, 601 + twl6040_thint_handler, IRQF_ONESHOT, 602 + "twl6040_irq_th", twl6040); 603 + if (ret) { 604 + dev_err(twl6040->dev, "Thermal IRQ request failed: %d\n", ret); 605 + goto thirq_err; 607 606 } 608 607 609 608 /* dual-access registers controlled by I2C only */ ··· 628 601 * The ASoC codec can work without pdata, pass the platform_data only if 629 602 * it has been provided. 630 603 */ 631 - irq = twl6040->irq_base + TWL6040_IRQ_PLUG; 604 + irq = regmap_irq_get_virq(twl6040->irq_data, TWL6040_IRQ_PLUG); 632 605 cell = &twl6040->cells[children]; 633 606 cell->name = "twl6040-codec"; 634 607 twl6040_codec_rsrc[0].start = irq; ··· 642 615 children++; 643 616 644 617 if (twl6040_has_vibra(pdata, node)) { 645 - irq = twl6040->irq_base + TWL6040_IRQ_VIB; 618 + irq = regmap_irq_get_virq(twl6040->irq_data, TWL6040_IRQ_VIB); 646 619 647 620 cell = &twl6040->cells[children]; 648 621 cell->name = "twl6040-vibra"; ··· 681 654 return 0; 682 655 683 656 mfd_err: 684 - free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040); 685 - irq_err: 686 - twl6040_irq_exit(twl6040); 657 + free_irq(twl6040->irq_th, twl6040); 658 + thirq_err: 659 + free_irq(twl6040->irq_ready, twl6040); 660 + readyirq_err: 661 + regmap_del_irq_chip(twl6040->irq, twl6040->irq_data); 687 662 irq_init_err: 688 663 if (gpio_is_valid(twl6040->audpwron)) 689 664 gpio_free(twl6040->audpwron); ··· 709 680 if (gpio_is_valid(twl6040->audpwron)) 710 681 gpio_free(twl6040->audpwron); 711 682 712 - free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040); 713 - twl6040_irq_exit(twl6040); 683 + free_irq(twl6040->irq_ready, twl6040); 684 + free_irq(twl6040->irq_th, twl6040); 685 + regmap_del_irq_chip(twl6040->irq, twl6040->irq_data); 714 686 715 687 mfd_remove_devices(&client->dev); 716 688 i2c_set_clientdata(client, NULL);
-205
drivers/mfd/twl6040-irq.c
··· 1 - /* 2 - * Interrupt controller support for TWL6040 3 - * 4 - * Author: Misael Lopez Cruz <misael.lopez@ti.com> 5 - * 6 - * Copyright: (C) 2011 Texas Instruments, Inc. 7 - * 8 - * This program is free software; you can redistribute it and/or modify 9 - * it under the terms of the GNU General Public License version 2 as 10 - * published by the Free Software Foundation. 11 - * 12 - * This program is distributed in the hope that it will be useful, but 13 - * WITHOUT ANY WARRANTY; without even the implied warranty of 14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 - * General Public License for more details. 16 - * 17 - * You should have received a copy of the GNU General Public License 18 - * along with this program; if not, write to the Free Software 19 - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 20 - * 02110-1301 USA 21 - * 22 - */ 23 - 24 - #include <linux/kernel.h> 25 - #include <linux/module.h> 26 - #include <linux/err.h> 27 - #include <linux/irq.h> 28 - #include <linux/of.h> 29 - #include <linux/irqdomain.h> 30 - #include <linux/interrupt.h> 31 - #include <linux/mfd/core.h> 32 - #include <linux/mfd/twl6040.h> 33 - 34 - struct twl6040_irq_data { 35 - int mask; 36 - int status; 37 - }; 38 - 39 - static struct twl6040_irq_data twl6040_irqs[] = { 40 - { 41 - .mask = TWL6040_THMSK, 42 - .status = TWL6040_THINT, 43 - }, 44 - { 45 - .mask = TWL6040_PLUGMSK, 46 - .status = TWL6040_PLUGINT | TWL6040_UNPLUGINT, 47 - }, 48 - { 49 - .mask = TWL6040_HOOKMSK, 50 - .status = TWL6040_HOOKINT, 51 - }, 52 - { 53 - .mask = TWL6040_HFMSK, 54 - .status = TWL6040_HFINT, 55 - }, 56 - { 57 - .mask = TWL6040_VIBMSK, 58 - .status = TWL6040_VIBINT, 59 - }, 60 - { 61 - .mask = TWL6040_READYMSK, 62 - .status = TWL6040_READYINT, 63 - }, 64 - }; 65 - 66 - static inline 67 - struct twl6040_irq_data *irq_to_twl6040_irq(struct twl6040 *twl6040, 68 - int irq) 69 - { 70 - return &twl6040_irqs[irq - twl6040->irq_base]; 71 - } 72 - 73 - static void twl6040_irq_lock(struct irq_data *data) 74 - { 75 - struct twl6040 *twl6040 = irq_data_get_irq_chip_data(data); 76 - 77 - mutex_lock(&twl6040->irq_mutex); 78 - } 79 - 80 - static void twl6040_irq_sync_unlock(struct irq_data *data) 81 - { 82 - struct twl6040 *twl6040 = irq_data_get_irq_chip_data(data); 83 - 84 - /* write back to hardware any change in irq mask */ 85 - if (twl6040->irq_masks_cur != twl6040->irq_masks_cache) { 86 - twl6040->irq_masks_cache = twl6040->irq_masks_cur; 87 - twl6040_reg_write(twl6040, TWL6040_REG_INTMR, 88 - twl6040->irq_masks_cur); 89 - } 90 - 91 - mutex_unlock(&twl6040->irq_mutex); 92 - } 93 - 94 - static void twl6040_irq_enable(struct irq_data *data) 95 - { 96 - struct twl6040 *twl6040 = irq_data_get_irq_chip_data(data); 97 - struct twl6040_irq_data *irq_data = irq_to_twl6040_irq(twl6040, 98 - data->irq); 99 - 100 - twl6040->irq_masks_cur &= ~irq_data->mask; 101 - } 102 - 103 - static void twl6040_irq_disable(struct irq_data *data) 104 - { 105 - struct twl6040 *twl6040 = irq_data_get_irq_chip_data(data); 106 - struct twl6040_irq_data *irq_data = irq_to_twl6040_irq(twl6040, 107 - data->irq); 108 - 109 - twl6040->irq_masks_cur |= irq_data->mask; 110 - } 111 - 112 - static struct irq_chip twl6040_irq_chip = { 113 - .name = "twl6040", 114 - .irq_bus_lock = twl6040_irq_lock, 115 - .irq_bus_sync_unlock = twl6040_irq_sync_unlock, 116 - .irq_enable = twl6040_irq_enable, 117 - .irq_disable = twl6040_irq_disable, 118 - }; 119 - 120 - static irqreturn_t twl6040_irq_thread(int irq, void *data) 121 - { 122 - struct twl6040 *twl6040 = data; 123 - u8 intid; 124 - int i; 125 - 126 - intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID); 127 - 128 - /* apply masking and report (backwards to handle READYINT first) */ 129 - for (i = ARRAY_SIZE(twl6040_irqs) - 1; i >= 0; i--) { 130 - if (twl6040->irq_masks_cur & twl6040_irqs[i].mask) 131 - intid &= ~twl6040_irqs[i].status; 132 - if (intid & twl6040_irqs[i].status) 133 - handle_nested_irq(twl6040->irq_base + i); 134 - } 135 - 136 - /* ack unmasked irqs */ 137 - twl6040_reg_write(twl6040, TWL6040_REG_INTID, intid); 138 - 139 - return IRQ_HANDLED; 140 - } 141 - 142 - int twl6040_irq_init(struct twl6040 *twl6040) 143 - { 144 - struct device_node *node = twl6040->dev->of_node; 145 - int i, nr_irqs, irq_base, ret; 146 - u8 val; 147 - 148 - mutex_init(&twl6040->irq_mutex); 149 - 150 - /* mask the individual interrupt sources */ 151 - twl6040->irq_masks_cur = TWL6040_ALLINT_MSK; 152 - twl6040->irq_masks_cache = TWL6040_ALLINT_MSK; 153 - twl6040_reg_write(twl6040, TWL6040_REG_INTMR, TWL6040_ALLINT_MSK); 154 - 155 - nr_irqs = ARRAY_SIZE(twl6040_irqs); 156 - 157 - irq_base = irq_alloc_descs(-1, 0, nr_irqs, 0); 158 - if (IS_ERR_VALUE(irq_base)) { 159 - dev_err(twl6040->dev, "Fail to allocate IRQ descs\n"); 160 - return irq_base; 161 - } 162 - twl6040->irq_base = irq_base; 163 - 164 - irq_domain_add_legacy(node, ARRAY_SIZE(twl6040_irqs), irq_base, 0, 165 - &irq_domain_simple_ops, NULL); 166 - 167 - /* Register them with genirq */ 168 - for (i = irq_base; i < irq_base + nr_irqs; i++) { 169 - irq_set_chip_data(i, twl6040); 170 - irq_set_chip_and_handler(i, &twl6040_irq_chip, 171 - handle_level_irq); 172 - irq_set_nested_thread(i, 1); 173 - 174 - /* ARM needs us to explicitly flag the IRQ as valid 175 - * and will set them noprobe when we do so. */ 176 - #ifdef CONFIG_ARM 177 - set_irq_flags(i, IRQF_VALID); 178 - #else 179 - irq_set_noprobe(i); 180 - #endif 181 - } 182 - 183 - ret = request_threaded_irq(twl6040->irq, NULL, twl6040_irq_thread, 184 - IRQF_ONESHOT, "twl6040", twl6040); 185 - if (ret) { 186 - dev_err(twl6040->dev, "failed to request IRQ %d: %d\n", 187 - twl6040->irq, ret); 188 - return ret; 189 - } 190 - 191 - /* reset interrupts */ 192 - val = twl6040_reg_read(twl6040, TWL6040_REG_INTID); 193 - 194 - /* interrupts cleared on write */ 195 - twl6040_clear_bits(twl6040, TWL6040_REG_ACCCTL, TWL6040_INTCLRMODE); 196 - 197 - return 0; 198 - } 199 - EXPORT_SYMBOL(twl6040_irq_init); 200 - 201 - void twl6040_irq_exit(struct twl6040 *twl6040) 202 - { 203 - free_irq(twl6040->irq, twl6040); 204 - } 205 - EXPORT_SYMBOL(twl6040_irq_exit);
+137
drivers/mfd/viperboard.c
··· 1 + /* 2 + * Nano River Technologies viperboard driver 3 + * 4 + * This is the core driver for the viperboard. There are cell drivers 5 + * available for I2C, ADC and both GPIOs. SPI is not yet supported. 6 + * The drivers do not support all features the board exposes. See user 7 + * manual of the viperboard. 8 + * 9 + * (C) 2012 by Lemonage GmbH 10 + * Author: Lars Poeschel <poeschel@lemonage.de> 11 + * All rights reserved. 12 + * 13 + * This program is free software; you can redistribute it and/or modify it 14 + * under the terms of the GNU General Public License as published by the 15 + * Free Software Foundation; either version 2 of the License, or (at your 16 + * option) any later version. 17 + * 18 + */ 19 + 20 + #include <linux/kernel.h> 21 + #include <linux/errno.h> 22 + #include <linux/module.h> 23 + #include <linux/slab.h> 24 + #include <linux/types.h> 25 + #include <linux/mutex.h> 26 + 27 + #include <linux/mfd/core.h> 28 + #include <linux/mfd/viperboard.h> 29 + 30 + #include <linux/usb.h> 31 + 32 + 33 + static const struct usb_device_id vprbrd_table[] = { 34 + { USB_DEVICE(0x2058, 0x1005) }, /* Nano River Technologies */ 35 + { } /* Terminating entry */ 36 + }; 37 + 38 + MODULE_DEVICE_TABLE(usb, vprbrd_table); 39 + 40 + static struct mfd_cell vprbrd_devs[] = { 41 + { 42 + .name = "viperboard-gpio", 43 + }, 44 + { 45 + .name = "viperboard-i2c", 46 + }, 47 + { 48 + .name = "viperboard-adc", 49 + }, 50 + }; 51 + 52 + static int vprbrd_probe(struct usb_interface *interface, 53 + const struct usb_device_id *id) 54 + { 55 + struct vprbrd *vb; 56 + 57 + u16 version = 0; 58 + int pipe, ret; 59 + 60 + /* allocate memory for our device state and initialize it */ 61 + vb = kzalloc(sizeof(*vb), GFP_KERNEL); 62 + if (vb == NULL) { 63 + dev_err(&interface->dev, "Out of memory\n"); 64 + return -ENOMEM; 65 + } 66 + 67 + mutex_init(&vb->lock); 68 + 69 + vb->usb_dev = usb_get_dev(interface_to_usbdev(interface)); 70 + 71 + /* save our data pointer in this interface device */ 72 + usb_set_intfdata(interface, vb); 73 + dev_set_drvdata(&vb->pdev.dev, vb); 74 + 75 + /* get version information, major first, minor then */ 76 + pipe = usb_rcvctrlpipe(vb->usb_dev, 0); 77 + ret = usb_control_msg(vb->usb_dev, pipe, VPRBRD_USB_REQUEST_MAJOR, 78 + VPRBRD_USB_TYPE_IN, 0x0000, 0x0000, vb->buf, 1, 79 + VPRBRD_USB_TIMEOUT_MS); 80 + if (ret == 1) 81 + version = vb->buf[0]; 82 + 83 + ret = usb_control_msg(vb->usb_dev, pipe, VPRBRD_USB_REQUEST_MINOR, 84 + VPRBRD_USB_TYPE_IN, 0x0000, 0x0000, vb->buf, 1, 85 + VPRBRD_USB_TIMEOUT_MS); 86 + if (ret == 1) { 87 + version <<= 8; 88 + version = version | vb->buf[0]; 89 + } 90 + 91 + dev_info(&interface->dev, 92 + "version %x.%02x found at bus %03d address %03d\n", 93 + version >> 8, version & 0xff, 94 + vb->usb_dev->bus->busnum, vb->usb_dev->devnum); 95 + 96 + ret = mfd_add_devices(&interface->dev, -1, vprbrd_devs, 97 + ARRAY_SIZE(vprbrd_devs), NULL, 0, NULL); 98 + if (ret != 0) { 99 + dev_err(&interface->dev, "Failed to add mfd devices to core."); 100 + goto error; 101 + } 102 + 103 + return 0; 104 + 105 + error: 106 + if (vb) { 107 + usb_put_dev(vb->usb_dev); 108 + kfree(vb); 109 + } 110 + 111 + return ret; 112 + } 113 + 114 + static void vprbrd_disconnect(struct usb_interface *interface) 115 + { 116 + struct vprbrd *vb = usb_get_intfdata(interface); 117 + 118 + mfd_remove_devices(&interface->dev); 119 + usb_set_intfdata(interface, NULL); 120 + usb_put_dev(vb->usb_dev); 121 + kfree(vb); 122 + 123 + dev_dbg(&interface->dev, "disconnected\n"); 124 + } 125 + 126 + static struct usb_driver vprbrd_driver = { 127 + .name = "viperboard", 128 + .probe = vprbrd_probe, 129 + .disconnect = vprbrd_disconnect, 130 + .id_table = vprbrd_table, 131 + }; 132 + 133 + module_usb_driver(vprbrd_driver); 134 + 135 + MODULE_DESCRIPTION("Nano River Technologies viperboard mfd core driver"); 136 + MODULE_AUTHOR("Lars Poeschel <poeschel@lemonage.de>"); 137 + MODULE_LICENSE("GPL");
+32 -3
drivers/mfd/wm5102-tables.c
··· 56 56 { 0x80, 0x0000 }, 57 57 }; 58 58 59 + static const struct reg_default wm5102_revb_patch[] = { 60 + { 0x80, 0x0003 }, 61 + { 0x081, 0xE022 }, 62 + { 0x410, 0x6080 }, 63 + { 0x418, 0x6080 }, 64 + { 0x420, 0x6080 }, 65 + { 0x428, 0xC000 }, 66 + { 0x441, 0x8014 }, 67 + { 0x458, 0x000b }, 68 + { 0x80, 0x0000 }, 69 + }; 70 + 59 71 /* We use a function so we can use ARRAY_SIZE() */ 60 72 int wm5102_patch(struct arizona *arizona) 61 73 { ··· 77 65 wm5102_reva_patch, 78 66 ARRAY_SIZE(wm5102_reva_patch)); 79 67 default: 80 - return 0; 68 + return regmap_register_patch(arizona->regmap, 69 + wm5102_revb_patch, 70 + ARRAY_SIZE(wm5102_revb_patch)); 81 71 } 82 72 } 83 73 ··· 305 291 { 0x000001AA, 0x0004 }, /* R426 - FLL2 GPIO Clock */ 306 292 { 0x00000200, 0x0006 }, /* R512 - Mic Charge Pump 1 */ 307 293 { 0x00000210, 0x00D4 }, /* R528 - LDO1 Control 1 */ 294 + { 0x00000212, 0x0001 }, /* R530 - LDO1 Control 2 */ 308 295 { 0x00000213, 0x0344 }, /* R531 - LDO2 Control 1 */ 309 296 { 0x00000218, 0x01A6 }, /* R536 - Mic Bias Ctrl 1 */ 310 297 { 0x00000219, 0x01A6 }, /* R537 - Mic Bias Ctrl 2 */ ··· 1071 1056 case ARIZONA_FLL1_CONTROL_5: 1072 1057 case ARIZONA_FLL1_CONTROL_6: 1073 1058 case ARIZONA_FLL1_LOOP_FILTER_TEST_1: 1059 + case ARIZONA_FLL1_NCO_TEST_0: 1074 1060 case ARIZONA_FLL1_SYNCHRONISER_1: 1075 1061 case ARIZONA_FLL1_SYNCHRONISER_2: 1076 1062 case ARIZONA_FLL1_SYNCHRONISER_3: ··· 1087 1071 case ARIZONA_FLL2_CONTROL_5: 1088 1072 case ARIZONA_FLL2_CONTROL_6: 1089 1073 case ARIZONA_FLL2_LOOP_FILTER_TEST_1: 1074 + case ARIZONA_FLL2_NCO_TEST_0: 1090 1075 case ARIZONA_FLL2_SYNCHRONISER_1: 1091 1076 case ARIZONA_FLL2_SYNCHRONISER_2: 1092 1077 case ARIZONA_FLL2_SYNCHRONISER_3: ··· 1822 1805 case ARIZONA_DSP1_CLOCKING_1: 1823 1806 case ARIZONA_DSP1_STATUS_1: 1824 1807 case ARIZONA_DSP1_STATUS_2: 1808 + case ARIZONA_DSP1_STATUS_3: 1825 1809 return true; 1826 1810 default: 1827 1811 return false; ··· 1831 1813 1832 1814 static bool wm5102_volatile_register(struct device *dev, unsigned int reg) 1833 1815 { 1816 + if (reg > 0xffff) 1817 + return true; 1818 + 1834 1819 switch (reg) { 1835 1820 case ARIZONA_SOFTWARE_RESET: 1836 1821 case ARIZONA_DEVICE_REVISION: 1837 1822 case ARIZONA_OUTPUT_STATUS_1: 1823 + case ARIZONA_RAW_OUTPUT_STATUS_1: 1824 + case ARIZONA_SLIMBUS_RX_PORT_STATUS: 1825 + case ARIZONA_SLIMBUS_TX_PORT_STATUS: 1838 1826 case ARIZONA_SAMPLE_RATE_1_STATUS: 1839 1827 case ARIZONA_SAMPLE_RATE_2_STATUS: 1840 1828 case ARIZONA_SAMPLE_RATE_3_STATUS: 1841 1829 case ARIZONA_HAPTICS_STATUS: 1842 1830 case ARIZONA_ASYNC_SAMPLE_RATE_1_STATUS: 1831 + case ARIZONA_FLL1_NCO_TEST_0: 1832 + case ARIZONA_FLL2_NCO_TEST_0: 1843 1833 case ARIZONA_FX_CTRL2: 1844 1834 case ARIZONA_INTERRUPT_STATUS_1: 1845 1835 case ARIZONA_INTERRUPT_STATUS_2: ··· 1873 1847 case ARIZONA_AOD_IRQ_RAW_STATUS: 1874 1848 case ARIZONA_DSP1_STATUS_1: 1875 1849 case ARIZONA_DSP1_STATUS_2: 1850 + case ARIZONA_DSP1_STATUS_3: 1876 1851 case ARIZONA_HEADPHONE_DETECT_2: 1877 1852 case ARIZONA_MIC_DETECT_3: 1878 1853 return true; ··· 1882 1855 } 1883 1856 } 1884 1857 1858 + #define WM5102_MAX_REGISTER 0x1a8fff 1859 + 1885 1860 const struct regmap_config wm5102_spi_regmap = { 1886 1861 .reg_bits = 32, 1887 1862 .pad_bits = 16, 1888 1863 .val_bits = 16, 1889 1864 1890 - .max_register = ARIZONA_DSP1_STATUS_2, 1865 + .max_register = WM5102_MAX_REGISTER, 1891 1866 .readable_reg = wm5102_readable_register, 1892 1867 .volatile_reg = wm5102_volatile_register, 1893 1868 ··· 1903 1874 .reg_bits = 32, 1904 1875 .val_bits = 16, 1905 1876 1906 - .max_register = ARIZONA_DSP1_STATUS_2, 1877 + .max_register = WM5102_MAX_REGISTER, 1907 1878 .readable_reg = wm5102_readable_register, 1908 1879 .volatile_reg = wm5102_volatile_register, 1909 1880
+4 -13
drivers/mfd/wm8994-core.c
··· 535 535 break; 536 536 case 2: 537 537 case 3: 538 + default: 538 539 regmap_patch = wm8994_revc_patch; 539 540 patch_regs = ARRAY_SIZE(wm8994_revc_patch); 540 - break; 541 - default: 542 541 break; 543 542 } 544 543 break; ··· 557 558 /* Revision C did not change the relevant layer */ 558 559 if (wm8994->revision > 1) 559 560 wm8994->revision++; 560 - switch (wm8994->revision) { 561 - case 0: 562 - case 1: 563 - case 2: 564 - case 3: 565 - regmap_patch = wm1811_reva_patch; 566 - patch_regs = ARRAY_SIZE(wm1811_reva_patch); 567 - break; 568 - default: 569 - break; 570 - } 561 + 562 + regmap_patch = wm1811_reva_patch; 563 + patch_regs = ARRAY_SIZE(wm1811_reva_patch); 571 564 break; 572 565 573 566 default:
+2
drivers/mmc/host/Makefile
··· 49 49 50 50 obj-$(CONFIG_MMC_REALTEK_PCI) += rtsx_pci_sdmmc.o 51 51 52 + obj-$(CONFIG_MMC_REALTEK_PCI) += rtsx_pci_sdmmc.o 53 + 52 54 obj-$(CONFIG_MMC_SDHCI_PLTFM) += sdhci-pltfm.o 53 55 obj-$(CONFIG_MMC_SDHCI_CNS3XXX) += sdhci-cns3xxx.o 54 56 obj-$(CONFIG_MMC_SDHCI_ESDHC_IMX) += sdhci-esdhc-imx.o
+2 -2
drivers/mmc/host/rtsx_pci_sdmmc.c
··· 21 21 */ 22 22 23 23 #include <linux/module.h> 24 + #include <linux/slab.h> 24 25 #include <linux/highmem.h> 25 26 #include <linux/delay.h> 26 27 #include <linux/platform_device.h> ··· 383 382 0xFF, (u8)data->blocks); 384 383 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_BLOCK_CNT_H, 385 384 0xFF, (u8)(data->blocks >> 8)); 386 - rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, 387 - CARD_DATA_SOURCE, 0x01, RING_BUFFER); 388 385 389 386 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, IRQSTAT0, 390 387 DMA_DONE_INT, DMA_DONE_INT); ··· 406 407 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_DATA_SOURCE, 407 408 0x01, RING_BUFFER); 408 409 410 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_CFG2, 0xFF, cfg2); 409 411 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_TRANSFER, 0xFF, 410 412 trans_mode | SD_TRANSFER_START); 411 413 rtsx_pci_add_cmd(pcr, CHECK_REG_CMD, SD_TRANSFER,
+25 -19
drivers/power/da9052-battery.c
··· 440 440 static irqreturn_t da9052_bat_irq(int irq, void *data) 441 441 { 442 442 struct da9052_battery *bat = data; 443 + int virq; 443 444 444 - irq -= bat->da9052->irq_base; 445 + virq = regmap_irq_get_virq(bat->da9052->irq_data, irq); 446 + irq -= virq; 445 447 446 448 if (irq == DA9052_IRQ_CHGEND) 447 449 bat->status = POWER_SUPPLY_STATUS_FULL; ··· 569 567 .get_property = da9052_bat_get_property, 570 568 }; 571 569 572 - static const char *const da9052_bat_irqs[] = { 570 + static char *da9052_bat_irqs[] = { 573 571 "BATT TEMP", 574 572 "DCIN DET", 575 573 "DCIN REM", ··· 578 576 "CHG END", 579 577 }; 580 578 579 + static int da9052_bat_irq_bits[] = { 580 + DA9052_IRQ_TBAT, 581 + DA9052_IRQ_DCIN, 582 + DA9052_IRQ_DCINREM, 583 + DA9052_IRQ_VBUS, 584 + DA9052_IRQ_VBUSREM, 585 + DA9052_IRQ_CHGEND, 586 + }; 587 + 581 588 static s32 da9052_bat_probe(struct platform_device *pdev) 582 589 { 583 590 struct da9052_pdata *pdata; 584 591 struct da9052_battery *bat; 585 592 int ret; 586 - int irq; 587 593 int i; 588 594 589 595 bat = kzalloc(sizeof(struct da9052_battery), GFP_KERNEL); ··· 612 602 bat->psy.use_for_apm = 1; 613 603 614 604 for (i = 0; i < ARRAY_SIZE(da9052_bat_irqs); i++) { 615 - irq = platform_get_irq_byname(pdev, da9052_bat_irqs[i]); 616 - ret = request_threaded_irq(bat->da9052->irq_base + irq, 617 - NULL, da9052_bat_irq, 618 - IRQF_TRIGGER_LOW | IRQF_ONESHOT, 619 - da9052_bat_irqs[i], bat); 605 + ret = da9052_request_irq(bat->da9052, 606 + da9052_bat_irq_bits[i], da9052_bat_irqs[i], 607 + da9052_bat_irq, bat); 608 + 620 609 if (ret != 0) { 621 610 dev_err(bat->da9052->dev, 622 - "DA9052 failed to request %s IRQ %d: %d\n", 623 - da9052_bat_irqs[i], irq, ret); 611 + "DA9052 failed to request %s IRQ: %d\n", 612 + da9052_bat_irqs[i], ret); 624 613 goto err; 625 614 } 626 615 } ··· 632 623 return 0; 633 624 634 625 err: 635 - while (--i >= 0) { 636 - irq = platform_get_irq_byname(pdev, da9052_bat_irqs[i]); 637 - free_irq(bat->da9052->irq_base + irq, bat); 638 - } 626 + while (--i >= 0) 627 + da9052_free_irq(bat->da9052, da9052_bat_irq_bits[i], bat); 628 + 639 629 kfree(bat); 640 630 return ret; 641 631 } 642 632 static int da9052_bat_remove(struct platform_device *pdev) 643 633 { 644 634 int i; 645 - int irq; 646 635 struct da9052_battery *bat = platform_get_drvdata(pdev); 647 636 648 - for (i = 0; i < ARRAY_SIZE(da9052_bat_irqs); i++) { 649 - irq = platform_get_irq_byname(pdev, da9052_bat_irqs[i]); 650 - free_irq(bat->da9052->irq_base + irq, bat); 651 - } 637 + for (i = 0; i < ARRAY_SIZE(da9052_bat_irqs); i++) 638 + da9052_free_irq(bat->da9052, da9052_bat_irq_bits[i], bat); 639 + 652 640 power_supply_unregister(&bat->psy); 653 641 kfree(bat); 654 642
+16 -16
drivers/rtc/rtc-twl.c
··· 233 233 */ 234 234 static int twl_rtc_read_time(struct device *dev, struct rtc_time *tm) 235 235 { 236 - unsigned char rtc_data[ALL_TIME_REGS + 1]; 236 + unsigned char rtc_data[ALL_TIME_REGS]; 237 237 int ret; 238 238 u8 save_control; 239 239 u8 rtc_control; ··· 300 300 static int twl_rtc_set_time(struct device *dev, struct rtc_time *tm) 301 301 { 302 302 unsigned char save_control; 303 - unsigned char rtc_data[ALL_TIME_REGS + 1]; 303 + unsigned char rtc_data[ALL_TIME_REGS]; 304 304 int ret; 305 305 306 - rtc_data[1] = bin2bcd(tm->tm_sec); 307 - rtc_data[2] = bin2bcd(tm->tm_min); 308 - rtc_data[3] = bin2bcd(tm->tm_hour); 309 - rtc_data[4] = bin2bcd(tm->tm_mday); 310 - rtc_data[5] = bin2bcd(tm->tm_mon + 1); 311 - rtc_data[6] = bin2bcd(tm->tm_year - 100); 306 + rtc_data[0] = bin2bcd(tm->tm_sec); 307 + rtc_data[1] = bin2bcd(tm->tm_min); 308 + rtc_data[2] = bin2bcd(tm->tm_hour); 309 + rtc_data[3] = bin2bcd(tm->tm_mday); 310 + rtc_data[4] = bin2bcd(tm->tm_mon + 1); 311 + rtc_data[5] = bin2bcd(tm->tm_year - 100); 312 312 313 313 /* Stop RTC while updating the TC registers */ 314 314 ret = twl_rtc_read_u8(&save_control, REG_RTC_CTRL_REG); ··· 341 341 */ 342 342 static int twl_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) 343 343 { 344 - unsigned char rtc_data[ALL_TIME_REGS + 1]; 344 + unsigned char rtc_data[ALL_TIME_REGS]; 345 345 int ret; 346 346 347 347 ret = twl_i2c_read(TWL_MODULE_RTC, rtc_data, ··· 368 368 369 369 static int twl_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) 370 370 { 371 - unsigned char alarm_data[ALL_TIME_REGS + 1]; 371 + unsigned char alarm_data[ALL_TIME_REGS]; 372 372 int ret; 373 373 374 374 ret = twl_rtc_alarm_irq_enable(dev, 0); 375 375 if (ret) 376 376 goto out; 377 377 378 - alarm_data[1] = bin2bcd(alm->time.tm_sec); 379 - alarm_data[2] = bin2bcd(alm->time.tm_min); 380 - alarm_data[3] = bin2bcd(alm->time.tm_hour); 381 - alarm_data[4] = bin2bcd(alm->time.tm_mday); 382 - alarm_data[5] = bin2bcd(alm->time.tm_mon + 1); 383 - alarm_data[6] = bin2bcd(alm->time.tm_year - 100); 378 + alarm_data[0] = bin2bcd(alm->time.tm_sec); 379 + alarm_data[1] = bin2bcd(alm->time.tm_min); 380 + alarm_data[2] = bin2bcd(alm->time.tm_hour); 381 + alarm_data[3] = bin2bcd(alm->time.tm_mday); 382 + alarm_data[4] = bin2bcd(alm->time.tm_mon + 1); 383 + alarm_data[5] = bin2bcd(alm->time.tm_year - 100); 384 384 385 385 /* update all the alarm registers in one shot */ 386 386 ret = twl_i2c_write(TWL_MODULE_RTC, alarm_data,
+32 -33
include/linux/i2c/twl.h
··· 39 39 * address each module uses within a given i2c slave. 40 40 */ 41 41 42 - /* Slave 0 (i2c address 0x48) */ 43 - #define TWL4030_MODULE_USB 0x00 42 + enum twl4030_module_ids { 43 + TWL4030_MODULE_USB = 0, /* Slave 0 (i2c address 0x48) */ 44 + TWL4030_MODULE_AUDIO_VOICE, /* Slave 1 (i2c address 0x49) */ 45 + TWL4030_MODULE_GPIO, 46 + TWL4030_MODULE_INTBR, 47 + TWL4030_MODULE_PIH, 44 48 45 - /* Slave 1 (i2c address 0x49) */ 46 - #define TWL4030_MODULE_AUDIO_VOICE 0x01 47 - #define TWL4030_MODULE_GPIO 0x02 48 - #define TWL4030_MODULE_INTBR 0x03 49 - #define TWL4030_MODULE_PIH 0x04 50 - #define TWL4030_MODULE_TEST 0x05 49 + TWL4030_MODULE_TEST, 50 + TWL4030_MODULE_KEYPAD, /* Slave 2 (i2c address 0x4a) */ 51 + TWL4030_MODULE_MADC, 52 + TWL4030_MODULE_INTERRUPTS, 53 + TWL4030_MODULE_LED, 51 54 52 - /* Slave 2 (i2c address 0x4a) */ 53 - #define TWL4030_MODULE_KEYPAD 0x06 54 - #define TWL4030_MODULE_MADC 0x07 55 - #define TWL4030_MODULE_INTERRUPTS 0x08 56 - #define TWL4030_MODULE_LED 0x09 57 - #define TWL4030_MODULE_MAIN_CHARGE 0x0A 58 - #define TWL4030_MODULE_PRECHARGE 0x0B 59 - #define TWL4030_MODULE_PWM0 0x0C 60 - #define TWL4030_MODULE_PWM1 0x0D 61 - #define TWL4030_MODULE_PWMA 0x0E 62 - #define TWL4030_MODULE_PWMB 0x0F 55 + TWL4030_MODULE_MAIN_CHARGE, 56 + TWL4030_MODULE_PRECHARGE, 57 + TWL4030_MODULE_PWM0, 58 + TWL4030_MODULE_PWM1, 59 + TWL4030_MODULE_PWMA, 63 60 64 - #define TWL5031_MODULE_ACCESSORY 0x10 65 - #define TWL5031_MODULE_INTERRUPTS 0x11 61 + TWL4030_MODULE_PWMB, 62 + TWL5031_MODULE_ACCESSORY, 63 + TWL5031_MODULE_INTERRUPTS, 64 + TWL4030_MODULE_BACKUP, /* Slave 3 (i2c address 0x4b) */ 65 + TWL4030_MODULE_INT, 66 66 67 - /* Slave 3 (i2c address 0x4b) */ 68 - #define TWL4030_MODULE_BACKUP 0x12 69 - #define TWL4030_MODULE_INT 0x13 70 - #define TWL4030_MODULE_PM_MASTER 0x14 71 - #define TWL4030_MODULE_PM_RECEIVER 0x15 72 - #define TWL4030_MODULE_RTC 0x16 73 - #define TWL4030_MODULE_SECURED_REG 0x17 67 + TWL4030_MODULE_PM_MASTER, 68 + TWL4030_MODULE_PM_RECEIVER, 69 + TWL4030_MODULE_RTC, 70 + TWL4030_MODULE_SECURED_REG, 71 + TWL4030_MODULE_LAST, 72 + }; 74 73 74 + /* Similar functionalities implemented in TWL4030/6030 */ 75 75 #define TWL_MODULE_USB TWL4030_MODULE_USB 76 - #define TWL_MODULE_AUDIO_VOICE TWL4030_MODULE_AUDIO_VOICE 77 76 #define TWL_MODULE_PIH TWL4030_MODULE_PIH 78 - #define TWL_MODULE_MADC TWL4030_MODULE_MADC 79 77 #define TWL_MODULE_MAIN_CHARGE TWL4030_MODULE_MAIN_CHARGE 80 78 #define TWL_MODULE_PM_MASTER TWL4030_MODULE_PM_MASTER 81 79 #define TWL_MODULE_PM_RECEIVER TWL4030_MODULE_PM_RECEIVER 82 80 #define TWL_MODULE_RTC TWL4030_MODULE_RTC 83 81 #define TWL_MODULE_PWM TWL4030_MODULE_PWM0 82 + #define TWL_MODULE_LED TWL4030_MODULE_LED 84 83 85 - #define TWL6030_MODULE_ID0 0x0D 86 - #define TWL6030_MODULE_ID1 0x0E 87 - #define TWL6030_MODULE_ID2 0x0F 84 + #define TWL6030_MODULE_ID0 13 85 + #define TWL6030_MODULE_ID1 14 86 + #define TWL6030_MODULE_ID2 15 88 87 89 88 #define GPIO_INTR_OFFSET 0 90 89 #define KEYPAD_INTR_OFFSET 1
+23
include/linux/input/ti_am335x_tsc.h
··· 1 + #ifndef __LINUX_TI_AM335X_TSC_H 2 + #define __LINUX_TI_AM335X_TSC_H 3 + 4 + /** 5 + * struct tsc_data Touchscreen wire configuration 6 + * @wires: Wires refer to application modes 7 + * i.e. 4/5/8 wire touchscreen support 8 + * on the platform. 9 + * @x_plate_resistance: X plate resistance. 10 + * @steps_to_configure: The sequencer supports a total of 11 + * 16 programmable steps. 12 + * A step configured to read a single 13 + * co-ordinate value, can be applied 14 + * more number of times for better results. 15 + */ 16 + 17 + struct tsc_data { 18 + int wires; 19 + int x_plate_resistance; 20 + int steps_to_configure; 21 + }; 22 + 23 + #endif
-17
include/linux/input/ti_tscadc.h
··· 1 - #ifndef __LINUX_TI_TSCADC_H 2 - #define __LINUX_TI_TSCADC_H 3 - 4 - /** 5 - * struct tsc_data Touchscreen wire configuration 6 - * @wires: Wires refer to application modes 7 - * i.e. 4/5/8 wire touchscreen support 8 - * on the platform. 9 - * @x_plate_resistance: X plate resistance. 10 - */ 11 - 12 - struct tsc_data { 13 - int wires; 14 - int x_plate_resistance; 15 - }; 16 - 17 - #endif
+1
include/linux/mfd/arizona/registers.h
··· 981 981 #define ARIZONA_DSP1_CLOCKING_1 0x1101 982 982 #define ARIZONA_DSP1_STATUS_1 0x1104 983 983 #define ARIZONA_DSP1_STATUS_2 0x1105 984 + #define ARIZONA_DSP1_STATUS_3 0x1106 984 985 #define ARIZONA_DSP2_CONTROL_1 0x1200 985 986 #define ARIZONA_DSP2_CLOCKING_1 0x1201 986 987 #define ARIZONA_DSP2_STATUS_1 0x1204
+126
include/linux/mfd/as3711.h
··· 1 + /* 2 + * AS3711 PMIC MFC driver header 3 + * 4 + * Copyright (C) 2012 Renesas Electronics Corporation 5 + * Author: Guennadi Liakhovetski, <g.liakhovetski@gmx.de> 6 + * 7 + * This program is free software; you can redistribute it and/or modify 8 + * it under the terms of the version 2 of the GNU General Public License as 9 + * published by the Free Software Foundation 10 + */ 11 + 12 + #ifndef MFD_AS3711_H 13 + #define MFD_AS3711_H 14 + 15 + /* 16 + * Client data 17 + */ 18 + 19 + /* Register addresses */ 20 + #define AS3711_SD_1_VOLTAGE 0 /* Digital Step-Down */ 21 + #define AS3711_SD_2_VOLTAGE 1 22 + #define AS3711_SD_3_VOLTAGE 2 23 + #define AS3711_SD_4_VOLTAGE 3 24 + #define AS3711_LDO_1_VOLTAGE 4 /* Analog LDO */ 25 + #define AS3711_LDO_2_VOLTAGE 5 26 + #define AS3711_LDO_3_VOLTAGE 6 /* Digital LDO */ 27 + #define AS3711_LDO_4_VOLTAGE 7 28 + #define AS3711_LDO_5_VOLTAGE 8 29 + #define AS3711_LDO_6_VOLTAGE 9 30 + #define AS3711_LDO_7_VOLTAGE 0xa 31 + #define AS3711_LDO_8_VOLTAGE 0xb 32 + #define AS3711_SD_CONTROL 0x10 33 + #define AS3711_GPIO_SIGNAL_OUT 0x20 34 + #define AS3711_GPIO_SIGNAL_IN 0x21 35 + #define AS3711_SD_CONTROL_1 0x30 36 + #define AS3711_SD_CONTROL_2 0x31 37 + #define AS3711_CURR_CONTROL 0x40 38 + #define AS3711_CURR1_VALUE 0x43 39 + #define AS3711_CURR2_VALUE 0x44 40 + #define AS3711_CURR3_VALUE 0x45 41 + #define AS3711_STEPUP_CONTROL_1 0x50 42 + #define AS3711_STEPUP_CONTROL_2 0x51 43 + #define AS3711_STEPUP_CONTROL_4 0x53 44 + #define AS3711_STEPUP_CONTROL_5 0x54 45 + #define AS3711_REG_STATUS 0x73 46 + #define AS3711_INTERRUPT_STATUS_1 0x77 47 + #define AS3711_INTERRUPT_STATUS_2 0x78 48 + #define AS3711_INTERRUPT_STATUS_3 0x79 49 + #define AS3711_CHARGER_STATUS_1 0x86 50 + #define AS3711_CHARGER_STATUS_2 0x87 51 + #define AS3711_ASIC_ID_1 0x90 52 + #define AS3711_ASIC_ID_2 0x91 53 + 54 + #define AS3711_MAX_REGS 0x92 55 + 56 + /* Regulators */ 57 + enum { 58 + AS3711_REGULATOR_SD_1, 59 + AS3711_REGULATOR_SD_2, 60 + AS3711_REGULATOR_SD_3, 61 + AS3711_REGULATOR_SD_4, 62 + AS3711_REGULATOR_LDO_1, 63 + AS3711_REGULATOR_LDO_2, 64 + AS3711_REGULATOR_LDO_3, 65 + AS3711_REGULATOR_LDO_4, 66 + AS3711_REGULATOR_LDO_5, 67 + AS3711_REGULATOR_LDO_6, 68 + AS3711_REGULATOR_LDO_7, 69 + AS3711_REGULATOR_LDO_8, 70 + 71 + AS3711_REGULATOR_MAX, 72 + }; 73 + 74 + struct device; 75 + struct regmap; 76 + 77 + struct as3711 { 78 + struct device *dev; 79 + struct regmap *regmap; 80 + }; 81 + 82 + #define AS3711_MAX_STEPDOWN 4 83 + #define AS3711_MAX_STEPUP 2 84 + #define AS3711_MAX_LDO 8 85 + 86 + enum as3711_su2_feedback { 87 + AS3711_SU2_VOLTAGE, 88 + AS3711_SU2_CURR1, 89 + AS3711_SU2_CURR2, 90 + AS3711_SU2_CURR3, 91 + AS3711_SU2_CURR_AUTO, 92 + }; 93 + 94 + enum as3711_su2_fbprot { 95 + AS3711_SU2_LX_SD4, 96 + AS3711_SU2_GPIO2, 97 + AS3711_SU2_GPIO3, 98 + AS3711_SU2_GPIO4, 99 + }; 100 + 101 + /* 102 + * Platform data 103 + */ 104 + 105 + struct as3711_regulator_pdata { 106 + struct regulator_init_data *init_data[AS3711_REGULATOR_MAX]; 107 + }; 108 + 109 + struct as3711_bl_pdata { 110 + const char *su1_fb; 111 + int su1_max_uA; 112 + const char *su2_fb; 113 + int su2_max_uA; 114 + enum as3711_su2_feedback su2_feedback; 115 + enum as3711_su2_fbprot su2_fbprot; 116 + bool su2_auto_curr1; 117 + bool su2_auto_curr2; 118 + bool su2_auto_curr3; 119 + }; 120 + 121 + struct as3711_platform_data { 122 + struct as3711_regulator_pdata regulator; 123 + struct as3711_bl_pdata backlight; 124 + }; 125 + 126 + #endif
+10
include/linux/mfd/da9052/da9052.h
··· 146 146 147 147 extern struct regmap_config da9052_regmap_config; 148 148 149 + int da9052_irq_init(struct da9052 *da9052); 150 + int da9052_irq_exit(struct da9052 *da9052); 151 + int da9052_request_irq(struct da9052 *da9052, int irq, char *name, 152 + irq_handler_t handler, void *data); 153 + void da9052_free_irq(struct da9052 *da9052, int irq, void *data); 154 + 155 + int da9052_enable_irq(struct da9052 *da9052, int irq); 156 + int da9052_disable_irq(struct da9052 *da9052, int irq); 157 + int da9052_disable_irq_nosync(struct da9052 *da9052, int irq); 158 + 149 159 #endif /* __MFD_DA9052_DA9052_H */
+1 -1
include/linux/mfd/da9055/core.h
··· 1 - /* 1 + /* 2 2 * da9055 declarations for DA9055 PMICs. 3 3 * 4 4 * Copyright(c) 2012 Dialog Semiconductor Ltd.
+1 -1
include/linux/mfd/da9055/pdata.h
··· 1 - /* Copyright (C) 2012 Dialog Semiconductor Ltd. 1 + /* Copyright (C) 2012 Dialog Semiconductor Ltd. 2 2 * 3 3 * This program is free software; you can redistribute it and/or modify 4 4 * it under the terms of the GNU General Public License as published by
+1 -1
include/linux/mfd/da9055/reg.h
··· 1 - /* 1 + /* 2 2 * DA9055 declarations for DA9055 PMICs. 3 3 * 4 4 * Copyright(c) 2012 Dialog Semiconductor Ltd.
+2 -1
include/linux/mfd/rc5t583.h
··· 33 33 /* Maximum number of main interrupts */ 34 34 #define MAX_MAIN_INTERRUPT 5 35 35 #define RC5T583_MAX_GPEDGE_REG 2 36 + #define RC5T583_MAX_INTERRUPT_EN_REGS 8 36 37 #define RC5T583_MAX_INTERRUPT_MASK_REGS 9 37 38 38 39 /* Interrupt enable register */ ··· 305 304 uint8_t intc_inten_reg; 306 305 307 306 /* For group interrupt bits and address */ 308 - uint8_t irq_en_reg[RC5T583_MAX_INTERRUPT_MASK_REGS]; 307 + uint8_t irq_en_reg[RC5T583_MAX_INTERRUPT_EN_REGS]; 309 308 310 309 /* For gpio edge */ 311 310 uint8_t gpedge_reg[RC5T583_MAX_GPEDGE_REG];
+22
include/linux/mfd/retu.h
··· 1 + /* 2 + * Retu MFD driver interface 3 + * 4 + * This file is subject to the terms and conditions of the GNU General 5 + * Public License. See the file "COPYING" in the main directory of this 6 + * archive for more details. 7 + */ 8 + 9 + #ifndef __LINUX_MFD_RETU_H 10 + #define __LINUX_MFD_RETU_H 11 + 12 + struct retu_dev; 13 + 14 + int retu_read(struct retu_dev *, u8); 15 + int retu_write(struct retu_dev *, u8, u16); 16 + 17 + /* Registers */ 18 + #define RETU_REG_WATCHDOG 0x17 /* Watchdog */ 19 + #define RETU_REG_CC1 0x0d /* Common control register 1 */ 20 + #define RETU_REG_STATUS 0x16 /* Status register */ 21 + 22 + #endif /* __LINUX_MFD_RETU_H */
+196 -2
include/linux/mfd/sta2x11-mfd.h
··· 26 26 #include <linux/types.h> 27 27 #include <linux/pci.h> 28 28 29 + enum sta2x11_mfd_plat_dev { 30 + sta2x11_sctl = 0, 31 + sta2x11_gpio, 32 + sta2x11_scr, 33 + sta2x11_time, 34 + sta2x11_apbreg, 35 + sta2x11_apb_soc_regs, 36 + sta2x11_vic, 37 + sta2x11_n_mfd_plat_devs, 38 + }; 39 + 40 + #define STA2X11_MFD_SCTL_NAME "sta2x11-sctl" 41 + #define STA2X11_MFD_GPIO_NAME "sta2x11-gpio" 42 + #define STA2X11_MFD_SCR_NAME "sta2x11-scr" 43 + #define STA2X11_MFD_TIME_NAME "sta2x11-time" 44 + #define STA2X11_MFD_APBREG_NAME "sta2x11-apbreg" 45 + #define STA2X11_MFD_APB_SOC_REGS_NAME "sta2x11-apb-soc-regs" 46 + #define STA2X11_MFD_VIC_NAME "sta2x11-vic" 47 + 48 + extern u32 49 + __sta2x11_mfd_mask(struct pci_dev *, u32, u32, u32, enum sta2x11_mfd_plat_dev); 50 + 29 51 /* 30 52 * The MFD PCI block includes the GPIO peripherals and other register blocks. 31 53 * For GPIO, we have 32*4 bits (I use "gsta" for "gpio sta2x11".) ··· 204 182 * The APB bridge has its own registers, needed by our users as well. 205 183 * They are accessed with the following read/mask/write function. 206 184 */ 207 - u32 sta2x11_apbreg_mask(struct pci_dev *pdev, u32 reg, u32 mask, u32 val); 185 + static inline u32 186 + sta2x11_apbreg_mask(struct pci_dev *pdev, u32 reg, u32 mask, u32 val) 187 + { 188 + return __sta2x11_mfd_mask(pdev, reg, mask, val, sta2x11_apbreg); 189 + } 208 190 209 191 /* CAN and MLB */ 210 192 #define APBREG_BSR 0x00 /* Bridge Status Reg */ ··· 237 211 * The system controller has its own registers. Some of these are accessed 238 212 * by out users as well, using the following read/mask/write/function 239 213 */ 240 - u32 sta2x11_sctl_mask(struct pci_dev *pdev, u32 reg, u32 mask, u32 val); 214 + static inline 215 + u32 sta2x11_sctl_mask(struct pci_dev *pdev, u32 reg, u32 mask, u32 val) 216 + { 217 + return __sta2x11_mfd_mask(pdev, reg, mask, val, sta2x11_sctl); 218 + } 241 219 242 220 #define SCTL_SCCTL 0x00 /* System controller control register */ 243 221 #define SCTL_ARMCFG 0x04 /* ARM configuration register */ 244 222 #define SCTL_SCPLLCTL 0x08 /* PLL control status register */ 223 + 224 + #define SCTL_SCPLLCTL_AUDIO_PLL_PD BIT(1) 225 + #define SCTL_SCPLLCTL_FRAC_CONTROL BIT(3) 226 + #define SCTL_SCPLLCTL_STRB_BYPASS BIT(6) 227 + #define SCTL_SCPLLCTL_STRB_INPUT BIT(8) 228 + 245 229 #define SCTL_SCPLLFCTRL 0x0c /* PLL frequency control register */ 230 + 231 + #define SCTL_SCPLLFCTRL_AUDIO_PLL_NDIV_MASK 0xff 232 + #define SCTL_SCPLLFCTRL_AUDIO_PLL_NDIV_SHIFT 10 233 + #define SCTL_SCPLLFCTRL_AUDIO_PLL_IDF_MASK 7 234 + #define SCTL_SCPLLFCTRL_AUDIO_PLL_IDF_SHIFT 21 235 + #define SCTL_SCPLLFCTRL_AUDIO_PLL_ODF_MASK 7 236 + #define SCTL_SCPLLFCTRL_AUDIO_PLL_ODF_SHIFT 18 237 + #define SCTL_SCPLLFCTRL_DITHER_DISABLE_MASK 0x03 238 + #define SCTL_SCPLLFCTRL_DITHER_DISABLE_SHIFT 4 239 + 240 + 246 241 #define SCTL_SCRESFRACT 0x10 /* PLL fractional input register */ 242 + 243 + #define SCTL_SCRESFRACT_MASK 0x0000ffff 244 + 245 + 247 246 #define SCTL_SCRESCTRL1 0x14 /* Peripheral reset control 1 */ 248 247 #define SCTL_SCRESXTRL2 0x18 /* Peripheral reset control 2 */ 249 248 #define SCTL_SCPEREN0 0x1c /* Peripheral clock enable register 0 */ 250 249 #define SCTL_SCPEREN1 0x20 /* Peripheral clock enable register 1 */ 251 250 #define SCTL_SCPEREN2 0x24 /* Peripheral clock enable register 2 */ 252 251 #define SCTL_SCGRST 0x28 /* Peripheral global reset */ 252 + #define SCTL_SCPCIECSBRST 0x2c /* PCIe PAB CSB reset status register */ 253 253 #define SCTL_SCPCIPMCR1 0x30 /* PCI power management control 1 */ 254 254 #define SCTL_SCPCIPMCR2 0x34 /* PCI power management control 2 */ 255 255 #define SCTL_SCPCIPMSR1 0x38 /* PCI power management status 1 */ ··· 372 320 #define SCTL_SCPEREN1_I2C2 (1 << 15) 373 321 #define SCTL_SCPEREN1_I2C3 (1 << 16) 374 322 #define SCTL_SCPEREN1_USB_PHY (1 << 17) 323 + 324 + /* 325 + * APB-SOC registers 326 + */ 327 + static inline 328 + u32 sta2x11_apb_soc_regs_mask(struct pci_dev *pdev, u32 reg, u32 mask, u32 val) 329 + { 330 + return __sta2x11_mfd_mask(pdev, reg, mask, val, sta2x11_apb_soc_regs); 331 + } 332 + 333 + #define PCIE_EP1_FUNC3_0_INTR_REG 0x000 334 + #define PCIE_EP1_FUNC7_4_INTR_REG 0x004 335 + #define PCIE_EP2_FUNC3_0_INTR_REG 0x008 336 + #define PCIE_EP2_FUNC7_4_INTR_REG 0x00c 337 + #define PCIE_EP3_FUNC3_0_INTR_REG 0x010 338 + #define PCIE_EP3_FUNC7_4_INTR_REG 0x014 339 + #define PCIE_EP4_FUNC3_0_INTR_REG 0x018 340 + #define PCIE_EP4_FUNC7_4_INTR_REG 0x01c 341 + #define PCIE_INTR_ENABLE0_REG 0x020 342 + #define PCIE_INTR_ENABLE1_REG 0x024 343 + #define PCIE_EP1_FUNC_TC_REG 0x028 344 + #define PCIE_EP2_FUNC_TC_REG 0x02c 345 + #define PCIE_EP3_FUNC_TC_REG 0x030 346 + #define PCIE_EP4_FUNC_TC_REG 0x034 347 + #define PCIE_EP1_FUNC_F_REG 0x038 348 + #define PCIE_EP2_FUNC_F_REG 0x03c 349 + #define PCIE_EP3_FUNC_F_REG 0x040 350 + #define PCIE_EP4_FUNC_F_REG 0x044 351 + #define PCIE_PAB_AMBA_SW_RST_REG 0x048 352 + #define PCIE_PM_STATUS_0_PORT_0_4 0x04c 353 + #define PCIE_PM_STATUS_7_0_EP1 0x050 354 + #define PCIE_PM_STATUS_7_0_EP2 0x054 355 + #define PCIE_PM_STATUS_7_0_EP3 0x058 356 + #define PCIE_PM_STATUS_7_0_EP4 0x05c 357 + #define PCIE_DEV_ID_0_EP1_REG 0x060 358 + #define PCIE_CC_REV_ID_0_EP1_REG 0x064 359 + #define PCIE_DEV_ID_1_EP1_REG 0x068 360 + #define PCIE_CC_REV_ID_1_EP1_REG 0x06c 361 + #define PCIE_DEV_ID_2_EP1_REG 0x070 362 + #define PCIE_CC_REV_ID_2_EP1_REG 0x074 363 + #define PCIE_DEV_ID_3_EP1_REG 0x078 364 + #define PCIE_CC_REV_ID_3_EP1_REG 0x07c 365 + #define PCIE_DEV_ID_4_EP1_REG 0x080 366 + #define PCIE_CC_REV_ID_4_EP1_REG 0x084 367 + #define PCIE_DEV_ID_5_EP1_REG 0x088 368 + #define PCIE_CC_REV_ID_5_EP1_REG 0x08c 369 + #define PCIE_DEV_ID_6_EP1_REG 0x090 370 + #define PCIE_CC_REV_ID_6_EP1_REG 0x094 371 + #define PCIE_DEV_ID_7_EP1_REG 0x098 372 + #define PCIE_CC_REV_ID_7_EP1_REG 0x09c 373 + #define PCIE_DEV_ID_0_EP2_REG 0x0a0 374 + #define PCIE_CC_REV_ID_0_EP2_REG 0x0a4 375 + #define PCIE_DEV_ID_1_EP2_REG 0x0a8 376 + #define PCIE_CC_REV_ID_1_EP2_REG 0x0ac 377 + #define PCIE_DEV_ID_2_EP2_REG 0x0b0 378 + #define PCIE_CC_REV_ID_2_EP2_REG 0x0b4 379 + #define PCIE_DEV_ID_3_EP2_REG 0x0b8 380 + #define PCIE_CC_REV_ID_3_EP2_REG 0x0bc 381 + #define PCIE_DEV_ID_4_EP2_REG 0x0c0 382 + #define PCIE_CC_REV_ID_4_EP2_REG 0x0c4 383 + #define PCIE_DEV_ID_5_EP2_REG 0x0c8 384 + #define PCIE_CC_REV_ID_5_EP2_REG 0x0cc 385 + #define PCIE_DEV_ID_6_EP2_REG 0x0d0 386 + #define PCIE_CC_REV_ID_6_EP2_REG 0x0d4 387 + #define PCIE_DEV_ID_7_EP2_REG 0x0d8 388 + #define PCIE_CC_REV_ID_7_EP2_REG 0x0dC 389 + #define PCIE_DEV_ID_0_EP3_REG 0x0e0 390 + #define PCIE_CC_REV_ID_0_EP3_REG 0x0e4 391 + #define PCIE_DEV_ID_1_EP3_REG 0x0e8 392 + #define PCIE_CC_REV_ID_1_EP3_REG 0x0ec 393 + #define PCIE_DEV_ID_2_EP3_REG 0x0f0 394 + #define PCIE_CC_REV_ID_2_EP3_REG 0x0f4 395 + #define PCIE_DEV_ID_3_EP3_REG 0x0f8 396 + #define PCIE_CC_REV_ID_3_EP3_REG 0x0fc 397 + #define PCIE_DEV_ID_4_EP3_REG 0x100 398 + #define PCIE_CC_REV_ID_4_EP3_REG 0x104 399 + #define PCIE_DEV_ID_5_EP3_REG 0x108 400 + #define PCIE_CC_REV_ID_5_EP3_REG 0x10c 401 + #define PCIE_DEV_ID_6_EP3_REG 0x110 402 + #define PCIE_CC_REV_ID_6_EP3_REG 0x114 403 + #define PCIE_DEV_ID_7_EP3_REG 0x118 404 + #define PCIE_CC_REV_ID_7_EP3_REG 0x11c 405 + #define PCIE_DEV_ID_0_EP4_REG 0x120 406 + #define PCIE_CC_REV_ID_0_EP4_REG 0x124 407 + #define PCIE_DEV_ID_1_EP4_REG 0x128 408 + #define PCIE_CC_REV_ID_1_EP4_REG 0x12c 409 + #define PCIE_DEV_ID_2_EP4_REG 0x130 410 + #define PCIE_CC_REV_ID_2_EP4_REG 0x134 411 + #define PCIE_DEV_ID_3_EP4_REG 0x138 412 + #define PCIE_CC_REV_ID_3_EP4_REG 0x13c 413 + #define PCIE_DEV_ID_4_EP4_REG 0x140 414 + #define PCIE_CC_REV_ID_4_EP4_REG 0x144 415 + #define PCIE_DEV_ID_5_EP4_REG 0x148 416 + #define PCIE_CC_REV_ID_5_EP4_REG 0x14c 417 + #define PCIE_DEV_ID_6_EP4_REG 0x150 418 + #define PCIE_CC_REV_ID_6_EP4_REG 0x154 419 + #define PCIE_DEV_ID_7_EP4_REG 0x158 420 + #define PCIE_CC_REV_ID_7_EP4_REG 0x15c 421 + #define PCIE_SUBSYS_VEN_ID_REG 0x160 422 + #define PCIE_COMMON_CLOCK_CONFIG_0_4_0 0x164 423 + #define PCIE_MIPHYP_SSC_EN_REG 0x168 424 + #define PCIE_MIPHYP_ADDR_REG 0x16c 425 + #define PCIE_L1_ASPM_READY_REG 0x170 426 + #define PCIE_EXT_CFG_RDY_REG 0x174 427 + #define PCIE_SoC_INT_ROUTER_STATUS0_REG 0x178 428 + #define PCIE_SoC_INT_ROUTER_STATUS1_REG 0x17c 429 + #define PCIE_SoC_INT_ROUTER_STATUS2_REG 0x180 430 + #define PCIE_SoC_INT_ROUTER_STATUS3_REG 0x184 431 + #define DMA_IP_CTRL_REG 0x324 432 + #define DISP_BRIDGE_PU_PD_CTRL_REG 0x328 433 + #define VIP_PU_PD_CTRL_REG 0x32c 434 + #define USB_MLB_PU_PD_CTRL_REG 0x330 435 + #define SDIO_PU_PD_MISCFUNC_CTRL_REG1 0x334 436 + #define SDIO_PU_PD_MISCFUNC_CTRL_REG2 0x338 437 + #define UART_PU_PD_CTRL_REG 0x33c 438 + #define ARM_Lock 0x340 439 + #define SYS_IO_CHAR_REG1 0x344 440 + #define SYS_IO_CHAR_REG2 0x348 441 + #define SATA_CORE_ID_REG 0x34c 442 + #define SATA_CTRL_REG 0x350 443 + #define I2C_HSFIX_MISC_REG 0x354 444 + #define SPARE2_RESERVED 0x358 445 + #define SPARE3_RESERVED 0x35c 446 + #define MASTER_LOCK_REG 0x368 447 + #define SYSTEM_CONFIG_STATUS_REG 0x36c 448 + #define MSP_CLK_CTRL_REG 0x39c 449 + #define COMPENSATION_REG1 0x3c4 450 + #define COMPENSATION_REG2 0x3c8 451 + #define COMPENSATION_REG3 0x3cc 452 + #define TEST_CTL_REG 0x3d0 453 + 454 + /* 455 + * SECR (OTP) registers 456 + */ 457 + #define STA2X11_SECR_CR 0x00 458 + #define STA2X11_SECR_FVR0 0x10 459 + #define STA2X11_SECR_FVR1 0x14 460 + 461 + extern int sta2x11_mfd_get_regs_data(struct platform_device *pdev, 462 + enum sta2x11_mfd_plat_dev index, 463 + void __iomem **regs, 464 + spinlock_t **lock); 375 465 376 466 #endif /* __STA2X11_MFD_H */
+2 -2
include/linux/mfd/stmpe.h
··· 62 62 * @lock: lock protecting I/O operations 63 63 * @irq_lock: IRQ bus lock 64 64 * @dev: device, mostly for dev_dbg() 65 + * @irq_domain: IRQ domain 65 66 * @client: client - i2c or spi 66 67 * @ci: client specific information 67 68 * @partnum: part number ··· 80 79 struct mutex lock; 81 80 struct mutex irq_lock; 82 81 struct device *dev; 82 + struct irq_domain *domain; 83 83 void *client; 84 84 struct stmpe_client_info *ci; 85 85 enum stmpe_partnum partnum; ··· 190 188 * @id: device id to distinguish between multiple STMPEs on the same board 191 189 * @blocks: bitmask of blocks to enable (use STMPE_BLOCK_*) 192 190 * @irq_trigger: IRQ trigger to use for the interrupt to the host 193 - * @irq_invert_polarity: IRQ line is connected with reversed polarity 194 191 * @autosleep: bool to enable/disable stmpe autosleep 195 192 * @autosleep_timeout: inactivity timeout in milliseconds for autosleep 196 193 * @irq_base: base IRQ number. %STMPE_NR_IRQS irqs will be used, or ··· 206 205 unsigned int blocks; 207 206 int irq_base; 208 207 unsigned int irq_trigger; 209 - bool irq_invert_polarity; 210 208 bool autosleep; 211 209 bool irq_over_gpio; 212 210 int irq_gpio;
+152
include/linux/mfd/ti_am335x_tscadc.h
··· 1 + #ifndef __LINUX_TI_AM335X_TSCADC_MFD_H 2 + #define __LINUX_TI_AM335X_TSCADC_MFD_H 3 + 4 + /* 5 + * TI Touch Screen / ADC MFD driver 6 + * 7 + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 8 + * 9 + * This program is free software; you can redistribute it and/or 10 + * modify it under the terms of the GNU General Public License as 11 + * published by the Free Software Foundation version 2. 12 + * 13 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 14 + * kind, whether express or implied; without even the implied warranty 15 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 + * GNU General Public License for more details. 17 + */ 18 + 19 + #include <linux/mfd/core.h> 20 + 21 + #define REG_RAWIRQSTATUS 0x024 22 + #define REG_IRQSTATUS 0x028 23 + #define REG_IRQENABLE 0x02C 24 + #define REG_IRQCLR 0x030 25 + #define REG_IRQWAKEUP 0x034 26 + #define REG_CTRL 0x040 27 + #define REG_ADCFSM 0x044 28 + #define REG_CLKDIV 0x04C 29 + #define REG_SE 0x054 30 + #define REG_IDLECONFIG 0x058 31 + #define REG_CHARGECONFIG 0x05C 32 + #define REG_CHARGEDELAY 0x060 33 + #define REG_STEPCONFIG(n) (0x64 + ((n - 1) * 8)) 34 + #define REG_STEPDELAY(n) (0x68 + ((n - 1) * 8)) 35 + #define REG_FIFO0CNT 0xE4 36 + #define REG_FIFO0THR 0xE8 37 + #define REG_FIFO1CNT 0xF0 38 + #define REG_FIFO1THR 0xF4 39 + #define REG_FIFO0 0x100 40 + #define REG_FIFO1 0x200 41 + 42 + /* Register Bitfields */ 43 + /* IRQ wakeup enable */ 44 + #define IRQWKUP_ENB BIT(0) 45 + 46 + /* Step Enable */ 47 + #define STEPENB_MASK (0x1FFFF << 0) 48 + #define STEPENB(val) ((val) << 0) 49 + #define STPENB_STEPENB STEPENB(0x1FFFF) 50 + #define STPENB_STEPENB_TC STEPENB(0x1FFF) 51 + 52 + /* IRQ enable */ 53 + #define IRQENB_HW_PEN BIT(0) 54 + #define IRQENB_FIFO0THRES BIT(2) 55 + #define IRQENB_FIFO1THRES BIT(5) 56 + #define IRQENB_PENUP BIT(9) 57 + 58 + /* Step Configuration */ 59 + #define STEPCONFIG_MODE_MASK (3 << 0) 60 + #define STEPCONFIG_MODE(val) ((val) << 0) 61 + #define STEPCONFIG_MODE_HWSYNC STEPCONFIG_MODE(2) 62 + #define STEPCONFIG_AVG_MASK (7 << 2) 63 + #define STEPCONFIG_AVG(val) ((val) << 2) 64 + #define STEPCONFIG_AVG_16 STEPCONFIG_AVG(4) 65 + #define STEPCONFIG_XPP BIT(5) 66 + #define STEPCONFIG_XNN BIT(6) 67 + #define STEPCONFIG_YPP BIT(7) 68 + #define STEPCONFIG_YNN BIT(8) 69 + #define STEPCONFIG_XNP BIT(9) 70 + #define STEPCONFIG_YPN BIT(10) 71 + #define STEPCONFIG_INM_MASK (0xF << 15) 72 + #define STEPCONFIG_INM(val) ((val) << 15) 73 + #define STEPCONFIG_INM_ADCREFM STEPCONFIG_INM(8) 74 + #define STEPCONFIG_INP_MASK (0xF << 19) 75 + #define STEPCONFIG_INP(val) ((val) << 19) 76 + #define STEPCONFIG_INP_AN2 STEPCONFIG_INP(2) 77 + #define STEPCONFIG_INP_AN3 STEPCONFIG_INP(3) 78 + #define STEPCONFIG_INP_AN4 STEPCONFIG_INP(4) 79 + #define STEPCONFIG_INP_ADCREFM STEPCONFIG_INP(8) 80 + #define STEPCONFIG_FIFO1 BIT(26) 81 + 82 + /* Delay register */ 83 + #define STEPDELAY_OPEN_MASK (0x3FFFF << 0) 84 + #define STEPDELAY_OPEN(val) ((val) << 0) 85 + #define STEPCONFIG_OPENDLY STEPDELAY_OPEN(0x098) 86 + #define STEPDELAY_SAMPLE_MASK (0xFF << 24) 87 + #define STEPDELAY_SAMPLE(val) ((val) << 24) 88 + #define STEPCONFIG_SAMPLEDLY STEPDELAY_SAMPLE(0) 89 + 90 + /* Charge Config */ 91 + #define STEPCHARGE_RFP_MASK (7 << 12) 92 + #define STEPCHARGE_RFP(val) ((val) << 12) 93 + #define STEPCHARGE_RFP_XPUL STEPCHARGE_RFP(1) 94 + #define STEPCHARGE_INM_MASK (0xF << 15) 95 + #define STEPCHARGE_INM(val) ((val) << 15) 96 + #define STEPCHARGE_INM_AN1 STEPCHARGE_INM(1) 97 + #define STEPCHARGE_INP_MASK (0xF << 19) 98 + #define STEPCHARGE_INP(val) ((val) << 19) 99 + #define STEPCHARGE_INP_AN1 STEPCHARGE_INP(1) 100 + #define STEPCHARGE_RFM_MASK (3 << 23) 101 + #define STEPCHARGE_RFM(val) ((val) << 23) 102 + #define STEPCHARGE_RFM_XNUR STEPCHARGE_RFM(1) 103 + 104 + /* Charge delay */ 105 + #define CHARGEDLY_OPEN_MASK (0x3FFFF << 0) 106 + #define CHARGEDLY_OPEN(val) ((val) << 0) 107 + #define CHARGEDLY_OPENDLY CHARGEDLY_OPEN(1) 108 + 109 + /* Control register */ 110 + #define CNTRLREG_TSCSSENB BIT(0) 111 + #define CNTRLREG_STEPID BIT(1) 112 + #define CNTRLREG_STEPCONFIGWRT BIT(2) 113 + #define CNTRLREG_POWERDOWN BIT(4) 114 + #define CNTRLREG_AFE_CTRL_MASK (3 << 5) 115 + #define CNTRLREG_AFE_CTRL(val) ((val) << 5) 116 + #define CNTRLREG_4WIRE CNTRLREG_AFE_CTRL(1) 117 + #define CNTRLREG_5WIRE CNTRLREG_AFE_CTRL(2) 118 + #define CNTRLREG_8WIRE CNTRLREG_AFE_CTRL(3) 119 + #define CNTRLREG_TSCENB BIT(7) 120 + 121 + #define ADC_CLK 3000000 122 + #define MAX_CLK_DIV 7 123 + #define TOTAL_STEPS 16 124 + #define TOTAL_CHANNELS 8 125 + 126 + #define TSCADC_CELLS 2 127 + 128 + enum tscadc_cells { 129 + TSC_CELL, 130 + ADC_CELL, 131 + }; 132 + 133 + struct mfd_tscadc_board { 134 + struct tsc_data *tsc_init; 135 + struct adc_data *adc_init; 136 + }; 137 + 138 + struct ti_tscadc_dev { 139 + struct device *dev; 140 + struct regmap *regmap_tscadc; 141 + void __iomem *tscadc_base; 142 + int irq; 143 + struct mfd_cell cells[TSCADC_CELLS]; 144 + 145 + /* tsc device */ 146 + struct titsc *tsc; 147 + 148 + /* adc device */ 149 + struct adc_device *adc; 150 + }; 151 + 152 + #endif
+55 -18
include/linux/mfd/tps65090.h
··· 23 23 #define __LINUX_MFD_TPS65090_H 24 24 25 25 #include <linux/irq.h> 26 + #include <linux/regmap.h> 27 + 28 + /* TPS65090 IRQs */ 29 + enum { 30 + TPS65090_IRQ_VAC_STATUS_CHANGE, 31 + TPS65090_IRQ_VSYS_STATUS_CHANGE, 32 + TPS65090_IRQ_BAT_STATUS_CHANGE, 33 + TPS65090_IRQ_CHARGING_STATUS_CHANGE, 34 + TPS65090_IRQ_CHARGING_COMPLETE, 35 + TPS65090_IRQ_OVERLOAD_DCDC1, 36 + TPS65090_IRQ_OVERLOAD_DCDC2, 37 + TPS65090_IRQ_OVERLOAD_DCDC3, 38 + TPS65090_IRQ_OVERLOAD_FET1, 39 + TPS65090_IRQ_OVERLOAD_FET2, 40 + TPS65090_IRQ_OVERLOAD_FET3, 41 + TPS65090_IRQ_OVERLOAD_FET4, 42 + TPS65090_IRQ_OVERLOAD_FET5, 43 + TPS65090_IRQ_OVERLOAD_FET6, 44 + TPS65090_IRQ_OVERLOAD_FET7, 45 + }; 26 46 27 47 /* TPS65090 Regulator ID */ 28 48 enum { ··· 64 44 }; 65 45 66 46 struct tps65090 { 67 - struct mutex lock; 68 47 struct device *dev; 69 - struct i2c_client *client; 70 48 struct regmap *rmap; 71 - struct irq_chip irq_chip; 72 - struct mutex irq_lock; 73 - int irq_base; 74 - unsigned int id; 75 - }; 76 - 77 - struct tps65090_subdev_info { 78 - int id; 79 - const char *name; 80 - void *platform_data; 49 + struct regmap_irq_chip_data *irq_data; 81 50 }; 82 51 83 52 /* ··· 86 77 87 78 struct tps65090_platform_data { 88 79 int irq_base; 89 - int num_subdevs; 90 - struct tps65090_subdev_info *subdevs; 91 80 struct tps65090_regulator_plat_data *reg_pdata[TPS65090_REGULATOR_MAX]; 92 81 }; 93 82 ··· 93 86 * NOTE: the functions below are not intended for use outside 94 87 * of the TPS65090 sub-device drivers 95 88 */ 96 - extern int tps65090_write(struct device *dev, int reg, uint8_t val); 97 - extern int tps65090_read(struct device *dev, int reg, uint8_t *val); 98 - extern int tps65090_set_bits(struct device *dev, int reg, uint8_t bit_num); 99 - extern int tps65090_clr_bits(struct device *dev, int reg, uint8_t bit_num); 89 + static inline int tps65090_write(struct device *dev, int reg, uint8_t val) 90 + { 91 + struct tps65090 *tps = dev_get_drvdata(dev); 92 + 93 + return regmap_write(tps->rmap, reg, val); 94 + } 95 + 96 + static inline int tps65090_read(struct device *dev, int reg, uint8_t *val) 97 + { 98 + struct tps65090 *tps = dev_get_drvdata(dev); 99 + unsigned int temp_val; 100 + int ret; 101 + 102 + ret = regmap_read(tps->rmap, reg, &temp_val); 103 + if (!ret) 104 + *val = temp_val; 105 + return ret; 106 + } 107 + 108 + static inline int tps65090_set_bits(struct device *dev, int reg, 109 + uint8_t bit_num) 110 + { 111 + struct tps65090 *tps = dev_get_drvdata(dev); 112 + 113 + return regmap_update_bits(tps->rmap, reg, BIT(bit_num), ~0u); 114 + } 115 + 116 + static inline int tps65090_clr_bits(struct device *dev, int reg, 117 + uint8_t bit_num) 118 + { 119 + struct tps65090 *tps = dev_get_drvdata(dev); 120 + 121 + return regmap_update_bits(tps->rmap, reg, BIT(bit_num), 0u); 122 + } 100 123 101 124 #endif /*__LINUX_MFD_TPS65090_H */
+1
include/linux/mfd/tps6586x.h
··· 96 96 extern int tps6586x_clr_bits(struct device *dev, int reg, uint8_t bit_mask); 97 97 extern int tps6586x_update(struct device *dev, int reg, uint8_t val, 98 98 uint8_t mask); 99 + extern int tps6586x_irq_get_virq(struct device *dev, int irq); 99 100 100 101 #endif /*__LINUX_MFD_TPS6586X_H */
+98 -45
include/linux/mfd/tps65910.h
··· 572 572 #define SPARE_SPARE_MASK 0xFF 573 573 #define SPARE_SPARE_SHIFT 0 574 574 575 + #define TPS65910_INT_STS_RTC_PERIOD_IT_MASK 0x80 576 + #define TPS65910_INT_STS_RTC_PERIOD_IT_SHIFT 7 577 + #define TPS65910_INT_STS_RTC_ALARM_IT_MASK 0x40 578 + #define TPS65910_INT_STS_RTC_ALARM_IT_SHIFT 6 579 + #define TPS65910_INT_STS_HOTDIE_IT_MASK 0x20 580 + #define TPS65910_INT_STS_HOTDIE_IT_SHIFT 5 581 + #define TPS65910_INT_STS_PWRHOLD_F_IT_MASK 0x10 582 + #define TPS65910_INT_STS_PWRHOLD_F_IT_SHIFT 4 583 + #define TPS65910_INT_STS_PWRON_LP_IT_MASK 0x08 584 + #define TPS65910_INT_STS_PWRON_LP_IT_SHIFT 3 585 + #define TPS65910_INT_STS_PWRON_IT_MASK 0x04 586 + #define TPS65910_INT_STS_PWRON_IT_SHIFT 2 587 + #define TPS65910_INT_STS_VMBHI_IT_MASK 0x02 588 + #define TPS65910_INT_STS_VMBHI_IT_SHIFT 1 589 + #define TPS65910_INT_STS_VMBDCH_IT_MASK 0x01 590 + #define TPS65910_INT_STS_VMBDCH_IT_SHIFT 0 591 + 592 + #define TPS65910_INT_MSK_RTC_PERIOD_IT_MSK_MASK 0x80 593 + #define TPS65910_INT_MSK_RTC_PERIOD_IT_MSK_SHIFT 7 594 + #define TPS65910_INT_MSK_RTC_ALARM_IT_MSK_MASK 0x40 595 + #define TPS65910_INT_MSK_RTC_ALARM_IT_MSK_SHIFT 6 596 + #define TPS65910_INT_MSK_HOTDIE_IT_MSK_MASK 0x20 597 + #define TPS65910_INT_MSK_HOTDIE_IT_MSK_SHIFT 5 598 + #define TPS65910_INT_MSK_PWRHOLD_IT_MSK_MASK 0x10 599 + #define TPS65910_INT_MSK_PWRHOLD_IT_MSK_SHIFT 4 600 + #define TPS65910_INT_MSK_PWRON_LP_IT_MSK_MASK 0x08 601 + #define TPS65910_INT_MSK_PWRON_LP_IT_MSK_SHIFT 3 602 + #define TPS65910_INT_MSK_PWRON_IT_MSK_MASK 0x04 603 + #define TPS65910_INT_MSK_PWRON_IT_MSK_SHIFT 2 604 + #define TPS65910_INT_MSK_VMBHI_IT_MSK_MASK 0x02 605 + #define TPS65910_INT_MSK_VMBHI_IT_MSK_SHIFT 1 606 + #define TPS65910_INT_MSK_VMBDCH_IT_MSK_MASK 0x01 607 + #define TPS65910_INT_MSK_VMBDCH_IT_MSK_SHIFT 0 608 + 609 + #define TPS65910_INT_STS2_GPIO0_F_IT_SHIFT 2 610 + #define TPS65910_INT_STS2_GPIO0_F_IT_MASK 0x02 611 + #define TPS65910_INT_STS2_GPIO0_R_IT_SHIFT 1 612 + #define TPS65910_INT_STS2_GPIO0_R_IT_MASK 0x01 613 + 614 + #define TPS65910_INT_MSK2_GPIO0_F_IT_MSK_SHIFT 2 615 + #define TPS65910_INT_MSK2_GPIO0_F_IT_MSK_MASK 0x02 616 + #define TPS65910_INT_MSK2_GPIO0_R_IT_MSK_SHIFT 1 617 + #define TPS65910_INT_MSK2_GPIO0_R_IT_MSK_MASK 0x01 575 618 576 619 /*Register INT_STS (0x80) register.RegisterDescription */ 577 620 #define INT_STS_RTC_PERIOD_IT_MASK 0x80 ··· 623 580 #define INT_STS_RTC_ALARM_IT_SHIFT 6 624 581 #define INT_STS_HOTDIE_IT_MASK 0x20 625 582 #define INT_STS_HOTDIE_IT_SHIFT 5 626 - #define INT_STS_PWRHOLD_IT_MASK 0x10 627 - #define INT_STS_PWRHOLD_IT_SHIFT 4 583 + #define INT_STS_PWRHOLD_R_IT_MASK 0x10 584 + #define INT_STS_PWRHOLD_R_IT_SHIFT 4 628 585 #define INT_STS_PWRON_LP_IT_MASK 0x08 629 586 #define INT_STS_PWRON_LP_IT_SHIFT 3 630 587 #define INT_STS_PWRON_IT_MASK 0x04 631 588 #define INT_STS_PWRON_IT_SHIFT 2 632 589 #define INT_STS_VMBHI_IT_MASK 0x02 633 590 #define INT_STS_VMBHI_IT_SHIFT 1 634 - #define INT_STS_VMBDCH_IT_MASK 0x01 635 - #define INT_STS_VMBDCH_IT_SHIFT 0 591 + #define INT_STS_PWRHOLD_F_IT_MASK 0x01 592 + #define INT_STS_PWRHOLD_F_IT_SHIFT 0 636 593 637 594 638 595 /*Register INT_MSK (0x80) register.RegisterDescription */ ··· 642 599 #define INT_MSK_RTC_ALARM_IT_MSK_SHIFT 6 643 600 #define INT_MSK_HOTDIE_IT_MSK_MASK 0x20 644 601 #define INT_MSK_HOTDIE_IT_MSK_SHIFT 5 645 - #define INT_MSK_PWRHOLD_IT_MSK_MASK 0x10 646 - #define INT_MSK_PWRHOLD_IT_MSK_SHIFT 4 602 + #define INT_MSK_PWRHOLD_R_IT_MSK_MASK 0x10 603 + #define INT_MSK_PWRHOLD_R_IT_MSK_SHIFT 4 647 604 #define INT_MSK_PWRON_LP_IT_MSK_MASK 0x08 648 605 #define INT_MSK_PWRON_LP_IT_MSK_SHIFT 3 649 606 #define INT_MSK_PWRON_IT_MSK_MASK 0x04 650 607 #define INT_MSK_PWRON_IT_MSK_SHIFT 2 651 608 #define INT_MSK_VMBHI_IT_MSK_MASK 0x02 652 609 #define INT_MSK_VMBHI_IT_MSK_SHIFT 1 653 - #define INT_MSK_VMBDCH_IT_MSK_MASK 0x01 654 - #define INT_MSK_VMBDCH_IT_MSK_SHIFT 0 610 + #define INT_MSK_PWRHOLD_F_IT_MSK_MASK 0x01 611 + #define INT_MSK_PWRHOLD_F_IT_MSK_SHIFT 0 655 612 656 613 657 614 /*Register INT_STS2 (0x80) register.RegisterDescription */ ··· 693 650 694 651 695 652 /*Register INT_STS3 (0x80) register.RegisterDescription */ 653 + #define INT_STS3_PWRDN_IT_MASK 0x80 654 + #define INT_STS3_PWRDN_IT_SHIFT 7 655 + #define INT_STS3_VMBCH2_L_IT_MASK 0x40 656 + #define INT_STS3_VMBCH2_L_IT_SHIFT 6 657 + #define INT_STS3_VMBCH2_H_IT_MASK 0x20 658 + #define INT_STS3_VMBCH2_H_IT_SHIFT 5 659 + #define INT_STS3_WTCHDG_IT_MASK 0x10 660 + #define INT_STS3_WTCHDG_IT_SHIFT 4 696 661 #define INT_STS3_GPIO5_F_IT_MASK 0x08 697 662 #define INT_STS3_GPIO5_F_IT_SHIFT 3 698 663 #define INT_STS3_GPIO5_R_IT_MASK 0x04 ··· 712 661 713 662 714 663 /*Register INT_MSK3 (0x80) register.RegisterDescription */ 664 + #define INT_MSK3_PWRDN_IT_MSK_MASK 0x80 665 + #define INT_MSK3_PWRDN_IT_MSK_SHIFT 7 666 + #define INT_MSK3_VMBCH2_L_IT_MSK_MASK 0x40 667 + #define INT_MSK3_VMBCH2_L_IT_MSK_SHIFT 6 668 + #define INT_MSK3_VMBCH2_H_IT_MSK_MASK 0x20 669 + #define INT_MSK3_VMBCH2_H_IT_MSK_SHIFT 5 670 + #define INT_MSK3_WTCHDG_IT_MSK_MASK 0x10 671 + #define INT_MSK3_WTCHDG_IT_MSK_SHIFT 4 715 672 #define INT_MSK3_GPIO5_F_IT_MSK_MASK 0x08 716 673 #define INT_MSK3_GPIO5_F_IT_MSK_SHIFT 3 717 674 #define INT_MSK3_GPIO5_R_IT_MSK_MASK 0x04 ··· 780 721 #define TPS65910_IRQ_GPIO_F 9 781 722 #define TPS65910_NUM_IRQ 10 782 723 783 - #define TPS65911_IRQ_VBAT_VMBDCH 0 784 - #define TPS65911_IRQ_VBAT_VMBDCH2L 1 785 - #define TPS65911_IRQ_VBAT_VMBDCH2H 2 786 - #define TPS65911_IRQ_VBAT_VMHI 3 787 - #define TPS65911_IRQ_PWRON 4 788 - #define TPS65911_IRQ_PWRON_LP 5 789 - #define TPS65911_IRQ_PWRHOLD_F 6 790 - #define TPS65911_IRQ_PWRHOLD_R 7 791 - #define TPS65911_IRQ_HOTDIE 8 792 - #define TPS65911_IRQ_RTC_ALARM 9 793 - #define TPS65911_IRQ_RTC_PERIOD 10 794 - #define TPS65911_IRQ_GPIO0_R 11 795 - #define TPS65911_IRQ_GPIO0_F 12 796 - #define TPS65911_IRQ_GPIO1_R 13 797 - #define TPS65911_IRQ_GPIO1_F 14 798 - #define TPS65911_IRQ_GPIO2_R 15 799 - #define TPS65911_IRQ_GPIO2_F 16 800 - #define TPS65911_IRQ_GPIO3_R 17 801 - #define TPS65911_IRQ_GPIO3_F 18 802 - #define TPS65911_IRQ_GPIO4_R 19 803 - #define TPS65911_IRQ_GPIO4_F 20 804 - #define TPS65911_IRQ_GPIO5_R 21 805 - #define TPS65911_IRQ_GPIO5_F 22 806 - #define TPS65911_IRQ_WTCHDG 23 807 - #define TPS65911_IRQ_PWRDN 24 724 + #define TPS65911_IRQ_PWRHOLD_F 0 725 + #define TPS65911_IRQ_VBAT_VMHI 1 726 + #define TPS65911_IRQ_PWRON 2 727 + #define TPS65911_IRQ_PWRON_LP 3 728 + #define TPS65911_IRQ_PWRHOLD_R 4 729 + #define TPS65911_IRQ_HOTDIE 5 730 + #define TPS65911_IRQ_RTC_ALARM 6 731 + #define TPS65911_IRQ_RTC_PERIOD 7 732 + #define TPS65911_IRQ_GPIO0_R 8 733 + #define TPS65911_IRQ_GPIO0_F 9 734 + #define TPS65911_IRQ_GPIO1_R 10 735 + #define TPS65911_IRQ_GPIO1_F 11 736 + #define TPS65911_IRQ_GPIO2_R 12 737 + #define TPS65911_IRQ_GPIO2_F 13 738 + #define TPS65911_IRQ_GPIO3_R 14 739 + #define TPS65911_IRQ_GPIO3_F 15 740 + #define TPS65911_IRQ_GPIO4_R 16 741 + #define TPS65911_IRQ_GPIO4_F 17 742 + #define TPS65911_IRQ_GPIO5_R 18 743 + #define TPS65911_IRQ_GPIO5_F 19 744 + #define TPS65911_IRQ_WTCHDG 20 745 + #define TPS65911_IRQ_VMBCH2_H 21 746 + #define TPS65911_IRQ_VMBCH2_L 22 747 + #define TPS65911_IRQ_PWRDN 23 808 748 809 - #define TPS65911_NUM_IRQ 25 810 - 749 + #define TPS65911_NUM_IRQ 24 811 750 812 751 /* GPIO Register Definitions */ 813 752 #define TPS65910_GPIO_DEB BIT(2) ··· 893 836 struct device *dev; 894 837 struct i2c_client *i2c_client; 895 838 struct regmap *regmap; 896 - struct mutex io_mutex; 897 839 unsigned int id; 898 840 899 841 /* Client devices */ ··· 904 848 struct tps65910_board *of_plat_data; 905 849 906 850 /* IRQ Handling */ 907 - struct mutex irq_lock; 908 851 int chip_irq; 909 - int irq_base; 910 - int irq_num; 911 - u32 irq_mask; 912 - struct irq_domain *domain; 852 + struct regmap_irq_chip_data *irq_data; 913 853 }; 914 854 915 855 struct tps65910_platform_data { 916 856 int irq; 917 857 int irq_base; 918 858 }; 919 - 920 - int tps65910_irq_init(struct tps65910 *tps65910, int irq, 921 - struct tps65910_platform_data *pdata); 922 - int tps65910_irq_exit(struct tps65910 *tps65910); 923 859 924 860 static inline int tps65910_chip_id(struct tps65910 *tps65910) 925 861 { ··· 946 898 u8 mask, u8 val) 947 899 { 948 900 return regmap_update_bits(tps65910->regmap, reg, mask, val); 901 + } 902 + 903 + static inline int tps65910_irq_get_virq(struct tps65910 *tps65910, int irq) 904 + { 905 + return regmap_irq_get_virq(tps65910->irq_data, irq); 949 906 } 950 907 951 908 #endif /* __LINUX_MFD_TPS65910_H */
+637
include/linux/mfd/tps80031.h
··· 1 + /* 2 + * tps80031.h -- TI TPS80031 and TI TPS80032 PMIC driver. 3 + * 4 + * Copyright (c) 2012, NVIDIA Corporation. 5 + * 6 + * Author: Laxman Dewangan <ldewangan@nvidia.com> 7 + * 8 + * This program is free software; you can redistribute it and/or 9 + * modify it under the terms of the GNU General Public License as 10 + * published by the Free Software Foundation version 2. 11 + * 12 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind, 13 + * whether express or implied; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 + * General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public License 18 + * along with this program; if not, write to the Free Software 19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 20 + * 02111-1307, USA 21 + */ 22 + 23 + #ifndef __LINUX_MFD_TPS80031_H 24 + #define __LINUX_MFD_TPS80031_H 25 + 26 + #include <linux/device.h> 27 + #include <linux/regmap.h> 28 + 29 + /* Pull-ups/Pull-downs */ 30 + #define TPS80031_CFG_INPUT_PUPD1 0xF0 31 + #define TPS80031_CFG_INPUT_PUPD2 0xF1 32 + #define TPS80031_CFG_INPUT_PUPD3 0xF2 33 + #define TPS80031_CFG_INPUT_PUPD4 0xF3 34 + #define TPS80031_CFG_LDO_PD1 0xF4 35 + #define TPS80031_CFG_LDO_PD2 0xF5 36 + #define TPS80031_CFG_SMPS_PD 0xF6 37 + 38 + /* Real Time Clock */ 39 + #define TPS80031_SECONDS_REG 0x00 40 + #define TPS80031_MINUTES_REG 0x01 41 + #define TPS80031_HOURS_REG 0x02 42 + #define TPS80031_DAYS_REG 0x03 43 + #define TPS80031_MONTHS_REG 0x04 44 + #define TPS80031_YEARS_REG 0x05 45 + #define TPS80031_WEEKS_REG 0x06 46 + #define TPS80031_ALARM_SECONDS_REG 0x08 47 + #define TPS80031_ALARM_MINUTES_REG 0x09 48 + #define TPS80031_ALARM_HOURS_REG 0x0A 49 + #define TPS80031_ALARM_DAYS_REG 0x0B 50 + #define TPS80031_ALARM_MONTHS_REG 0x0C 51 + #define TPS80031_ALARM_YEARS_REG 0x0D 52 + #define TPS80031_RTC_CTRL_REG 0x10 53 + #define TPS80031_RTC_STATUS_REG 0x11 54 + #define TPS80031_RTC_INTERRUPTS_REG 0x12 55 + #define TPS80031_RTC_COMP_LSB_REG 0x13 56 + #define TPS80031_RTC_COMP_MSB_REG 0x14 57 + #define TPS80031_RTC_RESET_STATUS_REG 0x16 58 + 59 + /*PMC Master Module */ 60 + #define TPS80031_PHOENIX_START_CONDITION 0x1F 61 + #define TPS80031_PHOENIX_MSK_TRANSITION 0x20 62 + #define TPS80031_STS_HW_CONDITIONS 0x21 63 + #define TPS80031_PHOENIX_LAST_TURNOFF_STS 0x22 64 + #define TPS80031_VSYSMIN_LO_THRESHOLD 0x23 65 + #define TPS80031_VSYSMIN_HI_THRESHOLD 0x24 66 + #define TPS80031_PHOENIX_DEV_ON 0x25 67 + #define TPS80031_STS_PWR_GRP_STATE 0x27 68 + #define TPS80031_PH_CFG_VSYSLOW 0x28 69 + #define TPS80031_PH_STS_BOOT 0x29 70 + #define TPS80031_PHOENIX_SENS_TRANSITION 0x2A 71 + #define TPS80031_PHOENIX_SEQ_CFG 0x2B 72 + #define TPS80031_PRIMARY_WATCHDOG_CFG 0X2C 73 + #define TPS80031_KEY_PRESS_DUR_CFG 0X2D 74 + #define TPS80031_SMPS_LDO_SHORT_STS 0x2E 75 + 76 + /* PMC Slave Module - Broadcast */ 77 + #define TPS80031_BROADCAST_ADDR_ALL 0x31 78 + #define TPS80031_BROADCAST_ADDR_REF 0x32 79 + #define TPS80031_BROADCAST_ADDR_PROV 0x33 80 + #define TPS80031_BROADCAST_ADDR_CLK_RST 0x34 81 + 82 + /* PMC Slave Module SMPS Regulators */ 83 + #define TPS80031_SMPS4_CFG_TRANS 0x41 84 + #define TPS80031_SMPS4_CFG_STATE 0x42 85 + #define TPS80031_SMPS4_CFG_VOLTAGE 0x44 86 + #define TPS80031_VIO_CFG_TRANS 0x47 87 + #define TPS80031_VIO_CFG_STATE 0x48 88 + #define TPS80031_VIO_CFG_FORCE 0x49 89 + #define TPS80031_VIO_CFG_VOLTAGE 0x4A 90 + #define TPS80031_VIO_CFG_STEP 0x48 91 + #define TPS80031_SMPS1_CFG_TRANS 0x53 92 + #define TPS80031_SMPS1_CFG_STATE 0x54 93 + #define TPS80031_SMPS1_CFG_FORCE 0x55 94 + #define TPS80031_SMPS1_CFG_VOLTAGE 0x56 95 + #define TPS80031_SMPS1_CFG_STEP 0x57 96 + #define TPS80031_SMPS2_CFG_TRANS 0x59 97 + #define TPS80031_SMPS2_CFG_STATE 0x5A 98 + #define TPS80031_SMPS2_CFG_FORCE 0x5B 99 + #define TPS80031_SMPS2_CFG_VOLTAGE 0x5C 100 + #define TPS80031_SMPS2_CFG_STEP 0x5D 101 + #define TPS80031_SMPS3_CFG_TRANS 0x65 102 + #define TPS80031_SMPS3_CFG_STATE 0x66 103 + #define TPS80031_SMPS3_CFG_VOLTAGE 0x68 104 + 105 + /* PMC Slave Module LDO Regulators */ 106 + #define TPS80031_VANA_CFG_TRANS 0x81 107 + #define TPS80031_VANA_CFG_STATE 0x82 108 + #define TPS80031_VANA_CFG_VOLTAGE 0x83 109 + #define TPS80031_LDO2_CFG_TRANS 0x85 110 + #define TPS80031_LDO2_CFG_STATE 0x86 111 + #define TPS80031_LDO2_CFG_VOLTAGE 0x87 112 + #define TPS80031_LDO4_CFG_TRANS 0x89 113 + #define TPS80031_LDO4_CFG_STATE 0x8A 114 + #define TPS80031_LDO4_CFG_VOLTAGE 0x8B 115 + #define TPS80031_LDO3_CFG_TRANS 0x8D 116 + #define TPS80031_LDO3_CFG_STATE 0x8E 117 + #define TPS80031_LDO3_CFG_VOLTAGE 0x8F 118 + #define TPS80031_LDO6_CFG_TRANS 0x91 119 + #define TPS80031_LDO6_CFG_STATE 0x92 120 + #define TPS80031_LDO6_CFG_VOLTAGE 0x93 121 + #define TPS80031_LDOLN_CFG_TRANS 0x95 122 + #define TPS80031_LDOLN_CFG_STATE 0x96 123 + #define TPS80031_LDOLN_CFG_VOLTAGE 0x97 124 + #define TPS80031_LDO5_CFG_TRANS 0x99 125 + #define TPS80031_LDO5_CFG_STATE 0x9A 126 + #define TPS80031_LDO5_CFG_VOLTAGE 0x9B 127 + #define TPS80031_LDO1_CFG_TRANS 0x9D 128 + #define TPS80031_LDO1_CFG_STATE 0x9E 129 + #define TPS80031_LDO1_CFG_VOLTAGE 0x9F 130 + #define TPS80031_LDOUSB_CFG_TRANS 0xA1 131 + #define TPS80031_LDOUSB_CFG_STATE 0xA2 132 + #define TPS80031_LDOUSB_CFG_VOLTAGE 0xA3 133 + #define TPS80031_LDO7_CFG_TRANS 0xA5 134 + #define TPS80031_LDO7_CFG_STATE 0xA6 135 + #define TPS80031_LDO7_CFG_VOLTAGE 0xA7 136 + 137 + /* PMC Slave Module External Control */ 138 + #define TPS80031_REGEN1_CFG_TRANS 0xAE 139 + #define TPS80031_REGEN1_CFG_STATE 0xAF 140 + #define TPS80031_REGEN2_CFG_TRANS 0xB1 141 + #define TPS80031_REGEN2_CFG_STATE 0xB2 142 + #define TPS80031_SYSEN_CFG_TRANS 0xB4 143 + #define TPS80031_SYSEN_CFG_STATE 0xB5 144 + 145 + /* PMC Slave Module Internal Control */ 146 + #define TPS80031_NRESPWRON_CFG_TRANS 0xB7 147 + #define TPS80031_NRESPWRON_CFG_STATE 0xB8 148 + #define TPS80031_CLK32KAO_CFG_TRANS 0xBA 149 + #define TPS80031_CLK32KAO_CFG_STATE 0xBB 150 + #define TPS80031_CLK32KG_CFG_TRANS 0xBD 151 + #define TPS80031_CLK32KG_CFG_STATE 0xBE 152 + #define TPS80031_CLK32KAUDIO_CFG_TRANS 0xC0 153 + #define TPS80031_CLK32KAUDIO_CFG_STATE 0xC1 154 + #define TPS80031_VRTC_CFG_TRANS 0xC3 155 + #define TPS80031_VRTC_CFG_STATE 0xC4 156 + #define TPS80031_BIAS_CFG_TRANS 0xC6 157 + #define TPS80031_BIAS_CFG_STATE 0xC7 158 + #define TPS80031_VSYSMIN_HI_CFG_TRANS 0xC9 159 + #define TPS80031_VSYSMIN_HI_CFG_STATE 0xCA 160 + #define TPS80031_RC6MHZ_CFG_TRANS 0xCC 161 + #define TPS80031_RC6MHZ_CFG_STATE 0xCD 162 + #define TPS80031_TMP_CFG_TRANS 0xCF 163 + #define TPS80031_TMP_CFG_STATE 0xD0 164 + 165 + /* PMC Slave Module resources assignment */ 166 + #define TPS80031_PREQ1_RES_ASS_A 0xD7 167 + #define TPS80031_PREQ1_RES_ASS_B 0xD8 168 + #define TPS80031_PREQ1_RES_ASS_C 0xD9 169 + #define TPS80031_PREQ2_RES_ASS_A 0xDA 170 + #define TPS80031_PREQ2_RES_ASS_B 0xDB 171 + #define TPS80031_PREQ2_RES_ASS_C 0xDC 172 + #define TPS80031_PREQ3_RES_ASS_A 0xDD 173 + #define TPS80031_PREQ3_RES_ASS_B 0xDE 174 + #define TPS80031_PREQ3_RES_ASS_C 0xDF 175 + 176 + /* PMC Slave Module Miscellaneous */ 177 + #define TPS80031_SMPS_OFFSET 0xE0 178 + #define TPS80031_SMPS_MULT 0xE3 179 + #define TPS80031_MISC1 0xE4 180 + #define TPS80031_MISC2 0xE5 181 + #define TPS80031_BBSPOR_CFG 0xE6 182 + #define TPS80031_TMP_CFG 0xE7 183 + 184 + /* Battery Charging Controller and Indicator LED */ 185 + #define TPS80031_CONTROLLER_CTRL2 0xDA 186 + #define TPS80031_CONTROLLER_VSEL_COMP 0xDB 187 + #define TPS80031_CHARGERUSB_VSYSREG 0xDC 188 + #define TPS80031_CHARGERUSB_VICHRG_PC 0xDD 189 + #define TPS80031_LINEAR_CHRG_STS 0xDE 190 + #define TPS80031_CONTROLLER_INT_MASK 0xE0 191 + #define TPS80031_CONTROLLER_CTRL1 0xE1 192 + #define TPS80031_CONTROLLER_WDG 0xE2 193 + #define TPS80031_CONTROLLER_STAT1 0xE3 194 + #define TPS80031_CHARGERUSB_INT_STATUS 0xE4 195 + #define TPS80031_CHARGERUSB_INT_MASK 0xE5 196 + #define TPS80031_CHARGERUSB_STATUS_INT1 0xE6 197 + #define TPS80031_CHARGERUSB_STATUS_INT2 0xE7 198 + #define TPS80031_CHARGERUSB_CTRL1 0xE8 199 + #define TPS80031_CHARGERUSB_CTRL2 0xE9 200 + #define TPS80031_CHARGERUSB_CTRL3 0xEA 201 + #define TPS80031_CHARGERUSB_STAT1 0xEB 202 + #define TPS80031_CHARGERUSB_VOREG 0xEC 203 + #define TPS80031_CHARGERUSB_VICHRG 0xED 204 + #define TPS80031_CHARGERUSB_CINLIMIT 0xEE 205 + #define TPS80031_CHARGERUSB_CTRLLIMIT1 0xEF 206 + #define TPS80031_CHARGERUSB_CTRLLIMIT2 0xF0 207 + #define TPS80031_LED_PWM_CTRL1 0xF4 208 + #define TPS80031_LED_PWM_CTRL2 0xF5 209 + 210 + /* USB On-The-Go */ 211 + #define TPS80031_BACKUP_REG 0xFA 212 + #define TPS80031_USB_VENDOR_ID_LSB 0x00 213 + #define TPS80031_USB_VENDOR_ID_MSB 0x01 214 + #define TPS80031_USB_PRODUCT_ID_LSB 0x02 215 + #define TPS80031_USB_PRODUCT_ID_MSB 0x03 216 + #define TPS80031_USB_VBUS_CTRL_SET 0x04 217 + #define TPS80031_USB_VBUS_CTRL_CLR 0x05 218 + #define TPS80031_USB_ID_CTRL_SET 0x06 219 + #define TPS80031_USB_ID_CTRL_CLR 0x07 220 + #define TPS80031_USB_VBUS_INT_SRC 0x08 221 + #define TPS80031_USB_VBUS_INT_LATCH_SET 0x09 222 + #define TPS80031_USB_VBUS_INT_LATCH_CLR 0x0A 223 + #define TPS80031_USB_VBUS_INT_EN_LO_SET 0x0B 224 + #define TPS80031_USB_VBUS_INT_EN_LO_CLR 0x0C 225 + #define TPS80031_USB_VBUS_INT_EN_HI_SET 0x0D 226 + #define TPS80031_USB_VBUS_INT_EN_HI_CLR 0x0E 227 + #define TPS80031_USB_ID_INT_SRC 0x0F 228 + #define TPS80031_USB_ID_INT_LATCH_SET 0x10 229 + #define TPS80031_USB_ID_INT_LATCH_CLR 0x11 230 + #define TPS80031_USB_ID_INT_EN_LO_SET 0x12 231 + #define TPS80031_USB_ID_INT_EN_LO_CLR 0x13 232 + #define TPS80031_USB_ID_INT_EN_HI_SET 0x14 233 + #define TPS80031_USB_ID_INT_EN_HI_CLR 0x15 234 + #define TPS80031_USB_OTG_ADP_CTRL 0x16 235 + #define TPS80031_USB_OTG_ADP_HIGH 0x17 236 + #define TPS80031_USB_OTG_ADP_LOW 0x18 237 + #define TPS80031_USB_OTG_ADP_RISE 0x19 238 + #define TPS80031_USB_OTG_REVISION 0x1A 239 + 240 + /* Gas Gauge */ 241 + #define TPS80031_FG_REG_00 0xC0 242 + #define TPS80031_FG_REG_01 0xC1 243 + #define TPS80031_FG_REG_02 0xC2 244 + #define TPS80031_FG_REG_03 0xC3 245 + #define TPS80031_FG_REG_04 0xC4 246 + #define TPS80031_FG_REG_05 0xC5 247 + #define TPS80031_FG_REG_06 0xC6 248 + #define TPS80031_FG_REG_07 0xC7 249 + #define TPS80031_FG_REG_08 0xC8 250 + #define TPS80031_FG_REG_09 0xC9 251 + #define TPS80031_FG_REG_10 0xCA 252 + #define TPS80031_FG_REG_11 0xCB 253 + 254 + /* General Purpose ADC */ 255 + #define TPS80031_GPADC_CTRL 0x2E 256 + #define TPS80031_GPADC_CTRL2 0x2F 257 + #define TPS80031_RTSELECT_LSB 0x32 258 + #define TPS80031_RTSELECT_ISB 0x33 259 + #define TPS80031_RTSELECT_MSB 0x34 260 + #define TPS80031_GPSELECT_ISB 0x35 261 + #define TPS80031_CTRL_P1 0x36 262 + #define TPS80031_RTCH0_LSB 0x37 263 + #define TPS80031_RTCH0_MSB 0x38 264 + #define TPS80031_RTCH1_LSB 0x39 265 + #define TPS80031_RTCH1_MSB 0x3A 266 + #define TPS80031_GPCH0_LSB 0x3B 267 + #define TPS80031_GPCH0_MSB 0x3C 268 + 269 + /* SIM, MMC and Battery Detection */ 270 + #define TPS80031_SIMDEBOUNCING 0xEB 271 + #define TPS80031_SIMCTRL 0xEC 272 + #define TPS80031_MMCDEBOUNCING 0xED 273 + #define TPS80031_MMCCTRL 0xEE 274 + #define TPS80031_BATDEBOUNCING 0xEF 275 + 276 + /* Vibrator Driver and PWMs */ 277 + #define TPS80031_VIBCTRL 0x9B 278 + #define TPS80031_VIBMODE 0x9C 279 + #define TPS80031_PWM1ON 0xBA 280 + #define TPS80031_PWM1OFF 0xBB 281 + #define TPS80031_PWM2ON 0xBD 282 + #define TPS80031_PWM2OFF 0xBE 283 + 284 + /* Control Interface */ 285 + #define TPS80031_INT_STS_A 0xD0 286 + #define TPS80031_INT_STS_B 0xD1 287 + #define TPS80031_INT_STS_C 0xD2 288 + #define TPS80031_INT_MSK_LINE_A 0xD3 289 + #define TPS80031_INT_MSK_LINE_B 0xD4 290 + #define TPS80031_INT_MSK_LINE_C 0xD5 291 + #define TPS80031_INT_MSK_STS_A 0xD6 292 + #define TPS80031_INT_MSK_STS_B 0xD7 293 + #define TPS80031_INT_MSK_STS_C 0xD8 294 + #define TPS80031_TOGGLE1 0x90 295 + #define TPS80031_TOGGLE2 0x91 296 + #define TPS80031_TOGGLE3 0x92 297 + #define TPS80031_PWDNSTATUS1 0x93 298 + #define TPS80031_PWDNSTATUS2 0x94 299 + #define TPS80031_VALIDITY0 0x17 300 + #define TPS80031_VALIDITY1 0x18 301 + #define TPS80031_VALIDITY2 0x19 302 + #define TPS80031_VALIDITY3 0x1A 303 + #define TPS80031_VALIDITY4 0x1B 304 + #define TPS80031_VALIDITY5 0x1C 305 + #define TPS80031_VALIDITY6 0x1D 306 + #define TPS80031_VALIDITY7 0x1E 307 + 308 + /* Version number related register */ 309 + #define TPS80031_JTAGVERNUM 0x87 310 + #define TPS80031_EPROM_REV 0xDF 311 + 312 + /* GPADC Trimming Bits. */ 313 + #define TPS80031_GPADC_TRIM0 0xCC 314 + #define TPS80031_GPADC_TRIM1 0xCD 315 + #define TPS80031_GPADC_TRIM2 0xCE 316 + #define TPS80031_GPADC_TRIM3 0xCF 317 + #define TPS80031_GPADC_TRIM4 0xD0 318 + #define TPS80031_GPADC_TRIM5 0xD1 319 + #define TPS80031_GPADC_TRIM6 0xD2 320 + #define TPS80031_GPADC_TRIM7 0xD3 321 + #define TPS80031_GPADC_TRIM8 0xD4 322 + #define TPS80031_GPADC_TRIM9 0xD5 323 + #define TPS80031_GPADC_TRIM10 0xD6 324 + #define TPS80031_GPADC_TRIM11 0xD7 325 + #define TPS80031_GPADC_TRIM12 0xD8 326 + #define TPS80031_GPADC_TRIM13 0xD9 327 + #define TPS80031_GPADC_TRIM14 0xDA 328 + #define TPS80031_GPADC_TRIM15 0xDB 329 + #define TPS80031_GPADC_TRIM16 0xDC 330 + #define TPS80031_GPADC_TRIM17 0xDD 331 + #define TPS80031_GPADC_TRIM18 0xDE 332 + 333 + /* TPS80031_CONTROLLER_STAT1 bit fields */ 334 + #define TPS80031_CONTROLLER_STAT1_BAT_TEMP 0 335 + #define TPS80031_CONTROLLER_STAT1_BAT_REMOVED 1 336 + #define TPS80031_CONTROLLER_STAT1_VBUS_DET 2 337 + #define TPS80031_CONTROLLER_STAT1_VAC_DET 3 338 + #define TPS80031_CONTROLLER_STAT1_FAULT_WDG 4 339 + #define TPS80031_CONTROLLER_STAT1_LINCH_GATED 6 340 + /* TPS80031_CONTROLLER_INT_MASK bit filed */ 341 + #define TPS80031_CONTROLLER_INT_MASK_MVAC_DET 0 342 + #define TPS80031_CONTROLLER_INT_MASK_MVBUS_DET 1 343 + #define TPS80031_CONTROLLER_INT_MASK_MBAT_TEMP 2 344 + #define TPS80031_CONTROLLER_INT_MASK_MFAULT_WDG 3 345 + #define TPS80031_CONTROLLER_INT_MASK_MBAT_REMOVED 4 346 + #define TPS80031_CONTROLLER_INT_MASK_MLINCH_GATED 5 347 + 348 + #define TPS80031_CHARGE_CONTROL_SUB_INT_MASK 0x3F 349 + 350 + /* TPS80031_PHOENIX_DEV_ON bit field */ 351 + #define TPS80031_DEVOFF 0x1 352 + 353 + #define TPS80031_EXT_CONTROL_CFG_TRANS 0 354 + #define TPS80031_EXT_CONTROL_CFG_STATE 1 355 + 356 + /* State register field */ 357 + #define TPS80031_STATE_OFF 0x00 358 + #define TPS80031_STATE_ON 0x01 359 + #define TPS80031_STATE_MASK 0x03 360 + 361 + /* Trans register field */ 362 + #define TPS80031_TRANS_ACTIVE_OFF 0x00 363 + #define TPS80031_TRANS_ACTIVE_ON 0x01 364 + #define TPS80031_TRANS_ACTIVE_MASK 0x03 365 + #define TPS80031_TRANS_SLEEP_OFF 0x00 366 + #define TPS80031_TRANS_SLEEP_ON 0x04 367 + #define TPS80031_TRANS_SLEEP_MASK 0x0C 368 + #define TPS80031_TRANS_OFF_OFF 0x00 369 + #define TPS80031_TRANS_OFF_ACTIVE 0x10 370 + #define TPS80031_TRANS_OFF_MASK 0x30 371 + 372 + #define TPS80031_EXT_PWR_REQ (TPS80031_PWR_REQ_INPUT_PREQ1 | \ 373 + TPS80031_PWR_REQ_INPUT_PREQ2 | \ 374 + TPS80031_PWR_REQ_INPUT_PREQ3) 375 + 376 + /* TPS80031_BBSPOR_CFG bit field */ 377 + #define TPS80031_BBSPOR_CHG_EN 0x8 378 + #define TPS80031_MAX_REGISTER 0xFF 379 + 380 + struct i2c_client; 381 + 382 + /* Supported chips */ 383 + enum chips { 384 + TPS80031 = 0x00000001, 385 + TPS80032 = 0x00000002, 386 + }; 387 + 388 + enum { 389 + TPS80031_INT_PWRON, 390 + TPS80031_INT_RPWRON, 391 + TPS80031_INT_SYS_VLOW, 392 + TPS80031_INT_RTC_ALARM, 393 + TPS80031_INT_RTC_PERIOD, 394 + TPS80031_INT_HOT_DIE, 395 + TPS80031_INT_VXX_SHORT, 396 + TPS80031_INT_SPDURATION, 397 + TPS80031_INT_WATCHDOG, 398 + TPS80031_INT_BAT, 399 + TPS80031_INT_SIM, 400 + TPS80031_INT_MMC, 401 + TPS80031_INT_RES, 402 + TPS80031_INT_GPADC_RT, 403 + TPS80031_INT_GPADC_SW2_EOC, 404 + TPS80031_INT_CC_AUTOCAL, 405 + TPS80031_INT_ID_WKUP, 406 + TPS80031_INT_VBUSS_WKUP, 407 + TPS80031_INT_ID, 408 + TPS80031_INT_VBUS, 409 + TPS80031_INT_CHRG_CTRL, 410 + TPS80031_INT_EXT_CHRG, 411 + TPS80031_INT_INT_CHRG, 412 + TPS80031_INT_RES2, 413 + TPS80031_INT_BAT_TEMP_OVRANGE, 414 + TPS80031_INT_BAT_REMOVED, 415 + TPS80031_INT_VBUS_DET, 416 + TPS80031_INT_VAC_DET, 417 + TPS80031_INT_FAULT_WDG, 418 + TPS80031_INT_LINCH_GATED, 419 + 420 + /* Last interrupt id to get the end number */ 421 + TPS80031_INT_NR, 422 + }; 423 + 424 + /* TPS80031 Slave IDs */ 425 + #define TPS80031_NUM_SLAVES 4 426 + #define TPS80031_SLAVE_ID0 0 427 + #define TPS80031_SLAVE_ID1 1 428 + #define TPS80031_SLAVE_ID2 2 429 + #define TPS80031_SLAVE_ID3 3 430 + 431 + /* TPS80031 I2C addresses */ 432 + #define TPS80031_I2C_ID0_ADDR 0x12 433 + #define TPS80031_I2C_ID1_ADDR 0x48 434 + #define TPS80031_I2C_ID2_ADDR 0x49 435 + #define TPS80031_I2C_ID3_ADDR 0x4A 436 + 437 + enum { 438 + TPS80031_REGULATOR_VIO, 439 + TPS80031_REGULATOR_SMPS1, 440 + TPS80031_REGULATOR_SMPS2, 441 + TPS80031_REGULATOR_SMPS3, 442 + TPS80031_REGULATOR_SMPS4, 443 + TPS80031_REGULATOR_VANA, 444 + TPS80031_REGULATOR_LDO1, 445 + TPS80031_REGULATOR_LDO2, 446 + TPS80031_REGULATOR_LDO3, 447 + TPS80031_REGULATOR_LDO4, 448 + TPS80031_REGULATOR_LDO5, 449 + TPS80031_REGULATOR_LDO6, 450 + TPS80031_REGULATOR_LDO7, 451 + TPS80031_REGULATOR_LDOLN, 452 + TPS80031_REGULATOR_LDOUSB, 453 + TPS80031_REGULATOR_VBUS, 454 + TPS80031_REGULATOR_REGEN1, 455 + TPS80031_REGULATOR_REGEN2, 456 + TPS80031_REGULATOR_SYSEN, 457 + TPS80031_REGULATOR_MAX, 458 + }; 459 + 460 + /* Different configurations for the rails */ 461 + enum { 462 + /* USBLDO input selection */ 463 + TPS80031_USBLDO_INPUT_VSYS = 0x00000001, 464 + TPS80031_USBLDO_INPUT_PMID = 0x00000002, 465 + 466 + /* LDO3 output mode */ 467 + TPS80031_LDO3_OUTPUT_VIB = 0x00000004, 468 + 469 + /* VBUS configuration */ 470 + TPS80031_VBUS_DISCHRG_EN_PDN = 0x00000004, 471 + TPS80031_VBUS_SW_ONLY = 0x00000008, 472 + TPS80031_VBUS_SW_N_ID = 0x00000010, 473 + }; 474 + 475 + /* External controls requests */ 476 + enum tps80031_ext_control { 477 + TPS80031_PWR_REQ_INPUT_NONE = 0x00000000, 478 + TPS80031_PWR_REQ_INPUT_PREQ1 = 0x00000001, 479 + TPS80031_PWR_REQ_INPUT_PREQ2 = 0x00000002, 480 + TPS80031_PWR_REQ_INPUT_PREQ3 = 0x00000004, 481 + TPS80031_PWR_OFF_ON_SLEEP = 0x00000008, 482 + TPS80031_PWR_ON_ON_SLEEP = 0x00000010, 483 + }; 484 + 485 + enum tps80031_pupd_pins { 486 + TPS80031_PREQ1 = 0, 487 + TPS80031_PREQ2A, 488 + TPS80031_PREQ2B, 489 + TPS80031_PREQ2C, 490 + TPS80031_PREQ3, 491 + TPS80031_NRES_WARM, 492 + TPS80031_PWM_FORCE, 493 + TPS80031_CHRG_EXT_CHRG_STATZ, 494 + TPS80031_SIM, 495 + TPS80031_MMC, 496 + TPS80031_GPADC_START, 497 + TPS80031_DVSI2C_SCL, 498 + TPS80031_DVSI2C_SDA, 499 + TPS80031_CTLI2C_SCL, 500 + TPS80031_CTLI2C_SDA, 501 + }; 502 + 503 + enum tps80031_pupd_settings { 504 + TPS80031_PUPD_NORMAL, 505 + TPS80031_PUPD_PULLDOWN, 506 + TPS80031_PUPD_PULLUP, 507 + }; 508 + 509 + struct tps80031 { 510 + struct device *dev; 511 + unsigned long chip_info; 512 + int es_version; 513 + struct i2c_client *clients[TPS80031_NUM_SLAVES]; 514 + struct regmap *regmap[TPS80031_NUM_SLAVES]; 515 + struct regmap_irq_chip_data *irq_data; 516 + }; 517 + 518 + struct tps80031_pupd_init_data { 519 + int input_pin; 520 + int setting; 521 + }; 522 + 523 + /* 524 + * struct tps80031_regulator_platform_data - tps80031 regulator platform data. 525 + * 526 + * @reg_init_data: The regulator init data. 527 + * @ext_ctrl_flag: External control flag for sleep/power request control. 528 + * @config_flags: Configuration flag to configure the rails. 529 + * It should be ORed of config enums. 530 + */ 531 + 532 + struct tps80031_regulator_platform_data { 533 + struct regulator_init_data *reg_init_data; 534 + unsigned int ext_ctrl_flag; 535 + unsigned int config_flags; 536 + }; 537 + 538 + struct tps80031_platform_data { 539 + int irq_base; 540 + bool use_power_off; 541 + struct tps80031_pupd_init_data *pupd_init_data; 542 + int pupd_init_data_size; 543 + struct tps80031_regulator_platform_data 544 + *regulator_pdata[TPS80031_REGULATOR_MAX]; 545 + }; 546 + 547 + static inline int tps80031_write(struct device *dev, int sid, 548 + int reg, uint8_t val) 549 + { 550 + struct tps80031 *tps80031 = dev_get_drvdata(dev); 551 + 552 + return regmap_write(tps80031->regmap[sid], reg, val); 553 + } 554 + 555 + static inline int tps80031_writes(struct device *dev, int sid, int reg, 556 + int len, uint8_t *val) 557 + { 558 + struct tps80031 *tps80031 = dev_get_drvdata(dev); 559 + 560 + return regmap_bulk_write(tps80031->regmap[sid], reg, val, len); 561 + } 562 + 563 + static inline int tps80031_read(struct device *dev, int sid, 564 + int reg, uint8_t *val) 565 + { 566 + struct tps80031 *tps80031 = dev_get_drvdata(dev); 567 + unsigned int ival; 568 + int ret; 569 + 570 + ret = regmap_read(tps80031->regmap[sid], reg, &ival); 571 + if (ret < 0) { 572 + dev_err(dev, "failed reading from reg 0x%02x\n", reg); 573 + return ret; 574 + } 575 + 576 + *val = ival; 577 + return ret; 578 + } 579 + 580 + static inline int tps80031_reads(struct device *dev, int sid, 581 + int reg, int len, uint8_t *val) 582 + { 583 + struct tps80031 *tps80031 = dev_get_drvdata(dev); 584 + 585 + return regmap_bulk_read(tps80031->regmap[sid], reg, val, len); 586 + } 587 + 588 + static inline int tps80031_set_bits(struct device *dev, int sid, 589 + int reg, uint8_t bit_mask) 590 + { 591 + struct tps80031 *tps80031 = dev_get_drvdata(dev); 592 + 593 + return regmap_update_bits(tps80031->regmap[sid], reg, 594 + bit_mask, bit_mask); 595 + } 596 + 597 + static inline int tps80031_clr_bits(struct device *dev, int sid, 598 + int reg, uint8_t bit_mask) 599 + { 600 + struct tps80031 *tps80031 = dev_get_drvdata(dev); 601 + 602 + return regmap_update_bits(tps80031->regmap[sid], reg, bit_mask, 0); 603 + } 604 + 605 + static inline int tps80031_update(struct device *dev, int sid, 606 + int reg, uint8_t val, uint8_t mask) 607 + { 608 + struct tps80031 *tps80031 = dev_get_drvdata(dev); 609 + 610 + return regmap_update_bits(tps80031->regmap[sid], reg, mask, val); 611 + } 612 + 613 + static inline unsigned long tps80031_get_chip_info(struct device *dev) 614 + { 615 + struct tps80031 *tps80031 = dev_get_drvdata(dev); 616 + 617 + return tps80031->chip_info; 618 + } 619 + 620 + static inline int tps80031_get_pmu_version(struct device *dev) 621 + { 622 + struct tps80031 *tps80031 = dev_get_drvdata(dev); 623 + 624 + return tps80031->es_version; 625 + } 626 + 627 + static inline int tps80031_irq_get_virq(struct device *dev, int irq) 628 + { 629 + struct tps80031 *tps80031 = dev_get_drvdata(dev); 630 + 631 + return regmap_irq_get_virq(tps80031->irq_data, irq); 632 + } 633 + 634 + extern int tps80031_ext_power_req_config(struct device *dev, 635 + unsigned long ext_ctrl_flag, int preq_bit, 636 + int state_reg_add, int trans_reg_add); 637 + #endif /*__LINUX_MFD_TPS80031_H */
+5 -5
include/linux/mfd/twl6040.h
··· 207 207 }; 208 208 209 209 struct regmap; 210 + struct regmap_irq_chips_data; 210 211 211 212 struct twl6040 { 212 213 struct device *dev; 213 214 struct regmap *regmap; 215 + struct regmap_irq_chip_data *irq_data; 214 216 struct regulator_bulk_data supplies[2]; /* supplies for vio, v2v1 */ 215 217 struct mutex mutex; 216 218 struct mutex irq_mutex; ··· 230 228 unsigned int mclk; 231 229 232 230 unsigned int irq; 233 - unsigned int irq_base; 234 - u8 irq_masks_cur; 235 - u8 irq_masks_cache; 231 + unsigned int irq_ready; 232 + unsigned int irq_th; 236 233 }; 237 234 238 235 int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg); ··· 246 245 unsigned int freq_in, unsigned int freq_out); 247 246 int twl6040_get_pll(struct twl6040 *twl6040); 248 247 unsigned int twl6040_get_sysclk(struct twl6040 *twl6040); 249 - int twl6040_irq_init(struct twl6040 *twl6040); 250 - void twl6040_irq_exit(struct twl6040 *twl6040); 248 + 251 249 /* Get the combined status of the vibra control register */ 252 250 int twl6040_get_vibralr_status(struct twl6040 *twl6040); 253 251
+110
include/linux/mfd/viperboard.h
··· 1 + /* 2 + * include/linux/mfd/viperboard.h 3 + * 4 + * Nano River Technologies viperboard definitions 5 + * 6 + * (C) 2012 by Lemonage GmbH 7 + * Author: Lars Poeschel <poeschel@lemonage.de> 8 + * All rights reserved. 9 + * 10 + * This program is free software; you can redistribute it and/or modify it 11 + * under the terms of the GNU General Public License as published by the 12 + * Free Software Foundation; either version 2 of the License, or (at your 13 + * option) any later version. 14 + * 15 + */ 16 + 17 + #ifndef __MFD_VIPERBOARD_H__ 18 + #define __MFD_VIPERBOARD_H__ 19 + 20 + #include <linux/types.h> 21 + #include <linux/usb.h> 22 + 23 + #define VPRBRD_EP_OUT 0x02 24 + #define VPRBRD_EP_IN 0x86 25 + 26 + #define VPRBRD_I2C_MSG_LEN 512 /* max length of a msg on USB level */ 27 + 28 + #define VPRBRD_I2C_FREQ_6MHZ 1 /* 6 MBit/s */ 29 + #define VPRBRD_I2C_FREQ_3MHZ 2 /* 3 MBit/s */ 30 + #define VPRBRD_I2C_FREQ_1MHZ 3 /* 1 MBit/s */ 31 + #define VPRBRD_I2C_FREQ_FAST 4 /* 400 kbit/s */ 32 + #define VPRBRD_I2C_FREQ_400KHZ VPRBRD_I2C_FREQ_FAST 33 + #define VPRBRD_I2C_FREQ_200KHZ 5 /* 200 kbit/s */ 34 + #define VPRBRD_I2C_FREQ_STD 6 /* 100 kbit/s */ 35 + #define VPRBRD_I2C_FREQ_100KHZ VPRBRD_I2C_FREQ_STD 36 + #define VPRBRD_I2C_FREQ_10KHZ 7 /* 10 kbit/s */ 37 + 38 + #define VPRBRD_I2C_CMD_WRITE 0x00 39 + #define VPRBRD_I2C_CMD_READ 0x01 40 + #define VPRBRD_I2C_CMD_ADDR 0x02 41 + 42 + #define VPRBRD_USB_TYPE_OUT 0x40 43 + #define VPRBRD_USB_TYPE_IN 0xc0 44 + #define VPRBRD_USB_TIMEOUT_MS 100 45 + #define VPRBRD_USB_REQUEST_I2C_FREQ 0xe6 46 + #define VPRBRD_USB_REQUEST_I2C 0xe9 47 + #define VPRBRD_USB_REQUEST_MAJOR 0xea 48 + #define VPRBRD_USB_REQUEST_MINOR 0xeb 49 + #define VPRBRD_USB_REQUEST_ADC 0xec 50 + #define VPRBRD_USB_REQUEST_GPIOA 0xed 51 + #define VPRBRD_USB_REQUEST_GPIOB 0xdd 52 + 53 + struct vprbrd_i2c_write_hdr { 54 + u8 cmd; 55 + u16 addr; 56 + u8 len1; 57 + u8 len2; 58 + u8 last; 59 + u8 chan; 60 + u16 spi; 61 + } __packed; 62 + 63 + struct vprbrd_i2c_read_hdr { 64 + u8 cmd; 65 + u16 addr; 66 + u8 len0; 67 + u8 len1; 68 + u8 len2; 69 + u8 len3; 70 + u8 len4; 71 + u8 len5; 72 + u16 tf1; /* transfer 1 length */ 73 + u16 tf2; /* transfer 2 length */ 74 + } __packed; 75 + 76 + struct vprbrd_i2c_status { 77 + u8 unknown[11]; 78 + u8 status; 79 + } __packed; 80 + 81 + struct vprbrd_i2c_write_msg { 82 + struct vprbrd_i2c_write_hdr header; 83 + u8 data[VPRBRD_I2C_MSG_LEN 84 + - sizeof(struct vprbrd_i2c_write_hdr)]; 85 + } __packed; 86 + 87 + struct vprbrd_i2c_read_msg { 88 + struct vprbrd_i2c_read_hdr header; 89 + u8 data[VPRBRD_I2C_MSG_LEN 90 + - sizeof(struct vprbrd_i2c_read_hdr)]; 91 + } __packed; 92 + 93 + struct vprbrd_i2c_addr_msg { 94 + u8 cmd; 95 + u8 addr; 96 + u8 unknown1; 97 + u16 len; 98 + u8 unknown2; 99 + u8 unknown3; 100 + } __packed; 101 + 102 + /* Structure to hold all device specific stuff */ 103 + struct vprbrd { 104 + struct usb_device *usb_dev; /* the usb device for this device */ 105 + struct mutex lock; 106 + u8 buf[sizeof(struct vprbrd_i2c_write_msg)]; 107 + struct platform_device pdev; 108 + }; 109 + 110 + #endif /* __MFD_VIPERBOARD_H__ */
+14
include/linux/platform_data/ti_am335x_adc.h
··· 1 + #ifndef __LINUX_TI_AM335X_ADC_H 2 + #define __LINUX_TI_AM335X_ADC_H 3 + 4 + /** 5 + * struct adc_data ADC Input information 6 + * @adc_channels: Number of analog inputs 7 + * available for ADC. 8 + */ 9 + 10 + struct adc_data { 11 + unsigned int adc_channels; 12 + }; 13 + 14 + #endif