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

Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6: (59 commits)
rtc: max8925: Add function to work as wakeup source
mfd: Add pm ops to max8925
mfd: Convert aat2870 to dev_pm_ops
mfd: Still check other interrupts if we get a wm831x touchscreen IRQ
mfd: Introduce missing kfree in 88pm860x probe routine
mfd: Add S5M series configuration
mfd: Add s5m series irq driver
mfd: Add S5M core driver
mfd: Improve mc13xxx dt binding document
mfd: Fix stmpe section mismatch
mfd: Fix stmpe build warning
mfd: Fix STMPE I2c build failure
mfd: Constify aat2870-core i2c_device_id table
gpio: Add support for stmpe variant 801
mfd: Add support for stmpe variant 801
mfd: Add support for stmpe variant 610
mfd: Add support for STMPE SPI interface
mfd: Separate out STMPE controller and interface specific code
misc: Remove max8997-muic sysfs attributes
mfd: Remove unused wm831x_irq_data_to_mask_reg()
...

Fix up trivial conflict in drivers/leds/Kconfig due to addition of
LEDS_MAX8997 and LEDS_TCA6507 next to each other.

+3639 -550
+78
Documentation/devicetree/bindings/mfd/mc13xxx.txt
··· 1 + * Freescale MC13783/MC13892 Power Management Integrated Circuit (PMIC) 2 + 3 + Required properties: 4 + - compatible : Should be "fsl,mc13783" or "fsl,mc13892" 5 + 6 + Optional properties: 7 + - fsl,mc13xxx-uses-adc : Indicate the ADC is being used 8 + - fsl,mc13xxx-uses-codec : Indicate the Audio Codec is being used 9 + - fsl,mc13xxx-uses-rtc : Indicate the RTC is being used 10 + - fsl,mc13xxx-uses-touch : Indicate the touchscreen controller is being used 11 + 12 + Sub-nodes: 13 + - regulators : Contain the regulator nodes. The MC13892 regulators are 14 + bound using their names as listed below with their registers and bits 15 + for enabling. 16 + 17 + vcoincell : regulator VCOINCELL (register 13, bit 23) 18 + sw1 : regulator SW1 (register 24, bit 0) 19 + sw2 : regulator SW2 (register 25, bit 0) 20 + sw3 : regulator SW3 (register 26, bit 0) 21 + sw4 : regulator SW4 (register 27, bit 0) 22 + swbst : regulator SWBST (register 29, bit 20) 23 + vgen1 : regulator VGEN1 (register 32, bit 0) 24 + viohi : regulator VIOHI (register 32, bit 3) 25 + vdig : regulator VDIG (register 32, bit 9) 26 + vgen2 : regulator VGEN2 (register 32, bit 12) 27 + vpll : regulator VPLL (register 32, bit 15) 28 + vusb2 : regulator VUSB2 (register 32, bit 18) 29 + vgen3 : regulator VGEN3 (register 33, bit 0) 30 + vcam : regulator VCAM (register 33, bit 6) 31 + vvideo : regulator VVIDEO (register 33, bit 12) 32 + vaudio : regulator VAUDIO (register 33, bit 15) 33 + vsd : regulator VSD (register 33, bit 18) 34 + gpo1 : regulator GPO1 (register 34, bit 6) 35 + gpo2 : regulator GPO2 (register 34, bit 8) 36 + gpo3 : regulator GPO3 (register 34, bit 10) 37 + gpo4 : regulator GPO4 (register 34, bit 12) 38 + pwgt1spi : regulator PWGT1SPI (register 34, bit 15) 39 + pwgt2spi : regulator PWGT2SPI (register 34, bit 16) 40 + vusb : regulator VUSB (register 50, bit 3) 41 + 42 + The bindings details of individual regulator device can be found in: 43 + Documentation/devicetree/bindings/regulator/regulator.txt 44 + 45 + Examples: 46 + 47 + ecspi@70010000 { /* ECSPI1 */ 48 + fsl,spi-num-chipselects = <2>; 49 + cs-gpios = <&gpio3 24 0>, /* GPIO4_24 */ 50 + <&gpio3 25 0>; /* GPIO4_25 */ 51 + status = "okay"; 52 + 53 + pmic: mc13892@0 { 54 + #address-cells = <1>; 55 + #size-cells = <0>; 56 + compatible = "fsl,mc13892"; 57 + spi-max-frequency = <6000000>; 58 + reg = <0>; 59 + interrupt-parent = <&gpio0>; 60 + interrupts = <8>; 61 + 62 + regulators { 63 + sw1_reg: mc13892__sw1 { 64 + regulator-min-microvolt = <600000>; 65 + regulator-max-microvolt = <1375000>; 66 + regulator-boot-on; 67 + regulator-always-on; 68 + }; 69 + 70 + sw2_reg: mc13892__sw2 { 71 + regulator-min-microvolt = <900000>; 72 + regulator-max-microvolt = <1850000>; 73 + regulator-boot-on; 74 + regulator-always-on; 75 + }; 76 + }; 77 + }; 78 + };
+47
Documentation/devicetree/bindings/mfd/twl-familly.txt
··· 1 + Texas Instruments TWL family 2 + 3 + The TWLs are Integrated Power Management Chips. 4 + Some version might contain much more analog function like 5 + USB transceiver or Audio amplifier. 6 + These chips are connected to an i2c bus. 7 + 8 + 9 + Required properties: 10 + - compatible : Must be "ti,twl4030"; 11 + For Integrated power-management/audio CODEC device used in OMAP3 12 + based boards 13 + - compatible : Must be "ti,twl6030"; 14 + For Integrated power-management used in OMAP4 based boards 15 + - interrupts : This i2c device has an IRQ line connected to the main SoC 16 + - interrupt-controller : Since the twl support several interrupts internally, 17 + it is considered as an interrupt controller cascaded to the SoC one. 18 + - #interrupt-cells = <1>; 19 + - interrupt-parent : The parent interrupt controller. 20 + 21 + Optional node: 22 + - Child nodes contain in the twl. The twl family is made of several variants 23 + that support a different number of features. 24 + The children nodes will thus depend of the capability of the variant. 25 + 26 + 27 + Example: 28 + /* 29 + * Integrated Power Management Chip 30 + * http://www.ti.com/lit/ds/symlink/twl6030.pdf 31 + */ 32 + twl@48 { 33 + compatible = "ti,twl6030"; 34 + reg = <0x48>; 35 + interrupts = <39>; /* IRQ_SYS_1N cascaded to gic */ 36 + interrupt-controller; 37 + #interrupt-cells = <1>; 38 + interrupt-parent = <&gic>; 39 + #address-cells = <1>; 40 + #size-cells = <0>; 41 + 42 + twl_rtc { 43 + compatible = "ti,twl_rtc"; 44 + interrupts = <11>; 45 + reg = <0>; 46 + }; 47 + };
+12
arch/arm/mach-sa1100/assabet.c
··· 202 202 static struct mcp_plat_data assabet_mcp_data = { 203 203 .mccr0 = MCCR0_ADM, 204 204 .sclk_rate = 11981000, 205 + .codec = "ucb1x00", 205 206 }; 206 207 207 208 static void __init assabet_init(void) ··· 253 252 sa11x0_register_mtd(&assabet_flash_data, assabet_flash_resources, 254 253 ARRAY_SIZE(assabet_flash_resources)); 255 254 sa11x0_register_irda(&assabet_irda_data); 255 + 256 + /* 257 + * Setup the PPC unit correctly. 258 + */ 259 + PPDR &= ~PPC_RXD4; 260 + PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM; 261 + PSDR |= PPC_RXD4; 262 + PSDR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); 263 + PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); 264 + 265 + ASSABET_BCR_set(ASSABET_BCR_CODEC_RST); 256 266 sa11x0_register_mcp(&assabet_mcp_data); 257 267 } 258 268
+11
arch/arm/mach-sa1100/cerf.c
··· 124 124 static struct mcp_plat_data cerf_mcp_data = { 125 125 .mccr0 = MCCR0_ADM, 126 126 .sclk_rate = 11981000, 127 + .codec = "ucb1x00", 127 128 }; 128 129 129 130 static void __init cerf_init(void) 130 131 { 131 132 platform_add_devices(cerf_devices, ARRAY_SIZE(cerf_devices)); 132 133 sa11x0_register_mtd(&cerf_flash_data, &cerf_flash_resource, 1); 134 + 135 + /* 136 + * Setup the PPC unit correctly. 137 + */ 138 + PPDR &= ~PPC_RXD4; 139 + PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM; 140 + PSDR |= PPC_RXD4; 141 + PSDR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); 142 + PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); 143 + 133 144 sa11x0_register_mcp(&cerf_mcp_data); 134 145 } 135 146
+17 -1
arch/arm/mach-sa1100/collie.c
··· 27 27 #include <linux/timer.h> 28 28 #include <linux/gpio.h> 29 29 #include <linux/pda_power.h> 30 + #include <linux/mfd/ucb1x00.h> 30 31 31 32 #include <mach/hardware.h> 32 33 #include <asm/mach-types.h> ··· 86 85 .num_devs = 1, 87 86 }; 88 87 88 + static struct ucb1x00_plat_data collie_ucb1x00_data = { 89 + .gpio_base = COLLIE_TC35143_GPIO_BASE, 90 + }; 91 + 89 92 static struct mcp_plat_data collie_mcp_data = { 90 93 .mccr0 = MCCR0_ADM | MCCR0_ExtClk, 91 94 .sclk_rate = 9216000, 92 - .gpio_base = COLLIE_TC35143_GPIO_BASE, 95 + .codec = "ucb1x00", 96 + .codec_pdata = &collie_ucb1x00_data, 93 97 }; 94 98 95 99 /* ··· 357 351 358 352 sa11x0_register_mtd(&collie_flash_data, collie_flash_resources, 359 353 ARRAY_SIZE(collie_flash_resources)); 354 + 355 + /* 356 + * Setup the PPC unit correctly. 357 + */ 358 + PPDR &= ~PPC_RXD4; 359 + PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM; 360 + PSDR |= PPC_RXD4; 361 + PSDR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); 362 + PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); 363 + 360 364 sa11x0_register_mcp(&collie_mcp_data); 361 365 362 366 sharpsl_save_param();
+6 -1
arch/arm/mach-sa1100/generic.c
··· 217 217 static struct resource sa11x0mcp_resources[] = { 218 218 [0] = { 219 219 .start = __PREG(Ser4MCCR0), 220 - .end = __PREG(Ser4MCCR0) + 0xffff, 220 + .end = __PREG(Ser4MCCR0) + 0x1C - 1, 221 221 .flags = IORESOURCE_MEM, 222 222 }, 223 223 [1] = { 224 + .start = __PREG(Ser4MCCR1), 225 + .end = __PREG(Ser4MCCR1) + 0x4 - 1, 226 + .flags = IORESOURCE_MEM, 227 + }, 228 + [2] = { 224 229 .start = IRQ_Ser4MCP, 225 230 .end = IRQ_Ser4MCP, 226 231 .flags = IORESOURCE_IRQ,
+2
arch/arm/mach-sa1100/include/mach/mcp.h
··· 17 17 u32 mccr1; 18 18 unsigned int sclk_rate; 19 19 int gpio_base; 20 + const char *codec; 21 + void *codec_pdata; 20 22 }; 21 23 22 24 #endif
+10
arch/arm/mach-sa1100/lart.c
··· 24 24 static struct mcp_plat_data lart_mcp_data = { 25 25 .mccr0 = MCCR0_ADM, 26 26 .sclk_rate = 11981000, 27 + .codec = "ucb1x00", 27 28 }; 28 29 29 30 static void __init lart_init(void) 30 31 { 32 + /* 33 + * Setup the PPC unit correctly. 34 + */ 35 + PPDR &= ~PPC_RXD4; 36 + PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM; 37 + PSDR |= PPC_RXD4; 38 + PSDR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); 39 + PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); 40 + 31 41 sa11x0_register_mcp(&lart_mcp_data); 32 42 } 33 43
+11
arch/arm/mach-sa1100/shannon.c
··· 55 55 static struct mcp_plat_data shannon_mcp_data = { 56 56 .mccr0 = MCCR0_ADM, 57 57 .sclk_rate = 11981000, 58 + .codec = "ucb1x00", 58 59 }; 59 60 60 61 static void __init shannon_init(void) 61 62 { 62 63 sa11x0_register_mtd(&shannon_flash_data, &shannon_flash_resource, 1); 64 + 65 + /* 66 + * Setup the PPC unit correctly. 67 + */ 68 + PPDR &= ~PPC_RXD4; 69 + PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM; 70 + PSDR |= PPC_RXD4; 71 + PSDR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); 72 + PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); 73 + 63 74 sa11x0_register_mcp(&shannon_mcp_data); 64 75 } 65 76
+17 -1
arch/arm/mach-sa1100/simpad.c
··· 14 14 #include <linux/mtd/partitions.h> 15 15 #include <linux/io.h> 16 16 #include <linux/gpio.h> 17 + #include <linux/mfd/ucb1x00.h> 17 18 18 19 #include <asm/irq.h> 19 20 #include <mach/hardware.h> ··· 188 187 } 189 188 }; 190 189 190 + static struct ucb1x00_plat_data simpad_ucb1x00_data = { 191 + .gpio_base = SIMPAD_UCB1X00_GPIO_BASE, 192 + }; 193 + 191 194 static struct mcp_plat_data simpad_mcp_data = { 192 195 .mccr0 = MCCR0_ADM, 193 196 .sclk_rate = 11981000, 194 - .gpio_base = SIMPAD_UCB1X00_GPIO_BASE, 197 + .codec = "ucb1300", 198 + .codec_pdata = &simpad_ucb1x00_data, 195 199 }; 196 200 197 201 ··· 384 378 385 379 sa11x0_register_mtd(&simpad_flash_data, simpad_flash_resources, 386 380 ARRAY_SIZE(simpad_flash_resources)); 381 + 382 + /* 383 + * Setup the PPC unit correctly. 384 + */ 385 + PPDR &= ~PPC_RXD4; 386 + PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM; 387 + PSDR |= PPC_RXD4; 388 + PSDR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); 389 + PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); 390 + 387 391 sa11x0_register_mcp(&simpad_mcp_data); 388 392 389 393 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
+2 -2
arch/arm/mach-ux500/board-mop500.c
··· 19 19 #include <linux/amba/pl022.h> 20 20 #include <linux/amba/serial.h> 21 21 #include <linux/spi/spi.h> 22 - #include <linux/mfd/ab8500.h> 22 + #include <linux/mfd/abx500/ab8500.h> 23 23 #include <linux/regulator/ab8500.h> 24 24 #include <linux/mfd/tc3589x.h> 25 25 #include <linux/mfd/tps6105x.h> 26 - #include <linux/mfd/ab8500/gpio.h> 26 + #include <linux/mfd/abx500/ab8500-gpio.h> 27 27 #include <linux/leds-lp5521.h> 28 28 #include <linux/input.h> 29 29 #include <linux/smsc911x.h>
+1 -1
arch/arm/mach-ux500/board-u5500.c
··· 10 10 #include <linux/amba/bus.h> 11 11 #include <linux/irq.h> 12 12 #include <linux/i2c.h> 13 - #include <linux/mfd/ab5500/ab5500.h> 13 + #include <linux/mfd/abx500/ab5500.h> 14 14 15 15 #include <asm/hardware/gic.h> 16 16 #include <asm/mach/arch.h>
+1 -1
arch/arm/mach-ux500/include/mach/irqs-board-mop500.h
··· 9 9 #define __MACH_IRQS_BOARD_MOP500_H 10 10 11 11 /* Number of AB8500 irqs is taken from header file */ 12 - #include <linux/mfd/ab8500.h> 12 + #include <linux/mfd/abx500/ab8500.h> 13 13 14 14 #define MOP500_AB8500_IRQ_BASE IRQ_BOARD_START 15 15 #define MOP500_AB8500_IRQ_END (MOP500_AB8500_IRQ_BASE \
+22 -3
drivers/gpio/gpio-stmpe.c
··· 65 65 u8 reg = stmpe->regs[which] - (offset / 8); 66 66 u8 mask = 1 << (offset % 8); 67 67 68 - stmpe_reg_write(stmpe, reg, mask); 68 + /* 69 + * Some variants have single register for gpio set/clear functionality. 70 + * For them we need to write 0 to clear and 1 to set. 71 + */ 72 + if (stmpe->regs[STMPE_IDX_GPSR_LSB] == stmpe->regs[STMPE_IDX_GPCR_LSB]) 73 + stmpe_set_bits(stmpe, reg, mask, val ? mask : 0); 74 + else 75 + stmpe_reg_write(stmpe, reg, mask); 69 76 } 70 77 71 78 static int stmpe_gpio_direction_output(struct gpio_chip *chip, ··· 139 132 if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_LEVEL_HIGH) 140 133 return -EINVAL; 141 134 135 + /* STMPE801 doesn't have RE and FE registers */ 136 + if (stmpe_gpio->stmpe->partnum == STMPE801) 137 + return 0; 138 + 142 139 if (type == IRQ_TYPE_EDGE_RISING) 143 140 stmpe_gpio->regs[REG_RE][regoffset] |= mask; 144 141 else ··· 176 165 int i, j; 177 166 178 167 for (i = 0; i < CACHE_NR_REGS; i++) { 168 + /* STMPE801 doesn't have RE and FE registers */ 169 + if ((stmpe->partnum == STMPE801) && 170 + (i != REG_IE)) 171 + continue; 172 + 179 173 for (j = 0; j < num_banks; j++) { 180 174 u8 old = stmpe_gpio->oldregs[i][j]; 181 175 u8 new = stmpe_gpio->regs[i][j]; ··· 257 241 } 258 242 259 243 stmpe_reg_write(stmpe, statmsbreg + i, status[i]); 260 - stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_GPEDR_MSB] + i, 261 - status[i]); 244 + 245 + /* Edge detect register is not present on 801 */ 246 + if (stmpe->partnum != STMPE801) 247 + stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_GPEDR_MSB] 248 + + i, status[i]); 262 249 } 263 250 264 251 return IRQ_HANDLED;
+1 -1
drivers/input/misc/ab8500-ponkey.c
··· 12 12 #include <linux/platform_device.h> 13 13 #include <linux/input.h> 14 14 #include <linux/interrupt.h> 15 - #include <linux/mfd/ab8500.h> 15 + #include <linux/mfd/abx500/ab8500.h> 16 16 #include <linux/slab.h> 17 17 18 18 /**
+7
drivers/leds/Kconfig
··· 396 396 LED driver chips accessed via the I2C bus. 397 397 Driver support brightness control and hardware-assisted blinking. 398 398 399 + config LEDS_MAX8997 400 + tristate "LED support for MAX8997 PMIC" 401 + depends on LEDS_CLASS && MFD_MAX8997 402 + help 403 + This option enables support for on-chip LED drivers on 404 + MAXIM MAX8997 PMIC. 405 + 399 406 config LEDS_TRIGGERS 400 407 bool "LED Trigger support" 401 408 depends on LEDS_CLASS
+1
drivers/leds/Makefile
··· 44 44 obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o 45 45 obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o 46 46 obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o 47 + obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o 47 48 48 49 # LED SPI Drivers 49 50 obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
+372
drivers/leds/leds-max8997.c
··· 1 + /* 2 + * leds-max8997.c - LED class driver for MAX8997 LEDs. 3 + * 4 + * Copyright (C) 2011 Samsung Electronics 5 + * Donggeun Kim <dg77.kim@samsung.com> 6 + * 7 + * This program is free software; you can redistribute it and/or modify 8 + * it under the terms of the GNU General Public License version 2 as 9 + * published by the Free Software Foundation. 10 + * 11 + */ 12 + 13 + #include <linux/module.h> 14 + #include <linux/err.h> 15 + #include <linux/slab.h> 16 + #include <linux/workqueue.h> 17 + #include <linux/leds.h> 18 + #include <linux/mfd/max8997.h> 19 + #include <linux/mfd/max8997-private.h> 20 + #include <linux/platform_device.h> 21 + 22 + #define MAX8997_LED_FLASH_SHIFT 3 23 + #define MAX8997_LED_FLASH_CUR_MASK 0xf8 24 + #define MAX8997_LED_MOVIE_SHIFT 4 25 + #define MAX8997_LED_MOVIE_CUR_MASK 0xf0 26 + 27 + #define MAX8997_LED_FLASH_MAX_BRIGHTNESS 0x1f 28 + #define MAX8997_LED_MOVIE_MAX_BRIGHTNESS 0xf 29 + #define MAX8997_LED_NONE_MAX_BRIGHTNESS 0 30 + 31 + #define MAX8997_LED0_FLASH_MASK 0x1 32 + #define MAX8997_LED0_FLASH_PIN_MASK 0x5 33 + #define MAX8997_LED0_MOVIE_MASK 0x8 34 + #define MAX8997_LED0_MOVIE_PIN_MASK 0x28 35 + 36 + #define MAX8997_LED1_FLASH_MASK 0x2 37 + #define MAX8997_LED1_FLASH_PIN_MASK 0x6 38 + #define MAX8997_LED1_MOVIE_MASK 0x10 39 + #define MAX8997_LED1_MOVIE_PIN_MASK 0x30 40 + 41 + #define MAX8997_LED_BOOST_ENABLE_MASK (1 << 6) 42 + 43 + struct max8997_led { 44 + struct max8997_dev *iodev; 45 + struct led_classdev cdev; 46 + bool enabled; 47 + int id; 48 + enum max8997_led_mode led_mode; 49 + struct mutex mutex; 50 + }; 51 + 52 + static void max8997_led_clear_mode(struct max8997_led *led, 53 + enum max8997_led_mode mode) 54 + { 55 + struct i2c_client *client = led->iodev->i2c; 56 + u8 val = 0, mask = 0; 57 + int ret; 58 + 59 + switch (mode) { 60 + case MAX8997_FLASH_MODE: 61 + mask = led->id ? 62 + MAX8997_LED1_FLASH_MASK : MAX8997_LED0_FLASH_MASK; 63 + break; 64 + case MAX8997_MOVIE_MODE: 65 + mask = led->id ? 66 + MAX8997_LED1_MOVIE_MASK : MAX8997_LED0_MOVIE_MASK; 67 + break; 68 + case MAX8997_FLASH_PIN_CONTROL_MODE: 69 + mask = led->id ? 70 + MAX8997_LED1_FLASH_PIN_MASK : MAX8997_LED0_FLASH_PIN_MASK; 71 + break; 72 + case MAX8997_MOVIE_PIN_CONTROL_MODE: 73 + mask = led->id ? 74 + MAX8997_LED1_MOVIE_PIN_MASK : MAX8997_LED0_MOVIE_PIN_MASK; 75 + break; 76 + default: 77 + break; 78 + } 79 + 80 + if (mask) { 81 + ret = max8997_update_reg(client, 82 + MAX8997_REG_LEN_CNTL, val, mask); 83 + if (ret) 84 + dev_err(led->iodev->dev, 85 + "failed to update register(%d)\n", ret); 86 + } 87 + } 88 + 89 + static void max8997_led_set_mode(struct max8997_led *led, 90 + enum max8997_led_mode mode) 91 + { 92 + int ret; 93 + struct i2c_client *client = led->iodev->i2c; 94 + u8 mask = 0; 95 + 96 + /* First, clear the previous mode */ 97 + max8997_led_clear_mode(led, led->led_mode); 98 + 99 + switch (mode) { 100 + case MAX8997_FLASH_MODE: 101 + mask = led->id ? 102 + MAX8997_LED1_FLASH_MASK : MAX8997_LED0_FLASH_MASK; 103 + led->cdev.max_brightness = MAX8997_LED_FLASH_MAX_BRIGHTNESS; 104 + break; 105 + case MAX8997_MOVIE_MODE: 106 + mask = led->id ? 107 + MAX8997_LED1_MOVIE_MASK : MAX8997_LED0_MOVIE_MASK; 108 + led->cdev.max_brightness = MAX8997_LED_MOVIE_MAX_BRIGHTNESS; 109 + break; 110 + case MAX8997_FLASH_PIN_CONTROL_MODE: 111 + mask = led->id ? 112 + MAX8997_LED1_FLASH_PIN_MASK : MAX8997_LED0_FLASH_PIN_MASK; 113 + led->cdev.max_brightness = MAX8997_LED_FLASH_MAX_BRIGHTNESS; 114 + break; 115 + case MAX8997_MOVIE_PIN_CONTROL_MODE: 116 + mask = led->id ? 117 + MAX8997_LED1_MOVIE_PIN_MASK : MAX8997_LED0_MOVIE_PIN_MASK; 118 + led->cdev.max_brightness = MAX8997_LED_MOVIE_MAX_BRIGHTNESS; 119 + break; 120 + default: 121 + led->cdev.max_brightness = MAX8997_LED_NONE_MAX_BRIGHTNESS; 122 + break; 123 + } 124 + 125 + if (mask) { 126 + ret = max8997_update_reg(client, 127 + MAX8997_REG_LEN_CNTL, mask, mask); 128 + if (ret) 129 + dev_err(led->iodev->dev, 130 + "failed to update register(%d)\n", ret); 131 + } 132 + 133 + led->led_mode = mode; 134 + } 135 + 136 + static void max8997_led_enable(struct max8997_led *led, bool enable) 137 + { 138 + int ret; 139 + struct i2c_client *client = led->iodev->i2c; 140 + u8 val = 0, mask = MAX8997_LED_BOOST_ENABLE_MASK; 141 + 142 + if (led->enabled == enable) 143 + return; 144 + 145 + val = enable ? MAX8997_LED_BOOST_ENABLE_MASK : 0; 146 + 147 + ret = max8997_update_reg(client, MAX8997_REG_BOOST_CNTL, val, mask); 148 + if (ret) 149 + dev_err(led->iodev->dev, 150 + "failed to update register(%d)\n", ret); 151 + 152 + led->enabled = enable; 153 + } 154 + 155 + static void max8997_led_set_current(struct max8997_led *led, 156 + enum led_brightness value) 157 + { 158 + int ret; 159 + struct i2c_client *client = led->iodev->i2c; 160 + u8 val = 0, mask = 0, reg = 0; 161 + 162 + switch (led->led_mode) { 163 + case MAX8997_FLASH_MODE: 164 + case MAX8997_FLASH_PIN_CONTROL_MODE: 165 + val = value << MAX8997_LED_FLASH_SHIFT; 166 + mask = MAX8997_LED_FLASH_CUR_MASK; 167 + reg = led->id ? MAX8997_REG_FLASH2_CUR : MAX8997_REG_FLASH1_CUR; 168 + break; 169 + case MAX8997_MOVIE_MODE: 170 + case MAX8997_MOVIE_PIN_CONTROL_MODE: 171 + val = value << MAX8997_LED_MOVIE_SHIFT; 172 + mask = MAX8997_LED_MOVIE_CUR_MASK; 173 + reg = MAX8997_REG_MOVIE_CUR; 174 + break; 175 + default: 176 + break; 177 + } 178 + 179 + if (mask) { 180 + ret = max8997_update_reg(client, reg, val, mask); 181 + if (ret) 182 + dev_err(led->iodev->dev, 183 + "failed to update register(%d)\n", ret); 184 + } 185 + } 186 + 187 + static void max8997_led_brightness_set(struct led_classdev *led_cdev, 188 + enum led_brightness value) 189 + { 190 + struct max8997_led *led = 191 + container_of(led_cdev, struct max8997_led, cdev); 192 + 193 + if (value) { 194 + max8997_led_set_current(led, value); 195 + max8997_led_enable(led, true); 196 + } else { 197 + max8997_led_set_current(led, value); 198 + max8997_led_enable(led, false); 199 + } 200 + } 201 + 202 + static ssize_t max8997_led_show_mode(struct device *dev, 203 + struct device_attribute *attr, char *buf) 204 + { 205 + struct led_classdev *led_cdev = dev_get_drvdata(dev); 206 + struct max8997_led *led = 207 + container_of(led_cdev, struct max8997_led, cdev); 208 + ssize_t ret = 0; 209 + 210 + mutex_lock(&led->mutex); 211 + 212 + switch (led->led_mode) { 213 + case MAX8997_FLASH_MODE: 214 + ret += sprintf(buf, "FLASH\n"); 215 + break; 216 + case MAX8997_MOVIE_MODE: 217 + ret += sprintf(buf, "MOVIE\n"); 218 + break; 219 + case MAX8997_FLASH_PIN_CONTROL_MODE: 220 + ret += sprintf(buf, "FLASH_PIN_CONTROL\n"); 221 + break; 222 + case MAX8997_MOVIE_PIN_CONTROL_MODE: 223 + ret += sprintf(buf, "MOVIE_PIN_CONTROL\n"); 224 + break; 225 + default: 226 + ret += sprintf(buf, "NONE\n"); 227 + break; 228 + } 229 + 230 + mutex_unlock(&led->mutex); 231 + 232 + return ret; 233 + } 234 + 235 + static ssize_t max8997_led_store_mode(struct device *dev, 236 + struct device_attribute *attr, 237 + const char *buf, size_t size) 238 + { 239 + struct led_classdev *led_cdev = dev_get_drvdata(dev); 240 + struct max8997_led *led = 241 + container_of(led_cdev, struct max8997_led, cdev); 242 + enum max8997_led_mode mode; 243 + 244 + mutex_lock(&led->mutex); 245 + 246 + if (!strncmp(buf, "FLASH_PIN_CONTROL", 17)) 247 + mode = MAX8997_FLASH_PIN_CONTROL_MODE; 248 + else if (!strncmp(buf, "MOVIE_PIN_CONTROL", 17)) 249 + mode = MAX8997_MOVIE_PIN_CONTROL_MODE; 250 + else if (!strncmp(buf, "FLASH", 5)) 251 + mode = MAX8997_FLASH_MODE; 252 + else if (!strncmp(buf, "MOVIE", 5)) 253 + mode = MAX8997_MOVIE_MODE; 254 + else 255 + mode = MAX8997_NONE; 256 + 257 + max8997_led_set_mode(led, mode); 258 + 259 + mutex_unlock(&led->mutex); 260 + 261 + return size; 262 + } 263 + 264 + static DEVICE_ATTR(mode, 0644, max8997_led_show_mode, max8997_led_store_mode); 265 + 266 + static int __devinit max8997_led_probe(struct platform_device *pdev) 267 + { 268 + struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); 269 + struct max8997_platform_data *pdata = dev_get_platdata(iodev->dev); 270 + struct max8997_led *led; 271 + char name[20]; 272 + int ret = 0; 273 + 274 + if (pdata == NULL) { 275 + dev_err(&pdev->dev, "no platform data\n"); 276 + return -ENODEV; 277 + } 278 + 279 + led = kzalloc(sizeof(*led), GFP_KERNEL); 280 + if (led == NULL) { 281 + ret = -ENOMEM; 282 + goto err_mem; 283 + } 284 + 285 + led->id = pdev->id; 286 + snprintf(name, sizeof(name), "max8997-led%d", pdev->id); 287 + 288 + led->cdev.name = name; 289 + led->cdev.brightness_set = max8997_led_brightness_set; 290 + led->cdev.flags |= LED_CORE_SUSPENDRESUME; 291 + led->cdev.brightness = 0; 292 + led->iodev = iodev; 293 + 294 + /* initialize mode and brightness according to platform_data */ 295 + if (pdata->led_pdata) { 296 + u8 mode = 0, brightness = 0; 297 + 298 + mode = pdata->led_pdata->mode[led->id]; 299 + brightness = pdata->led_pdata->brightness[led->id]; 300 + 301 + max8997_led_set_mode(led, pdata->led_pdata->mode[led->id]); 302 + 303 + if (brightness > led->cdev.max_brightness) 304 + brightness = led->cdev.max_brightness; 305 + max8997_led_set_current(led, brightness); 306 + led->cdev.brightness = brightness; 307 + } else { 308 + max8997_led_set_mode(led, MAX8997_NONE); 309 + max8997_led_set_current(led, 0); 310 + } 311 + 312 + mutex_init(&led->mutex); 313 + 314 + platform_set_drvdata(pdev, led); 315 + 316 + ret = led_classdev_register(&pdev->dev, &led->cdev); 317 + if (ret < 0) 318 + goto err_led; 319 + 320 + ret = device_create_file(led->cdev.dev, &dev_attr_mode); 321 + if (ret != 0) { 322 + dev_err(&pdev->dev, 323 + "failed to create file: %d\n", ret); 324 + goto err_file; 325 + } 326 + 327 + return 0; 328 + 329 + err_file: 330 + led_classdev_unregister(&led->cdev); 331 + err_led: 332 + kfree(led); 333 + err_mem: 334 + return ret; 335 + } 336 + 337 + static int __devexit max8997_led_remove(struct platform_device *pdev) 338 + { 339 + struct max8997_led *led = platform_get_drvdata(pdev); 340 + 341 + device_remove_file(led->cdev.dev, &dev_attr_mode); 342 + led_classdev_unregister(&led->cdev); 343 + kfree(led); 344 + 345 + return 0; 346 + } 347 + 348 + static struct platform_driver max8997_led_driver = { 349 + .driver = { 350 + .name = "max8997-led", 351 + .owner = THIS_MODULE, 352 + }, 353 + .probe = max8997_led_probe, 354 + .remove = __devexit_p(max8997_led_remove), 355 + }; 356 + 357 + static int __init max8997_led_init(void) 358 + { 359 + return platform_driver_register(&max8997_led_driver); 360 + } 361 + module_init(max8997_led_init); 362 + 363 + static void __exit max8997_led_exit(void) 364 + { 365 + platform_driver_unregister(&max8997_led_driver); 366 + } 367 + module_exit(max8997_led_exit); 368 + 369 + MODULE_AUTHOR("Donggeun Kim <dg77.kim@samsung.com>"); 370 + MODULE_DESCRIPTION("MAX8997 LED driver"); 371 + MODULE_LICENSE("GPL"); 372 + MODULE_ALIAS("platform:max8997-led");
+134 -107
drivers/mfd/88pm860x-i2c.c
··· 12 12 #include <linux/module.h> 13 13 #include <linux/platform_device.h> 14 14 #include <linux/i2c.h> 15 + #include <linux/err.h> 16 + #include <linux/regmap.h> 15 17 #include <linux/mfd/88pm860x.h> 16 18 #include <linux/slab.h> 17 - 18 - static inline int pm860x_read_device(struct i2c_client *i2c, 19 - int reg, int bytes, void *dest) 20 - { 21 - unsigned char data; 22 - int ret; 23 - 24 - data = (unsigned char)reg; 25 - ret = i2c_master_send(i2c, &data, 1); 26 - if (ret < 0) 27 - return ret; 28 - 29 - ret = i2c_master_recv(i2c, dest, bytes); 30 - if (ret < 0) 31 - return ret; 32 - return 0; 33 - } 34 - 35 - static inline int pm860x_write_device(struct i2c_client *i2c, 36 - int reg, int bytes, void *src) 37 - { 38 - unsigned char buf[bytes + 1]; 39 - int ret; 40 - 41 - buf[0] = (unsigned char)reg; 42 - memcpy(&buf[1], src, bytes); 43 - 44 - ret = i2c_master_send(i2c, buf, bytes + 1); 45 - if (ret < 0) 46 - return ret; 47 - return 0; 48 - } 49 19 50 20 int pm860x_reg_read(struct i2c_client *i2c, int reg) 51 21 { 52 22 struct pm860x_chip *chip = i2c_get_clientdata(i2c); 53 - unsigned char data; 23 + struct regmap *map = (i2c == chip->client) ? chip->regmap 24 + : chip->regmap_companion; 25 + unsigned int data; 54 26 int ret; 55 27 56 - mutex_lock(&chip->io_lock); 57 - ret = pm860x_read_device(i2c, reg, 1, &data); 58 - mutex_unlock(&chip->io_lock); 59 - 28 + ret = regmap_read(map, reg, &data); 60 29 if (ret < 0) 61 30 return ret; 62 31 else ··· 37 68 unsigned char data) 38 69 { 39 70 struct pm860x_chip *chip = i2c_get_clientdata(i2c); 71 + struct regmap *map = (i2c == chip->client) ? chip->regmap 72 + : chip->regmap_companion; 40 73 int ret; 41 74 42 - mutex_lock(&chip->io_lock); 43 - ret = pm860x_write_device(i2c, reg, 1, &data); 44 - mutex_unlock(&chip->io_lock); 45 - 75 + ret = regmap_write(map, reg, data); 46 76 return ret; 47 77 } 48 78 EXPORT_SYMBOL(pm860x_reg_write); ··· 50 82 int count, unsigned char *buf) 51 83 { 52 84 struct pm860x_chip *chip = i2c_get_clientdata(i2c); 85 + struct regmap *map = (i2c == chip->client) ? chip->regmap 86 + : chip->regmap_companion; 53 87 int ret; 54 88 55 - mutex_lock(&chip->io_lock); 56 - ret = pm860x_read_device(i2c, reg, count, buf); 57 - mutex_unlock(&chip->io_lock); 58 - 89 + ret = regmap_raw_read(map, reg, buf, count); 59 90 return ret; 60 91 } 61 92 EXPORT_SYMBOL(pm860x_bulk_read); ··· 63 96 int count, unsigned char *buf) 64 97 { 65 98 struct pm860x_chip *chip = i2c_get_clientdata(i2c); 99 + struct regmap *map = (i2c == chip->client) ? chip->regmap 100 + : chip->regmap_companion; 66 101 int ret; 67 102 68 - mutex_lock(&chip->io_lock); 69 - ret = pm860x_write_device(i2c, reg, count, buf); 70 - mutex_unlock(&chip->io_lock); 71 - 103 + ret = regmap_raw_write(map, reg, buf, count); 72 104 return ret; 73 105 } 74 106 EXPORT_SYMBOL(pm860x_bulk_write); ··· 76 110 unsigned char mask, unsigned char data) 77 111 { 78 112 struct pm860x_chip *chip = i2c_get_clientdata(i2c); 79 - unsigned char value; 113 + struct regmap *map = (i2c == chip->client) ? chip->regmap 114 + : chip->regmap_companion; 80 115 int ret; 81 116 82 - mutex_lock(&chip->io_lock); 83 - ret = pm860x_read_device(i2c, reg, 1, &value); 84 - if (ret < 0) 85 - goto out; 86 - value &= ~mask; 87 - value |= data; 88 - ret = pm860x_write_device(i2c, reg, 1, &value); 89 - out: 90 - mutex_unlock(&chip->io_lock); 117 + ret = regmap_update_bits(map, reg, mask, data); 91 118 return ret; 92 119 } 93 120 EXPORT_SYMBOL(pm860x_set_bits); 94 121 122 + static int read_device(struct i2c_client *i2c, int reg, 123 + int bytes, void *dest) 124 + { 125 + unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX + 3]; 126 + unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX + 2]; 127 + struct i2c_adapter *adap = i2c->adapter; 128 + struct i2c_msg msg[2] = {{i2c->addr, 0, 1, msgbuf0}, 129 + {i2c->addr, I2C_M_RD, 0, msgbuf1}, 130 + }; 131 + int num = 1, ret = 0; 132 + 133 + if (dest == NULL) 134 + return -EINVAL; 135 + msgbuf0[0] = (unsigned char)reg; /* command */ 136 + msg[1].len = bytes; 137 + 138 + /* if data needs to read back, num should be 2 */ 139 + if (bytes > 0) 140 + num = 2; 141 + ret = adap->algo->master_xfer(adap, msg, num); 142 + memcpy(dest, msgbuf1, bytes); 143 + if (ret < 0) 144 + return ret; 145 + return 0; 146 + } 147 + 148 + static int write_device(struct i2c_client *i2c, int reg, 149 + int bytes, void *src) 150 + { 151 + unsigned char buf[bytes + 1]; 152 + struct i2c_adapter *adap = i2c->adapter; 153 + struct i2c_msg msg; 154 + int ret; 155 + 156 + buf[0] = (unsigned char)reg; 157 + memcpy(&buf[1], src, bytes); 158 + msg.addr = i2c->addr; 159 + msg.flags = 0; 160 + msg.len = bytes + 1; 161 + msg.buf = buf; 162 + 163 + ret = adap->algo->master_xfer(adap, &msg, 1); 164 + if (ret < 0) 165 + return ret; 166 + return 0; 167 + } 168 + 95 169 int pm860x_page_reg_read(struct i2c_client *i2c, int reg) 96 170 { 97 - struct pm860x_chip *chip = i2c_get_clientdata(i2c); 98 171 unsigned char zero = 0; 99 172 unsigned char data; 100 173 int ret; 101 174 102 - mutex_lock(&chip->io_lock); 103 - pm860x_write_device(i2c, 0xFA, 0, &zero); 104 - pm860x_write_device(i2c, 0xFB, 0, &zero); 105 - pm860x_write_device(i2c, 0xFF, 0, &zero); 106 - ret = pm860x_read_device(i2c, reg, 1, &data); 175 + i2c_lock_adapter(i2c->adapter); 176 + read_device(i2c, 0xFA, 0, &zero); 177 + read_device(i2c, 0xFB, 0, &zero); 178 + read_device(i2c, 0xFF, 0, &zero); 179 + ret = read_device(i2c, reg, 1, &data); 107 180 if (ret >= 0) 108 181 ret = (int)data; 109 - pm860x_write_device(i2c, 0xFE, 0, &zero); 110 - pm860x_write_device(i2c, 0xFC, 0, &zero); 111 - mutex_unlock(&chip->io_lock); 182 + read_device(i2c, 0xFE, 0, &zero); 183 + read_device(i2c, 0xFC, 0, &zero); 184 + i2c_unlock_adapter(i2c->adapter); 112 185 return ret; 113 186 } 114 187 EXPORT_SYMBOL(pm860x_page_reg_read); ··· 155 150 int pm860x_page_reg_write(struct i2c_client *i2c, int reg, 156 151 unsigned char data) 157 152 { 158 - struct pm860x_chip *chip = i2c_get_clientdata(i2c); 159 153 unsigned char zero; 160 154 int ret; 161 155 162 - mutex_lock(&chip->io_lock); 163 - pm860x_write_device(i2c, 0xFA, 0, &zero); 164 - pm860x_write_device(i2c, 0xFB, 0, &zero); 165 - pm860x_write_device(i2c, 0xFF, 0, &zero); 166 - ret = pm860x_write_device(i2c, reg, 1, &data); 167 - pm860x_write_device(i2c, 0xFE, 0, &zero); 168 - pm860x_write_device(i2c, 0xFC, 0, &zero); 169 - mutex_unlock(&chip->io_lock); 156 + i2c_lock_adapter(i2c->adapter); 157 + read_device(i2c, 0xFA, 0, &zero); 158 + read_device(i2c, 0xFB, 0, &zero); 159 + read_device(i2c, 0xFF, 0, &zero); 160 + ret = write_device(i2c, reg, 1, &data); 161 + read_device(i2c, 0xFE, 0, &zero); 162 + read_device(i2c, 0xFC, 0, &zero); 163 + i2c_unlock_adapter(i2c->adapter); 170 164 return ret; 171 165 } 172 166 EXPORT_SYMBOL(pm860x_page_reg_write); ··· 173 169 int pm860x_page_bulk_read(struct i2c_client *i2c, int reg, 174 170 int count, unsigned char *buf) 175 171 { 176 - struct pm860x_chip *chip = i2c_get_clientdata(i2c); 177 172 unsigned char zero = 0; 178 173 int ret; 179 174 180 - mutex_lock(&chip->io_lock); 181 - pm860x_write_device(i2c, 0xFA, 0, &zero); 182 - pm860x_write_device(i2c, 0xFB, 0, &zero); 183 - pm860x_write_device(i2c, 0xFF, 0, &zero); 184 - ret = pm860x_read_device(i2c, reg, count, buf); 185 - pm860x_write_device(i2c, 0xFE, 0, &zero); 186 - pm860x_write_device(i2c, 0xFC, 0, &zero); 187 - mutex_unlock(&chip->io_lock); 175 + i2c_lock_adapter(i2c->adapter); 176 + read_device(i2c, 0xfa, 0, &zero); 177 + read_device(i2c, 0xfb, 0, &zero); 178 + read_device(i2c, 0xff, 0, &zero); 179 + ret = read_device(i2c, reg, count, buf); 180 + read_device(i2c, 0xFE, 0, &zero); 181 + read_device(i2c, 0xFC, 0, &zero); 182 + i2c_unlock_adapter(i2c->adapter); 188 183 return ret; 189 184 } 190 185 EXPORT_SYMBOL(pm860x_page_bulk_read); ··· 191 188 int pm860x_page_bulk_write(struct i2c_client *i2c, int reg, 192 189 int count, unsigned char *buf) 193 190 { 194 - struct pm860x_chip *chip = i2c_get_clientdata(i2c); 195 191 unsigned char zero = 0; 196 192 int ret; 197 193 198 - mutex_lock(&chip->io_lock); 199 - pm860x_write_device(i2c, 0xFA, 0, &zero); 200 - pm860x_write_device(i2c, 0xFB, 0, &zero); 201 - pm860x_write_device(i2c, 0xFF, 0, &zero); 202 - ret = pm860x_write_device(i2c, reg, count, buf); 203 - pm860x_write_device(i2c, 0xFE, 0, &zero); 204 - pm860x_write_device(i2c, 0xFC, 0, &zero); 205 - mutex_unlock(&chip->io_lock); 194 + i2c_lock_adapter(i2c->adapter); 195 + read_device(i2c, 0xFA, 0, &zero); 196 + read_device(i2c, 0xFB, 0, &zero); 197 + read_device(i2c, 0xFF, 0, &zero); 198 + ret = write_device(i2c, reg, count, buf); 199 + read_device(i2c, 0xFE, 0, &zero); 200 + read_device(i2c, 0xFC, 0, &zero); 201 + i2c_unlock_adapter(i2c->adapter); 202 + i2c_unlock_adapter(i2c->adapter); 206 203 return ret; 207 204 } 208 205 EXPORT_SYMBOL(pm860x_page_bulk_write); ··· 210 207 int pm860x_page_set_bits(struct i2c_client *i2c, int reg, 211 208 unsigned char mask, unsigned char data) 212 209 { 213 - struct pm860x_chip *chip = i2c_get_clientdata(i2c); 214 210 unsigned char zero; 215 211 unsigned char value; 216 212 int ret; 217 213 218 - mutex_lock(&chip->io_lock); 219 - pm860x_write_device(i2c, 0xFA, 0, &zero); 220 - pm860x_write_device(i2c, 0xFB, 0, &zero); 221 - pm860x_write_device(i2c, 0xFF, 0, &zero); 222 - ret = pm860x_read_device(i2c, reg, 1, &value); 214 + i2c_lock_adapter(i2c->adapter); 215 + read_device(i2c, 0xFA, 0, &zero); 216 + read_device(i2c, 0xFB, 0, &zero); 217 + read_device(i2c, 0xFF, 0, &zero); 218 + ret = read_device(i2c, reg, 1, &value); 223 219 if (ret < 0) 224 220 goto out; 225 221 value &= ~mask; 226 222 value |= data; 227 - ret = pm860x_write_device(i2c, reg, 1, &value); 223 + ret = write_device(i2c, reg, 1, &value); 228 224 out: 229 - pm860x_write_device(i2c, 0xFE, 0, &zero); 230 - pm860x_write_device(i2c, 0xFC, 0, &zero); 231 - mutex_unlock(&chip->io_lock); 225 + read_device(i2c, 0xFE, 0, &zero); 226 + read_device(i2c, 0xFC, 0, &zero); 227 + i2c_unlock_adapter(i2c->adapter); 232 228 return ret; 233 229 } 234 230 EXPORT_SYMBOL(pm860x_page_set_bits); ··· 259 257 return 0; 260 258 } 261 259 260 + static struct regmap_config pm860x_regmap_config = { 261 + .reg_bits = 8, 262 + .val_bits = 8, 263 + }; 264 + 262 265 static int __devinit pm860x_probe(struct i2c_client *client, 263 266 const struct i2c_device_id *id) 264 267 { 265 268 struct pm860x_platform_data *pdata = client->dev.platform_data; 266 269 struct pm860x_chip *chip; 270 + int ret; 267 271 268 272 if (!pdata) { 269 273 pr_info("No platform data in %s!\n", __func__); ··· 281 273 return -ENOMEM; 282 274 283 275 chip->id = verify_addr(client); 276 + chip->regmap = regmap_init_i2c(client, &pm860x_regmap_config); 277 + if (IS_ERR(chip->regmap)) { 278 + ret = PTR_ERR(chip->regmap); 279 + dev_err(&client->dev, "Failed to allocate register map: %d\n", 280 + ret); 281 + kfree(chip); 282 + return ret; 283 + } 284 284 chip->client = client; 285 285 i2c_set_clientdata(client, chip); 286 286 chip->dev = &client->dev; 287 - mutex_init(&chip->io_lock); 288 287 dev_set_drvdata(chip->dev, chip); 289 288 290 289 /* ··· 305 290 chip->companion_addr = pdata->companion_addr; 306 291 chip->companion = i2c_new_dummy(chip->client->adapter, 307 292 chip->companion_addr); 293 + chip->regmap_companion = regmap_init_i2c(chip->companion, 294 + &pm860x_regmap_config); 295 + if (IS_ERR(chip->regmap_companion)) { 296 + ret = PTR_ERR(chip->regmap_companion); 297 + dev_err(&chip->companion->dev, 298 + "Failed to allocate register map: %d\n", ret); 299 + return ret; 300 + } 308 301 i2c_set_clientdata(chip->companion, chip); 309 302 } 310 303 ··· 325 302 struct pm860x_chip *chip = i2c_get_clientdata(client); 326 303 327 304 pm860x_device_exit(chip); 328 - i2c_unregister_device(chip->companion); 305 + if (chip->companion) { 306 + regmap_exit(chip->regmap_companion); 307 + i2c_unregister_device(chip->companion); 308 + } 309 + regmap_exit(chip->regmap); 329 310 kfree(chip); 330 311 return 0; 331 312 }
+32 -3
drivers/mfd/Kconfig
··· 12 12 config MFD_88PM860X 13 13 bool "Support Marvell 88PM8606/88PM8607" 14 14 depends on I2C=y && GENERIC_HARDIRQS 15 + select REGMAP_I2C 15 16 select MFD_CORE 16 17 help 17 18 This supports for Marvell 88PM8606/88PM8607 Power Management IC. ··· 200 199 201 200 config TWL4030_CORE 202 201 bool "Texas Instruments TWL4030/TWL5030/TWL6030/TPS659x0 Support" 203 - depends on I2C=y && GENERIC_HARDIRQS 202 + depends on I2C=y && GENERIC_HARDIRQS && IRQ_DOMAIN 204 203 help 205 204 Say yes here if you have TWL4030 / TWL6030 family chip on your board. 206 205 This core driver provides register access and IRQ handling ··· 258 257 259 258 config MFD_STMPE 260 259 bool "Support STMicroelectronics STMPE" 261 - depends on I2C=y && GENERIC_HARDIRQS 260 + depends on (I2C=y || SPI_MASTER=y) && GENERIC_HARDIRQS 262 261 select MFD_CORE 263 262 help 264 263 Support for the STMPE family of I/O Expanders from ··· 278 277 GPIO: stmpe-gpio 279 278 Keypad: stmpe-keypad 280 279 Touchscreen: stmpe-ts 280 + 281 + menu "STMPE Interface Drivers" 282 + depends on MFD_STMPE 283 + 284 + config STMPE_I2C 285 + bool "STMPE I2C Inteface" 286 + depends on I2C=y 287 + default y 288 + help 289 + This is used to enable I2C interface of STMPE 290 + 291 + config STMPE_SPI 292 + bool "STMPE SPI Inteface" 293 + depends on SPI_MASTER 294 + help 295 + This is used to enable SPI interface of STMPE 296 + endmenu 281 297 282 298 config MFD_TC3589X 283 299 bool "Support Toshiba TC35892 and variants" ··· 329 311 330 312 config MFD_TC6393XB 331 313 bool "Support Toshiba TC6393XB" 332 - depends on GPIOLIB && ARM 314 + depends on GPIOLIB && ARM && HAVE_CLK 333 315 select MFD_CORE 334 316 select MFD_TMIO 335 317 help ··· 416 398 This driver provies common support for accessing the device, 417 399 additional drivers must be enabled in order to use the functionality 418 400 of the device. 401 + 402 + config MFD_S5M_CORE 403 + bool "SAMSUNG S5M Series Support" 404 + depends on I2C=y && GENERIC_HARDIRQS 405 + select MFD_CORE 406 + select REGMAP_I2C 407 + help 408 + Support for the Samsung Electronics S5M MFD series. 409 + This driver provies common support for accessing the device, 410 + additional drivers must be enabled in order to use the functionality 411 + of the device 419 412 420 413 config MFD_WM8400 421 414 tristate "Support Wolfson Microelectronics WM8400"
+3
drivers/mfd/Makefile
··· 16 16 obj-$(CONFIG_MFD_TI_SSP) += ti-ssp.o 17 17 18 18 obj-$(CONFIG_MFD_STMPE) += stmpe.o 19 + obj-$(CONFIG_STMPE_I2C) += stmpe-i2c.o 20 + obj-$(CONFIG_STMPE_SPI) += stmpe-spi.o 19 21 obj-$(CONFIG_MFD_TC3589X) += tc3589x.o 20 22 obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o tmio_core.o 21 23 obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o tmio_core.o ··· 111 109 obj-$(CONFIG_TPS65911_COMPARATOR) += tps65911-comparator.o 112 110 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o 113 111 obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o 112 + obj-$(CONFIG_MFD_S5M_CORE) += s5m-core.o s5m-irq.o
+13 -12
drivers/mfd/aat2870-core.c
··· 407 407 aat2870->init(aat2870); 408 408 409 409 if (aat2870->en_pin >= 0) { 410 - ret = gpio_request(aat2870->en_pin, "aat2870-en"); 410 + ret = gpio_request_one(aat2870->en_pin, GPIOF_OUT_INIT_HIGH, 411 + "aat2870-en"); 411 412 if (ret < 0) { 412 413 dev_err(&client->dev, 413 414 "Failed to request GPIO %d\n", aat2870->en_pin); 414 415 goto out_kfree; 415 416 } 416 - gpio_direction_output(aat2870->en_pin, 1); 417 417 } 418 418 419 419 aat2870_enable(aat2870); ··· 468 468 return 0; 469 469 } 470 470 471 - #ifdef CONFIG_PM 472 - static int aat2870_i2c_suspend(struct i2c_client *client, pm_message_t state) 471 + #ifdef CONFIG_PM_SLEEP 472 + static int aat2870_i2c_suspend(struct device *dev) 473 473 { 474 + struct i2c_client *client = to_i2c_client(dev); 474 475 struct aat2870_data *aat2870 = i2c_get_clientdata(client); 475 476 476 477 aat2870_disable(aat2870); ··· 479 478 return 0; 480 479 } 481 480 482 - static int aat2870_i2c_resume(struct i2c_client *client) 481 + static int aat2870_i2c_resume(struct device *dev) 483 482 { 483 + struct i2c_client *client = to_i2c_client(dev); 484 484 struct aat2870_data *aat2870 = i2c_get_clientdata(client); 485 485 struct aat2870_register *reg = NULL; 486 486 int i; ··· 497 495 498 496 return 0; 499 497 } 500 - #else 501 - #define aat2870_i2c_suspend NULL 502 - #define aat2870_i2c_resume NULL 503 - #endif /* CONFIG_PM */ 498 + #endif /* CONFIG_PM_SLEEP */ 504 499 505 - static struct i2c_device_id aat2870_i2c_id_table[] = { 500 + static SIMPLE_DEV_PM_OPS(aat2870_pm_ops, aat2870_i2c_suspend, 501 + aat2870_i2c_resume); 502 + 503 + static const struct i2c_device_id aat2870_i2c_id_table[] = { 506 504 { "aat2870", 0 }, 507 505 { } 508 506 }; ··· 512 510 .driver = { 513 511 .name = "aat2870", 514 512 .owner = THIS_MODULE, 513 + .pm = &aat2870_pm_ops, 515 514 }, 516 515 .probe = aat2870_i2c_probe, 517 516 .remove = aat2870_i2c_remove, 518 - .suspend = aat2870_i2c_suspend, 519 - .resume = aat2870_i2c_resume, 520 517 .id_table = aat2870_i2c_id_table, 521 518 }; 522 519
+1 -1
drivers/mfd/ab5500-core.c
··· 22 22 #include <linux/irq.h> 23 23 #include <linux/interrupt.h> 24 24 #include <linux/random.h> 25 - #include <linux/mfd/ab5500/ab5500.h> 26 25 #include <linux/mfd/abx500.h> 26 + #include <linux/mfd/abx500/ab5500.h> 27 27 #include <linux/list.h> 28 28 #include <linux/bitops.h> 29 29 #include <linux/spinlock.h>
+1 -1
drivers/mfd/ab5500-debugfs.c
··· 7 7 #include <linux/module.h> 8 8 #include <linux/debugfs.h> 9 9 #include <linux/seq_file.h> 10 - #include <linux/mfd/ab5500/ab5500.h> 11 10 #include <linux/mfd/abx500.h> 11 + #include <linux/mfd/abx500/ab5500.h> 12 12 #include <linux/uaccess.h> 13 13 14 14 #include "ab5500-core.h"
+1 -1
drivers/mfd/ab8500-core.c
··· 17 17 #include <linux/platform_device.h> 18 18 #include <linux/mfd/core.h> 19 19 #include <linux/mfd/abx500.h> 20 - #include <linux/mfd/ab8500.h> 20 + #include <linux/mfd/abx500/ab8500.h> 21 21 #include <linux/regulator/ab8500.h> 22 22 23 23 /*
+1 -1
drivers/mfd/ab8500-debugfs.c
··· 13 13 #include <linux/platform_device.h> 14 14 15 15 #include <linux/mfd/abx500.h> 16 - #include <linux/mfd/ab8500.h> 16 + #include <linux/mfd/abx500/ab8500.h> 17 17 18 18 static u32 debug_bank; 19 19 static u32 debug_address;
+2 -2
drivers/mfd/ab8500-gpadc.c
··· 18 18 #include <linux/err.h> 19 19 #include <linux/slab.h> 20 20 #include <linux/list.h> 21 - #include <linux/mfd/ab8500.h> 22 21 #include <linux/mfd/abx500.h> 23 - #include <linux/mfd/ab8500/gpadc.h> 22 + #include <linux/mfd/abx500/ab8500.h> 23 + #include <linux/mfd/abx500/ab8500-gpadc.h> 24 24 25 25 /* 26 26 * GPADC register offsets
+1 -1
drivers/mfd/ab8500-i2c.c
··· 10 10 #include <linux/init.h> 11 11 #include <linux/module.h> 12 12 #include <linux/platform_device.h> 13 - #include <linux/mfd/ab8500.h> 13 + #include <linux/mfd/abx500/ab8500.h> 14 14 #include <linux/mfd/db8500-prcmu.h> 15 15 16 16 static int ab8500_i2c_write(struct ab8500 *ab8500, u16 addr, u8 data)
+2 -2
drivers/mfd/ab8500-sysctrl.c
··· 7 7 #include <linux/err.h> 8 8 #include <linux/module.h> 9 9 #include <linux/platform_device.h> 10 - #include <linux/mfd/ab8500.h> 11 10 #include <linux/mfd/abx500.h> 12 - #include <linux/mfd/ab8500/sysctrl.h> 11 + #include <linux/mfd/abx500/ab8500.h> 12 + #include <linux/mfd/abx500/ab8500-sysctrl.h> 13 13 14 14 static struct device *sysctrl_dev; 15 15
+4 -4
drivers/mfd/cs5535-mfd.c
··· 172 172 pci_disable_device(pdev); 173 173 } 174 174 175 - static struct pci_device_id cs5535_mfd_pci_tbl[] = { 175 + static DEFINE_PCI_DEVICE_TABLE(cs5535_mfd_pci_tbl) = { 176 176 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) }, 177 177 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) }, 178 178 { 0, } 179 179 }; 180 180 MODULE_DEVICE_TABLE(pci, cs5535_mfd_pci_tbl); 181 181 182 - static struct pci_driver cs5535_mfd_drv = { 182 + static struct pci_driver cs5535_mfd_driver = { 183 183 .name = DRV_NAME, 184 184 .id_table = cs5535_mfd_pci_tbl, 185 185 .probe = cs5535_mfd_probe, ··· 188 188 189 189 static int __init cs5535_mfd_init(void) 190 190 { 191 - return pci_register_driver(&cs5535_mfd_drv); 191 + return pci_register_driver(&cs5535_mfd_driver); 192 192 } 193 193 194 194 static void __exit cs5535_mfd_exit(void) 195 195 { 196 - pci_unregister_driver(&cs5535_mfd_drv); 196 + pci_unregister_driver(&cs5535_mfd_driver); 197 197 } 198 198 199 199 module_init(cs5535_mfd_init);
+1 -2
drivers/mfd/dm355evm_msp.c
··· 308 308 for (i = 0; i < ARRAY_SIZE(config_inputs); i++) { 309 309 int gpio = dm355evm_msp_gpio.base + config_inputs[i].offset; 310 310 311 - gpio_request(gpio, config_inputs[i].label); 312 - gpio_direction_input(gpio); 311 + gpio_request_one(gpio, GPIOF_IN, config_inputs[i].label); 313 312 314 313 /* make it easy for userspace to see these */ 315 314 gpio_export(gpio, false);
+1 -11
drivers/mfd/intel_msic.c
··· 485 485 }, 486 486 }; 487 487 488 - static int __init intel_msic_init(void) 489 - { 490 - return platform_driver_register(&intel_msic_driver); 491 - } 492 - module_init(intel_msic_init); 493 - 494 - static void __exit intel_msic_exit(void) 495 - { 496 - platform_driver_unregister(&intel_msic_driver); 497 - } 498 - module_exit(intel_msic_exit); 488 + module_platform_driver(intel_msic_driver); 499 489 500 490 MODULE_DESCRIPTION("Driver for Intel MSIC"); 501 491 MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
+2 -12
drivers/mfd/jz4740-adc.c
··· 181 181 }, 182 182 }; 183 183 184 - const struct mfd_cell jz4740_adc_cells[] = { 184 + static struct mfd_cell jz4740_adc_cells[] = { 185 185 { 186 186 .id = 0, 187 187 .name = "jz4740-hwmon", ··· 338 338 }, 339 339 }; 340 340 341 - static int __init jz4740_adc_init(void) 342 - { 343 - return platform_driver_register(&jz4740_adc_driver); 344 - } 345 - module_init(jz4740_adc_init); 346 - 347 - static void __exit jz4740_adc_exit(void) 348 - { 349 - platform_driver_unregister(&jz4740_adc_driver); 350 - } 351 - module_exit(jz4740_adc_exit); 341 + module_platform_driver(jz4740_adc_driver); 352 342 353 343 MODULE_DESCRIPTION("JZ4740 SoC ADC driver"); 354 344 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
+1 -1
drivers/mfd/lpc_sch.c
··· 74 74 }, 75 75 }; 76 76 77 - static struct pci_device_id lpc_sch_ids[] = { 77 + static DEFINE_PCI_DEVICE_TABLE(lpc_sch_ids) = { 78 78 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, 79 79 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ITC_LPC) }, 80 80 { 0, }
+27
drivers/mfd/max8925-i2c.c
··· 161 161 chip->adc = i2c_new_dummy(chip->i2c->adapter, ADC_I2C_ADDR); 162 162 i2c_set_clientdata(chip->adc, chip); 163 163 164 + device_init_wakeup(&client->dev, 1); 165 + 164 166 max8925_device_init(chip, pdata); 165 167 166 168 return 0; ··· 179 177 return 0; 180 178 } 181 179 180 + #ifdef CONFIG_PM_SLEEP 181 + static int max8925_suspend(struct device *dev) 182 + { 183 + struct i2c_client *client = container_of(dev, struct i2c_client, dev); 184 + struct max8925_chip *chip = i2c_get_clientdata(client); 185 + 186 + if (device_may_wakeup(dev) && chip->wakeup_flag) 187 + enable_irq_wake(chip->core_irq); 188 + return 0; 189 + } 190 + 191 + static int max8925_resume(struct device *dev) 192 + { 193 + struct i2c_client *client = container_of(dev, struct i2c_client, dev); 194 + struct max8925_chip *chip = i2c_get_clientdata(client); 195 + 196 + if (device_may_wakeup(dev) && chip->wakeup_flag) 197 + disable_irq_wake(chip->core_irq); 198 + return 0; 199 + } 200 + #endif 201 + 202 + static SIMPLE_DEV_PM_OPS(max8925_pm_ops, max8925_suspend, max8925_resume); 203 + 182 204 static struct i2c_driver max8925_driver = { 183 205 .driver = { 184 206 .name = "max8925", 185 207 .owner = THIS_MODULE, 208 + .pm = &max8925_pm_ops, 186 209 }, 187 210 .probe = max8925_probe, 188 211 .remove = __devexit_p(max8925_remove),
+2 -1
drivers/mfd/max8997.c
··· 43 43 { .name = "max8997-battery", }, 44 44 { .name = "max8997-haptic", }, 45 45 { .name = "max8997-muic", }, 46 - { .name = "max8997-flash", }, 46 + { .name = "max8997-led", .id = 1 }, 47 + { .name = "max8997-led", .id = 2 }, 47 48 }; 48 49 49 50 int max8997_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest)
+4 -2
drivers/mfd/max8998.c
··· 176 176 if (ret < 0) 177 177 goto err; 178 178 179 + device_init_wakeup(max8998->dev, max8998->wakeup); 180 + 179 181 return ret; 180 182 181 183 err: ··· 212 210 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); 213 211 struct max8998_dev *max8998 = i2c_get_clientdata(i2c); 214 212 215 - if (max8998->wakeup) 213 + if (device_may_wakeup(dev)) 216 214 irq_set_irq_wake(max8998->irq, 1); 217 215 return 0; 218 216 } ··· 222 220 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); 223 221 struct max8998_dev *max8998 = i2c_get_clientdata(i2c); 224 222 225 - if (max8998->wakeup) 223 + if (device_may_wakeup(dev)) 226 224 irq_set_irq_wake(max8998->irq, 0); 227 225 /* 228 226 * In LP3974, if IRQ registers are not "read & clear"
+77 -34
drivers/mfd/mc13xxx-core.c
··· 18 18 #include <linux/spi/spi.h> 19 19 #include <linux/mfd/core.h> 20 20 #include <linux/mfd/mc13xxx.h> 21 + #include <linux/of.h> 22 + #include <linux/of_device.h> 23 + #include <linux/of_gpio.h> 21 24 22 25 struct mc13xxx { 23 26 struct spi_device *spidev; 24 27 struct mutex lock; 25 28 int irq; 29 + int flags; 26 30 27 31 irq_handler_t irqhandler[MC13XXX_NUM_IRQ]; 28 32 void *irqdata[MC13XXX_NUM_IRQ]; ··· 554 550 555 551 int mc13xxx_get_flags(struct mc13xxx *mc13xxx) 556 552 { 557 - struct mc13xxx_platform_data *pdata = 558 - dev_get_platdata(&mc13xxx->spidev->dev); 559 - 560 - return pdata->flags; 553 + return mc13xxx->flags; 561 554 } 562 555 EXPORT_SYMBOL(mc13xxx_get_flags); 563 556 ··· 616 615 break; 617 616 618 617 case MC13XXX_ADC_MODE_SINGLE_CHAN: 619 - adc0 |= old_adc0 & MC13XXX_ADC0_TSMOD_MASK; 618 + adc0 |= old_adc0 & MC13XXX_ADC0_CONFIG_MASK; 620 619 adc1 |= (channel & 0x7) << MC13XXX_ADC1_CHAN0_SHIFT; 621 620 adc1 |= MC13XXX_ADC1_RAND; 622 621 break; 623 622 624 623 case MC13XXX_ADC_MODE_MULT_CHAN: 625 - adc0 |= old_adc0 & MC13XXX_ADC0_TSMOD_MASK; 624 + adc0 |= old_adc0 & MC13XXX_ADC0_CONFIG_MASK; 626 625 adc1 |= 4 << MC13XXX_ADC1_CHAN1_SHIFT; 627 626 break; 628 627 ··· 697 696 return mc13xxx_add_subdevice_pdata(mc13xxx, format, NULL, 0); 698 697 } 699 698 699 + #ifdef CONFIG_OF 700 + static int mc13xxx_probe_flags_dt(struct mc13xxx *mc13xxx) 701 + { 702 + struct device_node *np = mc13xxx->spidev->dev.of_node; 703 + 704 + if (!np) 705 + return -ENODEV; 706 + 707 + if (of_get_property(np, "fsl,mc13xxx-uses-adc", NULL)) 708 + mc13xxx->flags |= MC13XXX_USE_ADC; 709 + 710 + if (of_get_property(np, "fsl,mc13xxx-uses-codec", NULL)) 711 + mc13xxx->flags |= MC13XXX_USE_CODEC; 712 + 713 + if (of_get_property(np, "fsl,mc13xxx-uses-rtc", NULL)) 714 + mc13xxx->flags |= MC13XXX_USE_RTC; 715 + 716 + if (of_get_property(np, "fsl,mc13xxx-uses-touch", NULL)) 717 + mc13xxx->flags |= MC13XXX_USE_TOUCHSCREEN; 718 + 719 + return 0; 720 + } 721 + #else 722 + static inline int mc13xxx_probe_flags_dt(struct mc13xxx *mc13xxx) 723 + { 724 + return -ENODEV; 725 + } 726 + #endif 727 + 728 + static const struct spi_device_id mc13xxx_device_id[] = { 729 + { 730 + .name = "mc13783", 731 + .driver_data = MC13XXX_ID_MC13783, 732 + }, { 733 + .name = "mc13892", 734 + .driver_data = MC13XXX_ID_MC13892, 735 + }, { 736 + /* sentinel */ 737 + } 738 + }; 739 + MODULE_DEVICE_TABLE(spi, mc13xxx_device_id); 740 + 741 + static const struct of_device_id mc13xxx_dt_ids[] = { 742 + { .compatible = "fsl,mc13783", .data = (void *) MC13XXX_ID_MC13783, }, 743 + { .compatible = "fsl,mc13892", .data = (void *) MC13XXX_ID_MC13892, }, 744 + { /* sentinel */ } 745 + }; 746 + MODULE_DEVICE_TABLE(of, mc13xxx_dt_ids); 747 + 700 748 static int mc13xxx_probe(struct spi_device *spi) 701 749 { 750 + const struct of_device_id *of_id; 751 + struct spi_driver *sdrv = to_spi_driver(spi->dev.driver); 702 752 struct mc13xxx *mc13xxx; 703 753 struct mc13xxx_platform_data *pdata = dev_get_platdata(&spi->dev); 704 754 enum mc13xxx_id id; 705 755 int ret; 706 756 707 - if (!pdata) { 708 - dev_err(&spi->dev, "invalid platform data\n"); 709 - return -EINVAL; 710 - } 757 + of_id = of_match_device(mc13xxx_dt_ids, &spi->dev); 758 + if (of_id) 759 + sdrv->id_table = &mc13xxx_device_id[(enum mc13xxx_id) of_id->data]; 711 760 712 761 mc13xxx = kzalloc(sizeof(*mc13xxx), GFP_KERNEL); 713 762 if (!mc13xxx) ··· 800 749 801 750 mc13xxx_unlock(mc13xxx); 802 751 803 - if (pdata->flags & MC13XXX_USE_ADC) 752 + if (mc13xxx_probe_flags_dt(mc13xxx) < 0 && pdata) 753 + mc13xxx->flags = pdata->flags; 754 + 755 + if (mc13xxx->flags & MC13XXX_USE_ADC) 804 756 mc13xxx_add_subdevice(mc13xxx, "%s-adc"); 805 757 806 - if (pdata->flags & MC13XXX_USE_CODEC) 758 + if (mc13xxx->flags & MC13XXX_USE_CODEC) 807 759 mc13xxx_add_subdevice(mc13xxx, "%s-codec"); 808 760 809 - mc13xxx_add_subdevice_pdata(mc13xxx, "%s-regulator", 810 - &pdata->regulators, sizeof(pdata->regulators)); 811 - 812 - if (pdata->flags & MC13XXX_USE_RTC) 761 + if (mc13xxx->flags & MC13XXX_USE_RTC) 813 762 mc13xxx_add_subdevice(mc13xxx, "%s-rtc"); 814 763 815 - if (pdata->flags & MC13XXX_USE_TOUCHSCREEN) 764 + if (mc13xxx->flags & MC13XXX_USE_TOUCHSCREEN) 816 765 mc13xxx_add_subdevice(mc13xxx, "%s-ts"); 817 766 818 - if (pdata->leds) 767 + if (pdata) { 768 + mc13xxx_add_subdevice_pdata(mc13xxx, "%s-regulator", 769 + &pdata->regulators, sizeof(pdata->regulators)); 819 770 mc13xxx_add_subdevice_pdata(mc13xxx, "%s-led", 820 771 pdata->leds, sizeof(*pdata->leds)); 821 - 822 - if (pdata->buttons) 823 772 mc13xxx_add_subdevice_pdata(mc13xxx, "%s-pwrbutton", 824 773 pdata->buttons, sizeof(*pdata->buttons)); 774 + } else { 775 + mc13xxx_add_subdevice(mc13xxx, "%s-regulator"); 776 + mc13xxx_add_subdevice(mc13xxx, "%s-led"); 777 + mc13xxx_add_subdevice(mc13xxx, "%s-pwrbutton"); 778 + } 825 779 826 780 return 0; 827 781 } ··· 844 788 return 0; 845 789 } 846 790 847 - static const struct spi_device_id mc13xxx_device_id[] = { 848 - { 849 - .name = "mc13783", 850 - .driver_data = MC13XXX_ID_MC13783, 851 - }, { 852 - .name = "mc13892", 853 - .driver_data = MC13XXX_ID_MC13892, 854 - }, { 855 - /* sentinel */ 856 - } 857 - }; 858 - MODULE_DEVICE_TABLE(spi, mc13xxx_device_id); 859 - 860 791 static struct spi_driver mc13xxx_driver = { 861 792 .id_table = mc13xxx_device_id, 862 793 .driver = { 863 794 .name = "mc13xxx", 864 - .bus = &spi_bus_type, 865 795 .owner = THIS_MODULE, 796 + .of_match_table = mc13xxx_dt_ids, 866 797 }, 867 798 .probe = mc13xxx_probe, 868 799 .remove = __devexit_p(mc13xxx_remove),
+42 -2
drivers/mfd/mcp-core.c
··· 26 26 #define to_mcp(d) container_of(d, struct mcp, attached_device) 27 27 #define to_mcp_driver(d) container_of(d, struct mcp_driver, drv) 28 28 29 + static const struct mcp_device_id *mcp_match_id(const struct mcp_device_id *id, 30 + const char *codec) 31 + { 32 + while (id->name[0]) { 33 + if (strcmp(codec, id->name) == 0) 34 + return id; 35 + id++; 36 + } 37 + return NULL; 38 + } 39 + 40 + const struct mcp_device_id *mcp_get_device_id(const struct mcp *mcp) 41 + { 42 + const struct mcp_driver *driver = 43 + to_mcp_driver(mcp->attached_device.driver); 44 + 45 + return mcp_match_id(driver->id_table, mcp->codec); 46 + } 47 + EXPORT_SYMBOL(mcp_get_device_id); 48 + 29 49 static int mcp_bus_match(struct device *dev, struct device_driver *drv) 30 50 { 31 - return 1; 51 + const struct mcp *mcp = to_mcp(dev); 52 + const struct mcp_driver *driver = to_mcp_driver(drv); 53 + 54 + if (driver->id_table) 55 + return !!mcp_match_id(driver->id_table, mcp->codec); 56 + 57 + return 0; 32 58 } 33 59 34 60 static int mcp_bus_probe(struct device *dev) ··· 100 74 return ret; 101 75 } 102 76 77 + static int mcp_bus_uevent(struct device *dev, struct kobj_uevent_env *env) 78 + { 79 + struct mcp *mcp = to_mcp(dev); 80 + 81 + add_uevent_var(env, "MODALIAS=%s%s", MCP_MODULE_PREFIX, mcp->codec); 82 + return 0; 83 + } 84 + 103 85 static struct bus_type mcp_bus_type = { 104 86 .name = "mcp", 105 87 .match = mcp_bus_match, 88 + .uevent = mcp_bus_uevent, 106 89 .probe = mcp_bus_probe, 107 90 .remove = mcp_bus_remove, 108 91 .suspend = mcp_bus_suspend, ··· 247 212 } 248 213 EXPORT_SYMBOL(mcp_host_alloc); 249 214 250 - int mcp_host_register(struct mcp *mcp) 215 + int mcp_host_register(struct mcp *mcp, void *pdata) 251 216 { 217 + if (!mcp->codec) 218 + return -EINVAL; 219 + 220 + mcp->attached_device.platform_data = pdata; 252 221 dev_set_name(&mcp->attached_device, "mcp0"); 222 + request_module("%s%s", MCP_MODULE_PREFIX, mcp->codec); 253 223 return device_register(&mcp->attached_device); 254 224 } 255 225 EXPORT_SYMBOL(mcp_host_register);
+116 -66
drivers/mfd/mcp-sa11x0.c
··· 19 19 #include <linux/spinlock.h> 20 20 #include <linux/platform_device.h> 21 21 #include <linux/mfd/mcp.h> 22 + #include <linux/io.h> 22 23 23 24 #include <mach/dma.h> 24 25 #include <mach/hardware.h> ··· 27 26 #include <asm/system.h> 28 27 #include <mach/mcp.h> 29 28 30 - #include <mach/assabet.h> 31 - 29 + /* Register offsets */ 30 + #define MCCR0 0x00 31 + #define MCDR0 0x08 32 + #define MCDR1 0x0C 33 + #define MCDR2 0x10 34 + #define MCSR 0x18 35 + #define MCCR1 0x00 32 36 33 37 struct mcp_sa11x0 { 34 - u32 mccr0; 35 - u32 mccr1; 38 + u32 mccr0; 39 + u32 mccr1; 40 + unsigned char *mccr0_base; 41 + unsigned char *mccr1_base; 36 42 }; 37 43 38 44 #define priv(mcp) ((struct mcp_sa11x0 *)mcp_priv(mcp)) ··· 47 39 static void 48 40 mcp_sa11x0_set_telecom_divisor(struct mcp *mcp, unsigned int divisor) 49 41 { 50 - unsigned int mccr0; 42 + struct mcp_sa11x0 *priv = priv(mcp); 51 43 52 44 divisor /= 32; 53 45 54 - mccr0 = Ser4MCCR0 & ~0x00007f00; 55 - mccr0 |= divisor << 8; 56 - Ser4MCCR0 = mccr0; 46 + priv->mccr0 &= ~0x00007f00; 47 + priv->mccr0 |= divisor << 8; 48 + __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0); 57 49 } 58 50 59 51 static void 60 52 mcp_sa11x0_set_audio_divisor(struct mcp *mcp, unsigned int divisor) 61 53 { 62 - unsigned int mccr0; 54 + struct mcp_sa11x0 *priv = priv(mcp); 63 55 64 56 divisor /= 32; 65 57 66 - mccr0 = Ser4MCCR0 & ~0x0000007f; 67 - mccr0 |= divisor; 68 - Ser4MCCR0 = mccr0; 58 + priv->mccr0 &= ~0x0000007f; 59 + priv->mccr0 |= divisor; 60 + __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0); 69 61 } 70 62 71 63 /* ··· 79 71 { 80 72 int ret = -ETIME; 81 73 int i; 74 + u32 mcpreg; 75 + struct mcp_sa11x0 *priv = priv(mcp); 82 76 83 - Ser4MCDR2 = reg << 17 | MCDR2_Wr | (val & 0xffff); 77 + mcpreg = reg << 17 | MCDR2_Wr | (val & 0xffff); 78 + __raw_writel(mcpreg, priv->mccr0_base + MCDR2); 84 79 85 80 for (i = 0; i < 2; i++) { 86 81 udelay(mcp->rw_timeout); 87 - if (Ser4MCSR & MCSR_CWC) { 82 + mcpreg = __raw_readl(priv->mccr0_base + MCSR); 83 + if (mcpreg & MCSR_CWC) { 88 84 ret = 0; 89 85 break; 90 86 } ··· 109 97 { 110 98 int ret = -ETIME; 111 99 int i; 100 + u32 mcpreg; 101 + struct mcp_sa11x0 *priv = priv(mcp); 112 102 113 - Ser4MCDR2 = reg << 17 | MCDR2_Rd; 103 + mcpreg = reg << 17 | MCDR2_Rd; 104 + __raw_writel(mcpreg, priv->mccr0_base + MCDR2); 114 105 115 106 for (i = 0; i < 2; i++) { 116 107 udelay(mcp->rw_timeout); 117 - if (Ser4MCSR & MCSR_CRC) { 118 - ret = Ser4MCDR2 & 0xffff; 108 + mcpreg = __raw_readl(priv->mccr0_base + MCSR); 109 + if (mcpreg & MCSR_CRC) { 110 + ret = __raw_readl(priv->mccr0_base + MCDR2) 111 + & 0xffff; 119 112 break; 120 113 } 121 114 } ··· 133 116 134 117 static void mcp_sa11x0_enable(struct mcp *mcp) 135 118 { 136 - Ser4MCSR = -1; 137 - Ser4MCCR0 |= MCCR0_MCE; 119 + struct mcp_sa11x0 *priv = priv(mcp); 120 + 121 + __raw_writel(-1, priv->mccr0_base + MCSR); 122 + priv->mccr0 |= MCCR0_MCE; 123 + __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0); 138 124 } 139 125 140 126 static void mcp_sa11x0_disable(struct mcp *mcp) 141 127 { 142 - Ser4MCCR0 &= ~MCCR0_MCE; 128 + struct mcp_sa11x0 *priv = priv(mcp); 129 + 130 + priv->mccr0 &= ~MCCR0_MCE; 131 + __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0); 143 132 } 144 133 145 134 /* ··· 165 142 struct mcp_plat_data *data = pdev->dev.platform_data; 166 143 struct mcp *mcp; 167 144 int ret; 145 + struct mcp_sa11x0 *priv; 146 + struct resource *res_mem0, *res_mem1; 147 + u32 size0, size1; 168 148 169 149 if (!data) 170 150 return -ENODEV; 171 151 172 - if (!request_mem_region(0x80060000, 0x60, "sa11x0-mcp")) 152 + if (!data->codec) 153 + return -ENODEV; 154 + 155 + res_mem0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); 156 + if (!res_mem0) 157 + return -ENODEV; 158 + size0 = res_mem0->end - res_mem0->start + 1; 159 + 160 + res_mem1 = platform_get_resource(pdev, IORESOURCE_MEM, 1); 161 + if (!res_mem1) 162 + return -ENODEV; 163 + size1 = res_mem1->end - res_mem1->start + 1; 164 + 165 + if (!request_mem_region(res_mem0->start, size0, "sa11x0-mcp")) 173 166 return -EBUSY; 167 + 168 + if (!request_mem_region(res_mem1->start, size1, "sa11x0-mcp")) { 169 + ret = -EBUSY; 170 + goto release; 171 + } 174 172 175 173 mcp = mcp_host_alloc(&pdev->dev, sizeof(struct mcp_sa11x0)); 176 174 if (!mcp) { 177 175 ret = -ENOMEM; 178 - goto release; 176 + goto release2; 179 177 } 178 + 179 + priv = priv(mcp); 180 180 181 181 mcp->owner = THIS_MODULE; 182 182 mcp->ops = &mcp_sa11x0; 183 183 mcp->sclk_rate = data->sclk_rate; 184 - mcp->dma_audio_rd = DMA_Ser4MCP0Rd; 185 - mcp->dma_audio_wr = DMA_Ser4MCP0Wr; 186 - mcp->dma_telco_rd = DMA_Ser4MCP1Rd; 187 - mcp->dma_telco_wr = DMA_Ser4MCP1Wr; 188 - mcp->gpio_base = data->gpio_base; 184 + mcp->dma_audio_rd = DDAR_DevAdd(res_mem0->start + MCDR0) 185 + + DDAR_DevRd + DDAR_Brst4 + DDAR_8BitDev; 186 + mcp->dma_audio_wr = DDAR_DevAdd(res_mem0->start + MCDR0) 187 + + DDAR_DevWr + DDAR_Brst4 + DDAR_8BitDev; 188 + mcp->dma_telco_rd = DDAR_DevAdd(res_mem0->start + MCDR1) 189 + + DDAR_DevRd + DDAR_Brst4 + DDAR_8BitDev; 190 + mcp->dma_telco_wr = DDAR_DevAdd(res_mem0->start + MCDR1) 191 + + DDAR_DevWr + DDAR_Brst4 + DDAR_8BitDev; 192 + mcp->codec = data->codec; 189 193 190 194 platform_set_drvdata(pdev, mcp); 191 - 192 - if (machine_is_assabet()) { 193 - ASSABET_BCR_set(ASSABET_BCR_CODEC_RST); 194 - } 195 - 196 - /* 197 - * Setup the PPC unit correctly. 198 - */ 199 - PPDR &= ~PPC_RXD4; 200 - PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM; 201 - PSDR |= PPC_RXD4; 202 - PSDR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); 203 - PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); 204 195 205 196 /* 206 197 * Initialise device. Note that we initially 207 198 * set the sampling rate to minimum. 208 199 */ 209 - Ser4MCSR = -1; 210 - Ser4MCCR1 = data->mccr1; 211 - Ser4MCCR0 = data->mccr0 | 0x7f7f; 200 + priv->mccr0_base = ioremap(res_mem0->start, size0); 201 + priv->mccr1_base = ioremap(res_mem1->start, size1); 202 + 203 + __raw_writel(-1, priv->mccr0_base + MCSR); 204 + priv->mccr1 = data->mccr1; 205 + priv->mccr0 = data->mccr0 | 0x7f7f; 206 + __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0); 207 + __raw_writel(priv->mccr1, priv->mccr1_base + MCCR1); 212 208 213 209 /* 214 210 * Calculate the read/write timeout (us) from the bit clock ··· 237 195 mcp->rw_timeout = (64 * 3 * 1000000 + mcp->sclk_rate - 1) / 238 196 mcp->sclk_rate; 239 197 240 - ret = mcp_host_register(mcp); 198 + ret = mcp_host_register(mcp, data->codec_pdata); 241 199 if (ret == 0) 242 200 goto out; 243 201 202 + release2: 203 + release_mem_region(res_mem1->start, size1); 244 204 release: 245 - release_mem_region(0x80060000, 0x60); 205 + release_mem_region(res_mem0->start, size0); 246 206 platform_set_drvdata(pdev, NULL); 247 207 248 208 out: 249 209 return ret; 250 210 } 251 211 252 - static int mcp_sa11x0_remove(struct platform_device *dev) 212 + static int mcp_sa11x0_remove(struct platform_device *pdev) 253 213 { 254 - struct mcp *mcp = platform_get_drvdata(dev); 214 + struct mcp *mcp = platform_get_drvdata(pdev); 215 + struct mcp_sa11x0 *priv = priv(mcp); 216 + struct resource *res_mem; 217 + u32 size; 255 218 256 - platform_set_drvdata(dev, NULL); 219 + platform_set_drvdata(pdev, NULL); 257 220 mcp_host_unregister(mcp); 258 - release_mem_region(0x80060000, 0x60); 259 221 222 + res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 223 + if (res_mem) { 224 + size = res_mem->end - res_mem->start + 1; 225 + release_mem_region(res_mem->start, size); 226 + } 227 + res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); 228 + if (res_mem) { 229 + size = res_mem->end - res_mem->start + 1; 230 + release_mem_region(res_mem->start, size); 231 + } 232 + iounmap(priv->mccr0_base); 233 + iounmap(priv->mccr1_base); 260 234 return 0; 261 235 } 262 236 263 237 static int mcp_sa11x0_suspend(struct platform_device *dev, pm_message_t state) 264 238 { 265 239 struct mcp *mcp = platform_get_drvdata(dev); 240 + struct mcp_sa11x0 *priv = priv(mcp); 241 + u32 mccr0; 266 242 267 - priv(mcp)->mccr0 = Ser4MCCR0; 268 - priv(mcp)->mccr1 = Ser4MCCR1; 269 - Ser4MCCR0 &= ~MCCR0_MCE; 243 + mccr0 = priv->mccr0 & ~MCCR0_MCE; 244 + __raw_writel(mccr0, priv->mccr0_base + MCCR0); 270 245 271 246 return 0; 272 247 } ··· 291 232 static int mcp_sa11x0_resume(struct platform_device *dev) 292 233 { 293 234 struct mcp *mcp = platform_get_drvdata(dev); 235 + struct mcp_sa11x0 *priv = priv(mcp); 294 236 295 - Ser4MCCR1 = priv(mcp)->mccr1; 296 - Ser4MCCR0 = priv(mcp)->mccr0; 237 + __raw_writel(priv->mccr0, priv->mccr0_base + MCCR0); 238 + __raw_writel(priv->mccr1, priv->mccr1_base + MCCR1); 297 239 298 240 return 0; 299 241 } ··· 311 251 .resume = mcp_sa11x0_resume, 312 252 .driver = { 313 253 .name = "sa11x0-mcp", 254 + .owner = THIS_MODULE, 314 255 }, 315 256 }; 316 257 317 258 /* 318 259 * This needs re-working 319 260 */ 320 - static int __init mcp_sa11x0_init(void) 321 - { 322 - return platform_driver_register(&mcp_sa11x0_driver); 323 - } 324 - 325 - static void __exit mcp_sa11x0_exit(void) 326 - { 327 - platform_driver_unregister(&mcp_sa11x0_driver); 328 - } 329 - 330 - module_init(mcp_sa11x0_init); 331 - module_exit(mcp_sa11x0_exit); 261 + module_platform_driver(mcp_sa11x0_driver); 332 262 333 263 MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); 334 264 MODULE_DESCRIPTION("SA11x0 multimedia communications port driver");
+6 -12
drivers/mfd/omap-usb-host.c
··· 503 503 spin_lock_irqsave(&omap->lock, flags); 504 504 505 505 if (pdata->ehci_data->phy_reset) { 506 - if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) { 507 - gpio_request(pdata->ehci_data->reset_gpio_port[0], 508 - "USB1 PHY reset"); 509 - gpio_direction_output 510 - (pdata->ehci_data->reset_gpio_port[0], 0); 511 - } 506 + if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) 507 + gpio_request_one(pdata->ehci_data->reset_gpio_port[0], 508 + GPIOF_OUT_INIT_LOW, "USB1 PHY reset"); 512 509 513 - if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) { 514 - gpio_request(pdata->ehci_data->reset_gpio_port[1], 515 - "USB2 PHY reset"); 516 - gpio_direction_output 517 - (pdata->ehci_data->reset_gpio_port[1], 0); 518 - } 510 + if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) 511 + gpio_request_one(pdata->ehci_data->reset_gpio_port[1], 512 + GPIOF_OUT_INIT_LOW, "USB2 PHY reset"); 519 513 520 514 /* Hold the PHY in RESET for enough time till DIR is high */ 521 515 udelay(10);
+1 -11
drivers/mfd/pcf50633-adc.c
··· 249 249 .remove = __devexit_p(pcf50633_adc_remove), 250 250 }; 251 251 252 - static int __init pcf50633_adc_init(void) 253 - { 254 - return platform_driver_register(&pcf50633_adc_driver); 255 - } 256 - module_init(pcf50633_adc_init); 257 - 258 - static void __exit pcf50633_adc_exit(void) 259 - { 260 - platform_driver_unregister(&pcf50633_adc_driver); 261 - } 262 - module_exit(pcf50633_adc_exit); 252 + module_platform_driver(pcf50633_adc_driver); 263 253 264 254 MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>"); 265 255 MODULE_DESCRIPTION("PCF50633 adc driver");
+176
drivers/mfd/s5m-core.c
··· 1 + /* 2 + * s5m87xx.c 3 + * 4 + * Copyright (c) 2011 Samsung Electronics Co., Ltd 5 + * http://www.samsung.com 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License as published by the 9 + * Free Software Foundation; either version 2 of the License, or (at your 10 + * option) any later version. 11 + * 12 + */ 13 + 14 + #include <linux/module.h> 15 + #include <linux/moduleparam.h> 16 + #include <linux/init.h> 17 + #include <linux/err.h> 18 + #include <linux/slab.h> 19 + #include <linux/i2c.h> 20 + #include <linux/interrupt.h> 21 + #include <linux/pm_runtime.h> 22 + #include <linux/mutex.h> 23 + #include <linux/mfd/core.h> 24 + #include <linux/mfd/s5m87xx/s5m-core.h> 25 + #include <linux/mfd/s5m87xx/s5m-pmic.h> 26 + #include <linux/mfd/s5m87xx/s5m-rtc.h> 27 + #include <linux/regmap.h> 28 + 29 + static struct mfd_cell s5m87xx_devs[] = { 30 + { 31 + .name = "s5m8767-pmic", 32 + }, { 33 + .name = "s5m-rtc", 34 + }, 35 + }; 36 + 37 + int s5m_reg_read(struct s5m87xx_dev *s5m87xx, u8 reg, void *dest) 38 + { 39 + return regmap_read(s5m87xx->regmap, reg, dest); 40 + } 41 + EXPORT_SYMBOL_GPL(s5m_reg_read); 42 + 43 + int s5m_bulk_read(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf) 44 + { 45 + return regmap_bulk_read(s5m87xx->regmap, reg, buf, count);; 46 + } 47 + EXPORT_SYMBOL_GPL(s5m_bulk_read); 48 + 49 + int s5m_reg_write(struct s5m87xx_dev *s5m87xx, u8 reg, u8 value) 50 + { 51 + return regmap_write(s5m87xx->regmap, reg, value); 52 + } 53 + EXPORT_SYMBOL_GPL(s5m_reg_write); 54 + 55 + int s5m_bulk_write(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf) 56 + { 57 + return regmap_raw_write(s5m87xx->regmap, reg, buf, count * sizeof(u16)); 58 + } 59 + EXPORT_SYMBOL_GPL(s5m_bulk_write); 60 + 61 + int s5m_reg_update(struct s5m87xx_dev *s5m87xx, u8 reg, u8 val, u8 mask) 62 + { 63 + return regmap_update_bits(s5m87xx->regmap, reg, mask, val); 64 + } 65 + EXPORT_SYMBOL_GPL(s5m_reg_update); 66 + 67 + static struct regmap_config s5m_regmap_config = { 68 + .reg_bits = 8, 69 + .val_bits = 8, 70 + }; 71 + 72 + static int s5m87xx_i2c_probe(struct i2c_client *i2c, 73 + const struct i2c_device_id *id) 74 + { 75 + struct s5m_platform_data *pdata = i2c->dev.platform_data; 76 + struct s5m87xx_dev *s5m87xx; 77 + int ret = 0; 78 + int error; 79 + 80 + s5m87xx = kzalloc(sizeof(struct s5m87xx_dev), GFP_KERNEL); 81 + if (s5m87xx == NULL) 82 + return -ENOMEM; 83 + 84 + i2c_set_clientdata(i2c, s5m87xx); 85 + s5m87xx->dev = &i2c->dev; 86 + s5m87xx->i2c = i2c; 87 + s5m87xx->irq = i2c->irq; 88 + s5m87xx->type = id->driver_data; 89 + 90 + if (pdata) { 91 + s5m87xx->device_type = pdata->device_type; 92 + s5m87xx->ono = pdata->ono; 93 + s5m87xx->irq_base = pdata->irq_base; 94 + s5m87xx->wakeup = pdata->wakeup; 95 + } 96 + 97 + s5m87xx->regmap = regmap_init_i2c(i2c, &s5m_regmap_config); 98 + if (IS_ERR(s5m87xx->regmap)) { 99 + error = PTR_ERR(s5m87xx->regmap); 100 + dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 101 + error); 102 + goto err; 103 + } 104 + 105 + s5m87xx->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR); 106 + i2c_set_clientdata(s5m87xx->rtc, s5m87xx); 107 + 108 + if (pdata->cfg_pmic_irq) 109 + pdata->cfg_pmic_irq(); 110 + 111 + s5m_irq_init(s5m87xx); 112 + 113 + pm_runtime_set_active(s5m87xx->dev); 114 + 115 + ret = mfd_add_devices(s5m87xx->dev, -1, 116 + s5m87xx_devs, ARRAY_SIZE(s5m87xx_devs), 117 + NULL, 0); 118 + 119 + if (ret < 0) 120 + goto err; 121 + 122 + return ret; 123 + 124 + err: 125 + mfd_remove_devices(s5m87xx->dev); 126 + s5m_irq_exit(s5m87xx); 127 + i2c_unregister_device(s5m87xx->rtc); 128 + regmap_exit(s5m87xx->regmap); 129 + kfree(s5m87xx); 130 + return ret; 131 + } 132 + 133 + static int s5m87xx_i2c_remove(struct i2c_client *i2c) 134 + { 135 + struct s5m87xx_dev *s5m87xx = i2c_get_clientdata(i2c); 136 + 137 + mfd_remove_devices(s5m87xx->dev); 138 + s5m_irq_exit(s5m87xx); 139 + i2c_unregister_device(s5m87xx->rtc); 140 + regmap_exit(s5m87xx->regmap); 141 + kfree(s5m87xx); 142 + return 0; 143 + } 144 + 145 + static const struct i2c_device_id s5m87xx_i2c_id[] = { 146 + { "s5m87xx", 0 }, 147 + { } 148 + }; 149 + MODULE_DEVICE_TABLE(i2c, s5m87xx_i2c_id); 150 + 151 + static struct i2c_driver s5m87xx_i2c_driver = { 152 + .driver = { 153 + .name = "s5m87xx", 154 + .owner = THIS_MODULE, 155 + }, 156 + .probe = s5m87xx_i2c_probe, 157 + .remove = s5m87xx_i2c_remove, 158 + .id_table = s5m87xx_i2c_id, 159 + }; 160 + 161 + static int __init s5m87xx_i2c_init(void) 162 + { 163 + return i2c_add_driver(&s5m87xx_i2c_driver); 164 + } 165 + 166 + subsys_initcall(s5m87xx_i2c_init); 167 + 168 + static void __exit s5m87xx_i2c_exit(void) 169 + { 170 + i2c_del_driver(&s5m87xx_i2c_driver); 171 + } 172 + module_exit(s5m87xx_i2c_exit); 173 + 174 + MODULE_AUTHOR("Sangbeom Kim <sbkim73@samsung.com>"); 175 + MODULE_DESCRIPTION("Core support for the S5M MFD"); 176 + MODULE_LICENSE("GPL");
+487
drivers/mfd/s5m-irq.c
··· 1 + /* 2 + * s5m-irq.c 3 + * 4 + * Copyright (c) 2011 Samsung Electronics Co., Ltd 5 + * http://www.samsung.com 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License as published by the 9 + * Free Software Foundation; either version 2 of the License, or (at your 10 + * option) any later version. 11 + * 12 + */ 13 + 14 + #include <linux/device.h> 15 + #include <linux/interrupt.h> 16 + #include <linux/irq.h> 17 + #include <linux/mfd/s5m87xx/s5m-core.h> 18 + 19 + struct s5m_irq_data { 20 + int reg; 21 + int mask; 22 + }; 23 + 24 + static struct s5m_irq_data s5m8767_irqs[] = { 25 + [S5M8767_IRQ_PWRR] = { 26 + .reg = 1, 27 + .mask = S5M8767_IRQ_PWRR_MASK, 28 + }, 29 + [S5M8767_IRQ_PWRF] = { 30 + .reg = 1, 31 + .mask = S5M8767_IRQ_PWRF_MASK, 32 + }, 33 + [S5M8767_IRQ_PWR1S] = { 34 + .reg = 1, 35 + .mask = S5M8767_IRQ_PWR1S_MASK, 36 + }, 37 + [S5M8767_IRQ_JIGR] = { 38 + .reg = 1, 39 + .mask = S5M8767_IRQ_JIGR_MASK, 40 + }, 41 + [S5M8767_IRQ_JIGF] = { 42 + .reg = 1, 43 + .mask = S5M8767_IRQ_JIGF_MASK, 44 + }, 45 + [S5M8767_IRQ_LOWBAT2] = { 46 + .reg = 1, 47 + .mask = S5M8767_IRQ_LOWBAT2_MASK, 48 + }, 49 + [S5M8767_IRQ_LOWBAT1] = { 50 + .reg = 1, 51 + .mask = S5M8767_IRQ_LOWBAT1_MASK, 52 + }, 53 + [S5M8767_IRQ_MRB] = { 54 + .reg = 2, 55 + .mask = S5M8767_IRQ_MRB_MASK, 56 + }, 57 + [S5M8767_IRQ_DVSOK2] = { 58 + .reg = 2, 59 + .mask = S5M8767_IRQ_DVSOK2_MASK, 60 + }, 61 + [S5M8767_IRQ_DVSOK3] = { 62 + .reg = 2, 63 + .mask = S5M8767_IRQ_DVSOK3_MASK, 64 + }, 65 + [S5M8767_IRQ_DVSOK4] = { 66 + .reg = 2, 67 + .mask = S5M8767_IRQ_DVSOK4_MASK, 68 + }, 69 + [S5M8767_IRQ_RTC60S] = { 70 + .reg = 3, 71 + .mask = S5M8767_IRQ_RTC60S_MASK, 72 + }, 73 + [S5M8767_IRQ_RTCA1] = { 74 + .reg = 3, 75 + .mask = S5M8767_IRQ_RTCA1_MASK, 76 + }, 77 + [S5M8767_IRQ_RTCA2] = { 78 + .reg = 3, 79 + .mask = S5M8767_IRQ_RTCA2_MASK, 80 + }, 81 + [S5M8767_IRQ_SMPL] = { 82 + .reg = 3, 83 + .mask = S5M8767_IRQ_SMPL_MASK, 84 + }, 85 + [S5M8767_IRQ_RTC1S] = { 86 + .reg = 3, 87 + .mask = S5M8767_IRQ_RTC1S_MASK, 88 + }, 89 + [S5M8767_IRQ_WTSR] = { 90 + .reg = 3, 91 + .mask = S5M8767_IRQ_WTSR_MASK, 92 + }, 93 + }; 94 + 95 + static struct s5m_irq_data s5m8763_irqs[] = { 96 + [S5M8763_IRQ_DCINF] = { 97 + .reg = 1, 98 + .mask = S5M8763_IRQ_DCINF_MASK, 99 + }, 100 + [S5M8763_IRQ_DCINR] = { 101 + .reg = 1, 102 + .mask = S5M8763_IRQ_DCINR_MASK, 103 + }, 104 + [S5M8763_IRQ_JIGF] = { 105 + .reg = 1, 106 + .mask = S5M8763_IRQ_JIGF_MASK, 107 + }, 108 + [S5M8763_IRQ_JIGR] = { 109 + .reg = 1, 110 + .mask = S5M8763_IRQ_JIGR_MASK, 111 + }, 112 + [S5M8763_IRQ_PWRONF] = { 113 + .reg = 1, 114 + .mask = S5M8763_IRQ_PWRONF_MASK, 115 + }, 116 + [S5M8763_IRQ_PWRONR] = { 117 + .reg = 1, 118 + .mask = S5M8763_IRQ_PWRONR_MASK, 119 + }, 120 + [S5M8763_IRQ_WTSREVNT] = { 121 + .reg = 2, 122 + .mask = S5M8763_IRQ_WTSREVNT_MASK, 123 + }, 124 + [S5M8763_IRQ_SMPLEVNT] = { 125 + .reg = 2, 126 + .mask = S5M8763_IRQ_SMPLEVNT_MASK, 127 + }, 128 + [S5M8763_IRQ_ALARM1] = { 129 + .reg = 2, 130 + .mask = S5M8763_IRQ_ALARM1_MASK, 131 + }, 132 + [S5M8763_IRQ_ALARM0] = { 133 + .reg = 2, 134 + .mask = S5M8763_IRQ_ALARM0_MASK, 135 + }, 136 + [S5M8763_IRQ_ONKEY1S] = { 137 + .reg = 3, 138 + .mask = S5M8763_IRQ_ONKEY1S_MASK, 139 + }, 140 + [S5M8763_IRQ_TOPOFFR] = { 141 + .reg = 3, 142 + .mask = S5M8763_IRQ_TOPOFFR_MASK, 143 + }, 144 + [S5M8763_IRQ_DCINOVPR] = { 145 + .reg = 3, 146 + .mask = S5M8763_IRQ_DCINOVPR_MASK, 147 + }, 148 + [S5M8763_IRQ_CHGRSTF] = { 149 + .reg = 3, 150 + .mask = S5M8763_IRQ_CHGRSTF_MASK, 151 + }, 152 + [S5M8763_IRQ_DONER] = { 153 + .reg = 3, 154 + .mask = S5M8763_IRQ_DONER_MASK, 155 + }, 156 + [S5M8763_IRQ_CHGFAULT] = { 157 + .reg = 3, 158 + .mask = S5M8763_IRQ_CHGFAULT_MASK, 159 + }, 160 + [S5M8763_IRQ_LOBAT1] = { 161 + .reg = 4, 162 + .mask = S5M8763_IRQ_LOBAT1_MASK, 163 + }, 164 + [S5M8763_IRQ_LOBAT2] = { 165 + .reg = 4, 166 + .mask = S5M8763_IRQ_LOBAT2_MASK, 167 + }, 168 + }; 169 + 170 + static inline struct s5m_irq_data * 171 + irq_to_s5m8767_irq(struct s5m87xx_dev *s5m87xx, int irq) 172 + { 173 + return &s5m8767_irqs[irq - s5m87xx->irq_base]; 174 + } 175 + 176 + static void s5m8767_irq_lock(struct irq_data *data) 177 + { 178 + struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); 179 + 180 + mutex_lock(&s5m87xx->irqlock); 181 + } 182 + 183 + static void s5m8767_irq_sync_unlock(struct irq_data *data) 184 + { 185 + struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); 186 + int i; 187 + 188 + for (i = 0; i < ARRAY_SIZE(s5m87xx->irq_masks_cur); i++) { 189 + if (s5m87xx->irq_masks_cur[i] != s5m87xx->irq_masks_cache[i]) { 190 + s5m87xx->irq_masks_cache[i] = s5m87xx->irq_masks_cur[i]; 191 + s5m_reg_write(s5m87xx, S5M8767_REG_INT1M + i, 192 + s5m87xx->irq_masks_cur[i]); 193 + } 194 + } 195 + 196 + mutex_unlock(&s5m87xx->irqlock); 197 + } 198 + 199 + static void s5m8767_irq_unmask(struct irq_data *data) 200 + { 201 + struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); 202 + struct s5m_irq_data *irq_data = irq_to_s5m8767_irq(s5m87xx, 203 + data->irq); 204 + 205 + s5m87xx->irq_masks_cur[irq_data->reg - 1] &= ~irq_data->mask; 206 + } 207 + 208 + static void s5m8767_irq_mask(struct irq_data *data) 209 + { 210 + struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); 211 + struct s5m_irq_data *irq_data = irq_to_s5m8767_irq(s5m87xx, 212 + data->irq); 213 + 214 + s5m87xx->irq_masks_cur[irq_data->reg - 1] |= irq_data->mask; 215 + } 216 + 217 + static struct irq_chip s5m8767_irq_chip = { 218 + .name = "s5m8767", 219 + .irq_bus_lock = s5m8767_irq_lock, 220 + .irq_bus_sync_unlock = s5m8767_irq_sync_unlock, 221 + .irq_mask = s5m8767_irq_mask, 222 + .irq_unmask = s5m8767_irq_unmask, 223 + }; 224 + 225 + static inline struct s5m_irq_data * 226 + irq_to_s5m8763_irq(struct s5m87xx_dev *s5m87xx, int irq) 227 + { 228 + return &s5m8763_irqs[irq - s5m87xx->irq_base]; 229 + } 230 + 231 + static void s5m8763_irq_lock(struct irq_data *data) 232 + { 233 + struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); 234 + 235 + mutex_lock(&s5m87xx->irqlock); 236 + } 237 + 238 + static void s5m8763_irq_sync_unlock(struct irq_data *data) 239 + { 240 + struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); 241 + int i; 242 + 243 + for (i = 0; i < ARRAY_SIZE(s5m87xx->irq_masks_cur); i++) { 244 + if (s5m87xx->irq_masks_cur[i] != s5m87xx->irq_masks_cache[i]) { 245 + s5m87xx->irq_masks_cache[i] = s5m87xx->irq_masks_cur[i]; 246 + s5m_reg_write(s5m87xx, S5M8763_REG_IRQM1 + i, 247 + s5m87xx->irq_masks_cur[i]); 248 + } 249 + } 250 + 251 + mutex_unlock(&s5m87xx->irqlock); 252 + } 253 + 254 + static void s5m8763_irq_unmask(struct irq_data *data) 255 + { 256 + struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); 257 + struct s5m_irq_data *irq_data = irq_to_s5m8763_irq(s5m87xx, 258 + data->irq); 259 + 260 + s5m87xx->irq_masks_cur[irq_data->reg - 1] &= ~irq_data->mask; 261 + } 262 + 263 + static void s5m8763_irq_mask(struct irq_data *data) 264 + { 265 + struct s5m87xx_dev *s5m87xx = irq_data_get_irq_chip_data(data); 266 + struct s5m_irq_data *irq_data = irq_to_s5m8763_irq(s5m87xx, 267 + data->irq); 268 + 269 + s5m87xx->irq_masks_cur[irq_data->reg - 1] |= irq_data->mask; 270 + } 271 + 272 + static struct irq_chip s5m8763_irq_chip = { 273 + .name = "s5m8763", 274 + .irq_bus_lock = s5m8763_irq_lock, 275 + .irq_bus_sync_unlock = s5m8763_irq_sync_unlock, 276 + .irq_mask = s5m8763_irq_mask, 277 + .irq_unmask = s5m8763_irq_unmask, 278 + }; 279 + 280 + 281 + static irqreturn_t s5m8767_irq_thread(int irq, void *data) 282 + { 283 + struct s5m87xx_dev *s5m87xx = data; 284 + u8 irq_reg[NUM_IRQ_REGS-1]; 285 + int ret; 286 + int i; 287 + 288 + 289 + ret = s5m_bulk_read(s5m87xx, S5M8767_REG_INT1, 290 + NUM_IRQ_REGS - 1, irq_reg); 291 + if (ret < 0) { 292 + dev_err(s5m87xx->dev, "Failed to read interrupt register: %d\n", 293 + ret); 294 + return IRQ_NONE; 295 + } 296 + 297 + for (i = 0; i < NUM_IRQ_REGS - 1; i++) 298 + irq_reg[i] &= ~s5m87xx->irq_masks_cur[i]; 299 + 300 + for (i = 0; i < S5M8767_IRQ_NR; i++) { 301 + if (irq_reg[s5m8767_irqs[i].reg - 1] & s5m8767_irqs[i].mask) 302 + handle_nested_irq(s5m87xx->irq_base + i); 303 + } 304 + 305 + return IRQ_HANDLED; 306 + } 307 + 308 + static irqreturn_t s5m8763_irq_thread(int irq, void *data) 309 + { 310 + struct s5m87xx_dev *s5m87xx = data; 311 + u8 irq_reg[NUM_IRQ_REGS]; 312 + int ret; 313 + int i; 314 + 315 + ret = s5m_bulk_read(s5m87xx, S5M8763_REG_IRQ1, 316 + NUM_IRQ_REGS, irq_reg); 317 + if (ret < 0) { 318 + dev_err(s5m87xx->dev, "Failed to read interrupt register: %d\n", 319 + ret); 320 + return IRQ_NONE; 321 + } 322 + 323 + for (i = 0; i < NUM_IRQ_REGS; i++) 324 + irq_reg[i] &= ~s5m87xx->irq_masks_cur[i]; 325 + 326 + for (i = 0; i < S5M8763_IRQ_NR; i++) { 327 + if (irq_reg[s5m8763_irqs[i].reg - 1] & s5m8763_irqs[i].mask) 328 + handle_nested_irq(s5m87xx->irq_base + i); 329 + } 330 + 331 + return IRQ_HANDLED; 332 + } 333 + 334 + int s5m_irq_resume(struct s5m87xx_dev *s5m87xx) 335 + { 336 + if (s5m87xx->irq && s5m87xx->irq_base){ 337 + switch (s5m87xx->device_type) { 338 + case S5M8763X: 339 + s5m8763_irq_thread(s5m87xx->irq_base, s5m87xx); 340 + break; 341 + case S5M8767X: 342 + s5m8767_irq_thread(s5m87xx->irq_base, s5m87xx); 343 + break; 344 + default: 345 + break; 346 + 347 + } 348 + } 349 + return 0; 350 + } 351 + 352 + int s5m_irq_init(struct s5m87xx_dev *s5m87xx) 353 + { 354 + int i; 355 + int cur_irq; 356 + int ret = 0; 357 + int type = s5m87xx->device_type; 358 + 359 + if (!s5m87xx->irq) { 360 + dev_warn(s5m87xx->dev, 361 + "No interrupt specified, no interrupts\n"); 362 + s5m87xx->irq_base = 0; 363 + return 0; 364 + } 365 + 366 + if (!s5m87xx->irq_base) { 367 + dev_err(s5m87xx->dev, 368 + "No interrupt base specified, no interrupts\n"); 369 + return 0; 370 + } 371 + 372 + mutex_init(&s5m87xx->irqlock); 373 + 374 + switch (type) { 375 + case S5M8763X: 376 + for (i = 0; i < NUM_IRQ_REGS; i++) { 377 + s5m87xx->irq_masks_cur[i] = 0xff; 378 + s5m87xx->irq_masks_cache[i] = 0xff; 379 + s5m_reg_write(s5m87xx, S5M8763_REG_IRQM1 + i, 380 + 0xff); 381 + } 382 + 383 + s5m_reg_write(s5m87xx, S5M8763_REG_STATUSM1, 0xff); 384 + s5m_reg_write(s5m87xx, S5M8763_REG_STATUSM2, 0xff); 385 + 386 + for (i = 0; i < S5M8763_IRQ_NR; i++) { 387 + cur_irq = i + s5m87xx->irq_base; 388 + irq_set_chip_data(cur_irq, s5m87xx); 389 + irq_set_chip_and_handler(cur_irq, &s5m8763_irq_chip, 390 + handle_edge_irq); 391 + irq_set_nested_thread(cur_irq, 1); 392 + #ifdef CONFIG_ARM 393 + set_irq_flags(cur_irq, IRQF_VALID); 394 + #else 395 + irq_set_noprobe(cur_irq); 396 + #endif 397 + } 398 + 399 + ret = request_threaded_irq(s5m87xx->irq, NULL, 400 + s5m8763_irq_thread, 401 + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 402 + "s5m87xx-irq", s5m87xx); 403 + if (ret) { 404 + dev_err(s5m87xx->dev, "Failed to request IRQ %d: %d\n", 405 + s5m87xx->irq, ret); 406 + return ret; 407 + } 408 + break; 409 + case S5M8767X: 410 + for (i = 0; i < NUM_IRQ_REGS - 1; i++) { 411 + s5m87xx->irq_masks_cur[i] = 0xff; 412 + s5m87xx->irq_masks_cache[i] = 0xff; 413 + s5m_reg_write(s5m87xx, S5M8767_REG_INT1M + i, 414 + 0xff); 415 + } 416 + for (i = 0; i < S5M8767_IRQ_NR; i++) { 417 + cur_irq = i + s5m87xx->irq_base; 418 + irq_set_chip_data(cur_irq, s5m87xx); 419 + if (ret) { 420 + dev_err(s5m87xx->dev, 421 + "Failed to irq_set_chip_data %d: %d\n", 422 + s5m87xx->irq, ret); 423 + return ret; 424 + } 425 + 426 + irq_set_chip_and_handler(cur_irq, &s5m8767_irq_chip, 427 + handle_edge_irq); 428 + irq_set_nested_thread(cur_irq, 1); 429 + #ifdef CONFIG_ARM 430 + set_irq_flags(cur_irq, IRQF_VALID); 431 + #else 432 + irq_set_noprobe(cur_irq); 433 + #endif 434 + } 435 + 436 + ret = request_threaded_irq(s5m87xx->irq, NULL, 437 + s5m8767_irq_thread, 438 + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 439 + "s5m87xx-irq", s5m87xx); 440 + if (ret) { 441 + dev_err(s5m87xx->dev, "Failed to request IRQ %d: %d\n", 442 + s5m87xx->irq, ret); 443 + return ret; 444 + } 445 + break; 446 + default: 447 + break; 448 + } 449 + 450 + if (!s5m87xx->ono) 451 + return 0; 452 + 453 + switch (type) { 454 + case S5M8763X: 455 + ret = request_threaded_irq(s5m87xx->ono, NULL, 456 + s5m8763_irq_thread, 457 + IRQF_TRIGGER_FALLING | 458 + IRQF_TRIGGER_RISING | 459 + IRQF_ONESHOT, "s5m87xx-ono", 460 + s5m87xx); 461 + break; 462 + case S5M8767X: 463 + ret = request_threaded_irq(s5m87xx->ono, NULL, 464 + s5m8767_irq_thread, 465 + IRQF_TRIGGER_FALLING | 466 + IRQF_TRIGGER_RISING | 467 + IRQF_ONESHOT, "s5m87xx-ono", s5m87xx); 468 + break; 469 + default: 470 + break; 471 + } 472 + 473 + if (ret) 474 + dev_err(s5m87xx->dev, "Failed to request IRQ %d: %d\n", 475 + s5m87xx->ono, ret); 476 + 477 + return 0; 478 + } 479 + 480 + void s5m_irq_exit(struct s5m87xx_dev *s5m87xx) 481 + { 482 + if (s5m87xx->ono) 483 + free_irq(s5m87xx->ono, s5m87xx); 484 + 485 + if (s5m87xx->irq) 486 + free_irq(s5m87xx->irq, s5m87xx); 487 + }
+1 -1
drivers/mfd/sm501.c
··· 1720 1720 return 0; 1721 1721 } 1722 1722 1723 - static struct pci_device_id sm501_pci_tbl[] = { 1723 + static DEFINE_PCI_DEVICE_TABLE(sm501_pci_tbl) = { 1724 1724 { 0x126f, 0x0501, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 1725 1725 { 0, }, 1726 1726 };
+109
drivers/mfd/stmpe-i2c.c
··· 1 + /* 2 + * ST Microelectronics MFD: stmpe's i2c client specific driver 3 + * 4 + * Copyright (C) ST-Ericsson SA 2010 5 + * Copyright (C) ST Microelectronics SA 2011 6 + * 7 + * License Terms: GNU General Public License, version 2 8 + * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson 9 + * Author: Viresh Kumar <viresh.kumar@st.com> for ST Microelectronics 10 + */ 11 + 12 + #include <linux/i2c.h> 13 + #include <linux/interrupt.h> 14 + #include <linux/kernel.h> 15 + #include <linux/module.h> 16 + #include <linux/types.h> 17 + #include "stmpe.h" 18 + 19 + static int i2c_reg_read(struct stmpe *stmpe, u8 reg) 20 + { 21 + struct i2c_client *i2c = stmpe->client; 22 + 23 + return i2c_smbus_read_byte_data(i2c, reg); 24 + } 25 + 26 + static int i2c_reg_write(struct stmpe *stmpe, u8 reg, u8 val) 27 + { 28 + struct i2c_client *i2c = stmpe->client; 29 + 30 + return i2c_smbus_write_byte_data(i2c, reg, val); 31 + } 32 + 33 + static int i2c_block_read(struct stmpe *stmpe, u8 reg, u8 length, u8 *values) 34 + { 35 + struct i2c_client *i2c = stmpe->client; 36 + 37 + return i2c_smbus_read_i2c_block_data(i2c, reg, length, values); 38 + } 39 + 40 + static int i2c_block_write(struct stmpe *stmpe, u8 reg, u8 length, 41 + const u8 *values) 42 + { 43 + struct i2c_client *i2c = stmpe->client; 44 + 45 + return i2c_smbus_write_i2c_block_data(i2c, reg, length, values); 46 + } 47 + 48 + static struct stmpe_client_info i2c_ci = { 49 + .read_byte = i2c_reg_read, 50 + .write_byte = i2c_reg_write, 51 + .read_block = i2c_block_read, 52 + .write_block = i2c_block_write, 53 + }; 54 + 55 + static int __devinit 56 + stmpe_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) 57 + { 58 + i2c_ci.data = (void *)id; 59 + i2c_ci.irq = i2c->irq; 60 + i2c_ci.client = i2c; 61 + i2c_ci.dev = &i2c->dev; 62 + 63 + return stmpe_probe(&i2c_ci, id->driver_data); 64 + } 65 + 66 + static int __devexit stmpe_i2c_remove(struct i2c_client *i2c) 67 + { 68 + struct stmpe *stmpe = dev_get_drvdata(&i2c->dev); 69 + 70 + return stmpe_remove(stmpe); 71 + } 72 + 73 + static const struct i2c_device_id stmpe_i2c_id[] = { 74 + { "stmpe610", STMPE610 }, 75 + { "stmpe801", STMPE801 }, 76 + { "stmpe811", STMPE811 }, 77 + { "stmpe1601", STMPE1601 }, 78 + { "stmpe2401", STMPE2401 }, 79 + { "stmpe2403", STMPE2403 }, 80 + { } 81 + }; 82 + MODULE_DEVICE_TABLE(i2c, stmpe_id); 83 + 84 + static struct i2c_driver stmpe_i2c_driver = { 85 + .driver.name = "stmpe-i2c", 86 + .driver.owner = THIS_MODULE, 87 + #ifdef CONFIG_PM 88 + .driver.pm = &stmpe_dev_pm_ops, 89 + #endif 90 + .probe = stmpe_i2c_probe, 91 + .remove = __devexit_p(stmpe_i2c_remove), 92 + .id_table = stmpe_i2c_id, 93 + }; 94 + 95 + static int __init stmpe_init(void) 96 + { 97 + return i2c_add_driver(&stmpe_i2c_driver); 98 + } 99 + subsys_initcall(stmpe_init); 100 + 101 + static void __exit stmpe_exit(void) 102 + { 103 + i2c_del_driver(&stmpe_i2c_driver); 104 + } 105 + module_exit(stmpe_exit); 106 + 107 + MODULE_LICENSE("GPL v2"); 108 + MODULE_DESCRIPTION("STMPE MFD I2C Interface Driver"); 109 + MODULE_AUTHOR("Rabin Vincent <rabin.vincent@stericsson.com>");
+150
drivers/mfd/stmpe-spi.c
··· 1 + /* 2 + * ST Microelectronics MFD: stmpe's spi client specific driver 3 + * 4 + * Copyright (C) ST Microelectronics SA 2011 5 + * 6 + * License Terms: GNU General Public License, version 2 7 + * Author: Viresh Kumar <viresh.kumar@st.com> for ST Microelectronics 8 + */ 9 + 10 + #include <linux/spi/spi.h> 11 + #include <linux/interrupt.h> 12 + #include <linux/kernel.h> 13 + #include <linux/module.h> 14 + #include <linux/types.h> 15 + #include "stmpe.h" 16 + 17 + #define READ_CMD (1 << 7) 18 + 19 + static int spi_reg_read(struct stmpe *stmpe, u8 reg) 20 + { 21 + struct spi_device *spi = stmpe->client; 22 + int status = spi_w8r16(spi, reg | READ_CMD); 23 + 24 + return (status < 0) ? status : status >> 8; 25 + } 26 + 27 + static int spi_reg_write(struct stmpe *stmpe, u8 reg, u8 val) 28 + { 29 + struct spi_device *spi = stmpe->client; 30 + u16 cmd = (val << 8) | reg; 31 + 32 + return spi_write(spi, (const u8 *)&cmd, 2); 33 + } 34 + 35 + static int spi_block_read(struct stmpe *stmpe, u8 reg, u8 length, u8 *values) 36 + { 37 + int ret, i; 38 + 39 + for (i = 0; i < length; i++) { 40 + ret = spi_reg_read(stmpe, reg + i); 41 + if (ret < 0) 42 + return ret; 43 + *(values + i) = ret; 44 + } 45 + 46 + return 0; 47 + } 48 + 49 + static int spi_block_write(struct stmpe *stmpe, u8 reg, u8 length, 50 + const u8 *values) 51 + { 52 + int ret = 0, i; 53 + 54 + for (i = length; i > 0; i--, reg++) { 55 + ret = spi_reg_write(stmpe, reg, *(values + i - 1)); 56 + if (ret < 0) 57 + return ret; 58 + } 59 + 60 + return ret; 61 + } 62 + 63 + static void spi_init(struct stmpe *stmpe) 64 + { 65 + struct spi_device *spi = stmpe->client; 66 + 67 + spi->bits_per_word = 8; 68 + 69 + /* This register is only present for stmpe811 */ 70 + if (stmpe->variant->id_val == 0x0811) 71 + spi_reg_write(stmpe, STMPE811_REG_SPI_CFG, spi->mode); 72 + 73 + if (spi_setup(spi) < 0) 74 + dev_dbg(&spi->dev, "spi_setup failed\n"); 75 + } 76 + 77 + static struct stmpe_client_info spi_ci = { 78 + .read_byte = spi_reg_read, 79 + .write_byte = spi_reg_write, 80 + .read_block = spi_block_read, 81 + .write_block = spi_block_write, 82 + .init = spi_init, 83 + }; 84 + 85 + static int __devinit 86 + stmpe_spi_probe(struct spi_device *spi) 87 + { 88 + const struct spi_device_id *id = spi_get_device_id(spi); 89 + 90 + /* don't exceed max specified rate - 1MHz - Limitation of STMPE */ 91 + if (spi->max_speed_hz > 1000000) { 92 + dev_dbg(&spi->dev, "f(sample) %d KHz?\n", 93 + (spi->max_speed_hz/1000)); 94 + return -EINVAL; 95 + } 96 + 97 + spi_ci.irq = spi->irq; 98 + spi_ci.client = spi; 99 + spi_ci.dev = &spi->dev; 100 + 101 + return stmpe_probe(&spi_ci, id->driver_data); 102 + } 103 + 104 + static int __devexit stmpe_spi_remove(struct spi_device *spi) 105 + { 106 + struct stmpe *stmpe = dev_get_drvdata(&spi->dev); 107 + 108 + return stmpe_remove(stmpe); 109 + } 110 + 111 + static const struct spi_device_id stmpe_spi_id[] = { 112 + { "stmpe610", STMPE610 }, 113 + { "stmpe801", STMPE801 }, 114 + { "stmpe811", STMPE811 }, 115 + { "stmpe1601", STMPE1601 }, 116 + { "stmpe2401", STMPE2401 }, 117 + { "stmpe2403", STMPE2403 }, 118 + { } 119 + }; 120 + MODULE_DEVICE_TABLE(spi, stmpe_id); 121 + 122 + static struct spi_driver stmpe_spi_driver = { 123 + .driver = { 124 + .name = "stmpe-spi", 125 + .bus = &spi_bus_type, 126 + .owner = THIS_MODULE, 127 + #ifdef CONFIG_PM 128 + .pm = &stmpe_dev_pm_ops, 129 + #endif 130 + }, 131 + .probe = stmpe_spi_probe, 132 + .remove = __devexit_p(stmpe_spi_remove), 133 + .id_table = stmpe_spi_id, 134 + }; 135 + 136 + static int __init stmpe_init(void) 137 + { 138 + return spi_register_driver(&stmpe_spi_driver); 139 + } 140 + subsys_initcall(stmpe_init); 141 + 142 + static void __exit stmpe_exit(void) 143 + { 144 + spi_unregister_driver(&stmpe_spi_driver); 145 + } 146 + module_exit(stmpe_exit); 147 + 148 + MODULE_LICENSE("GPL v2"); 149 + MODULE_DESCRIPTION("STMPE MFD SPI Interface Driver"); 150 + MODULE_AUTHOR("Viresh Kumar <viresh.kumar@st.com>");
+173 -110
drivers/mfd/stmpe.c
··· 1 1 /* 2 + * ST Microelectronics MFD: stmpe's driver 3 + * 2 4 * Copyright (C) ST-Ericsson SA 2010 3 5 * 4 6 * License Terms: GNU General Public License, version 2 5 7 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson 6 8 */ 7 9 10 + #include <linux/gpio.h> 11 + #include <linux/export.h> 8 12 #include <linux/kernel.h> 9 - #include <linux/module.h> 10 13 #include <linux/interrupt.h> 11 14 #include <linux/irq.h> 15 + #include <linux/pm.h> 12 16 #include <linux/slab.h> 13 - #include <linux/i2c.h> 14 17 #include <linux/mfd/core.h> 15 - #include <linux/mfd/stmpe.h> 16 18 #include "stmpe.h" 17 19 18 20 static int __stmpe_enable(struct stmpe *stmpe, unsigned int blocks) ··· 31 29 { 32 30 int ret; 33 31 34 - ret = i2c_smbus_read_byte_data(stmpe->i2c, reg); 32 + ret = stmpe->ci->read_byte(stmpe, reg); 35 33 if (ret < 0) 36 - dev_err(stmpe->dev, "failed to read reg %#x: %d\n", 37 - reg, ret); 34 + dev_err(stmpe->dev, "failed to read reg %#x: %d\n", reg, ret); 38 35 39 36 dev_vdbg(stmpe->dev, "rd: reg %#x => data %#x\n", reg, ret); 40 37 ··· 46 45 47 46 dev_vdbg(stmpe->dev, "wr: reg %#x <= %#x\n", reg, val); 48 47 49 - ret = i2c_smbus_write_byte_data(stmpe->i2c, reg, val); 48 + ret = stmpe->ci->write_byte(stmpe, reg, val); 50 49 if (ret < 0) 51 - dev_err(stmpe->dev, "failed to write reg %#x: %d\n", 52 - reg, ret); 50 + dev_err(stmpe->dev, "failed to write reg %#x: %d\n", reg, ret); 53 51 54 52 return ret; 55 53 } ··· 72 72 { 73 73 int ret; 74 74 75 - ret = i2c_smbus_read_i2c_block_data(stmpe->i2c, reg, length, values); 75 + ret = stmpe->ci->read_block(stmpe, reg, length, values); 76 76 if (ret < 0) 77 - dev_err(stmpe->dev, "failed to read regs %#x: %d\n", 78 - reg, ret); 77 + dev_err(stmpe->dev, "failed to read regs %#x: %d\n", reg, ret); 79 78 80 79 dev_vdbg(stmpe->dev, "rd: reg %#x (%d) => ret %#x\n", reg, length, ret); 81 80 stmpe_dump_bytes("stmpe rd: ", values, length); ··· 90 91 dev_vdbg(stmpe->dev, "wr: regs %#x (%d)\n", reg, length); 91 92 stmpe_dump_bytes("stmpe wr: ", values, length); 92 93 93 - ret = i2c_smbus_write_i2c_block_data(stmpe->i2c, reg, length, 94 - values); 94 + ret = stmpe->ci->write_block(stmpe, reg, length, values); 95 95 if (ret < 0) 96 - dev_err(stmpe->dev, "failed to write regs %#x: %d\n", 97 - reg, ret); 96 + dev_err(stmpe->dev, "failed to write regs %#x: %d\n", reg, ret); 98 97 99 98 return ret; 100 99 } ··· 242 245 u8 regaddr = stmpe->regs[STMPE_IDX_GPAFR_U_MSB]; 243 246 int af_bits = variant->af_bits; 244 247 int numregs = DIV_ROUND_UP(stmpe->num_gpios * af_bits, 8); 245 - int afperreg = 8 / af_bits; 246 248 int mask = (1 << af_bits) - 1; 247 249 u8 regs[numregs]; 248 - int af; 249 - int ret; 250 + int af, afperreg, ret; 250 251 252 + if (!variant->get_altfunc) 253 + return 0; 254 + 255 + afperreg = 8 / af_bits; 251 256 mutex_lock(&stmpe->lock); 252 257 253 258 ret = __stmpe_enable(stmpe, STMPE_BLOCK_GPIO); ··· 324 325 }; 325 326 326 327 /* 327 - * Touchscreen (STMPE811) 328 + * STMPE801 329 + */ 330 + static const u8 stmpe801_regs[] = { 331 + [STMPE_IDX_CHIP_ID] = STMPE801_REG_CHIP_ID, 332 + [STMPE_IDX_ICR_LSB] = STMPE801_REG_SYS_CTRL, 333 + [STMPE_IDX_GPMR_LSB] = STMPE801_REG_GPIO_MP_STA, 334 + [STMPE_IDX_GPSR_LSB] = STMPE801_REG_GPIO_SET_PIN, 335 + [STMPE_IDX_GPCR_LSB] = STMPE801_REG_GPIO_SET_PIN, 336 + [STMPE_IDX_GPDR_LSB] = STMPE801_REG_GPIO_DIR, 337 + [STMPE_IDX_IEGPIOR_LSB] = STMPE801_REG_GPIO_INT_EN, 338 + [STMPE_IDX_ISGPIOR_MSB] = STMPE801_REG_GPIO_INT_STA, 339 + 340 + }; 341 + 342 + static struct stmpe_variant_block stmpe801_blocks[] = { 343 + { 344 + .cell = &stmpe_gpio_cell, 345 + .irq = 0, 346 + .block = STMPE_BLOCK_GPIO, 347 + }, 348 + }; 349 + 350 + static int stmpe801_enable(struct stmpe *stmpe, unsigned int blocks, 351 + bool enable) 352 + { 353 + if (blocks & STMPE_BLOCK_GPIO) 354 + return 0; 355 + else 356 + return -EINVAL; 357 + } 358 + 359 + static struct stmpe_variant_info stmpe801 = { 360 + .name = "stmpe801", 361 + .id_val = STMPE801_ID, 362 + .id_mask = 0xffff, 363 + .num_gpios = 8, 364 + .regs = stmpe801_regs, 365 + .blocks = stmpe801_blocks, 366 + .num_blocks = ARRAY_SIZE(stmpe801_blocks), 367 + .num_irqs = STMPE801_NR_INTERNAL_IRQS, 368 + .enable = stmpe801_enable, 369 + }; 370 + 371 + /* 372 + * Touchscreen (STMPE811 or STMPE610) 328 373 */ 329 374 330 375 static struct resource stmpe_ts_resources[] = { ··· 393 350 }; 394 351 395 352 /* 396 - * STMPE811 353 + * STMPE811 or STMPE610 397 354 */ 398 355 399 356 static const u8 stmpe811_regs[] = { ··· 455 412 .id_val = 0x0811, 456 413 .id_mask = 0xffff, 457 414 .num_gpios = 8, 415 + .af_bits = 1, 416 + .regs = stmpe811_regs, 417 + .blocks = stmpe811_blocks, 418 + .num_blocks = ARRAY_SIZE(stmpe811_blocks), 419 + .num_irqs = STMPE811_NR_INTERNAL_IRQS, 420 + .enable = stmpe811_enable, 421 + .get_altfunc = stmpe811_get_altfunc, 422 + }; 423 + 424 + /* Similar to 811, except number of gpios */ 425 + static struct stmpe_variant_info stmpe610 = { 426 + .name = "stmpe610", 427 + .id_val = 0x0811, 428 + .id_mask = 0xffff, 429 + .num_gpios = 6, 458 430 .af_bits = 1, 459 431 .regs = stmpe811_regs, 460 432 .blocks = stmpe811_blocks, ··· 713 655 }; 714 656 715 657 static struct stmpe_variant_info *stmpe_variant_info[] = { 658 + [STMPE610] = &stmpe610, 659 + [STMPE801] = &stmpe801, 716 660 [STMPE811] = &stmpe811, 717 661 [STMPE1601] = &stmpe1601, 718 662 [STMPE2401] = &stmpe2401, ··· 730 670 u8 isr[num]; 731 671 int ret; 732 672 int i; 673 + 674 + if (variant->id_val == STMPE801_ID) { 675 + handle_nested_irq(stmpe->irq_base); 676 + return IRQ_HANDLED; 677 + } 733 678 734 679 ret = stmpe_block_read(stmpe, israddr, num, isr); 735 680 if (ret < 0) ··· 822 757 823 758 static int __devinit stmpe_irq_init(struct stmpe *stmpe) 824 759 { 760 + struct irq_chip *chip = NULL; 825 761 int num_irqs = stmpe->variant->num_irqs; 826 762 int base = stmpe->irq_base; 827 763 int irq; 828 764 765 + if (stmpe->variant->id_val != STMPE801_ID) 766 + chip = &stmpe_irq_chip; 767 + 829 768 for (irq = base; irq < base + num_irqs; irq++) { 830 769 irq_set_chip_data(irq, stmpe); 831 - irq_set_chip_and_handler(irq, &stmpe_irq_chip, 832 - handle_edge_irq); 770 + irq_set_chip_and_handler(irq, chip, handle_edge_irq); 833 771 irq_set_nested_thread(irq, 1); 834 772 #ifdef CONFIG_ARM 835 773 set_irq_flags(irq, IRQF_VALID); ··· 864 796 unsigned int irq_trigger = stmpe->pdata->irq_trigger; 865 797 int autosleep_timeout = stmpe->pdata->autosleep_timeout; 866 798 struct stmpe_variant_info *variant = stmpe->variant; 867 - u8 icr = STMPE_ICR_LSB_GIM; 799 + u8 icr; 868 800 unsigned int id; 869 801 u8 data[2]; 870 802 int ret; ··· 887 819 if (ret) 888 820 return ret; 889 821 890 - if (irq_trigger == IRQF_TRIGGER_FALLING || 891 - irq_trigger == IRQF_TRIGGER_RISING) 892 - icr |= STMPE_ICR_LSB_EDGE; 822 + if (id == STMPE801_ID) 823 + icr = STMPE801_REG_SYS_CTRL_INT_EN; 824 + else 825 + icr = STMPE_ICR_LSB_GIM; 826 + 827 + /* STMPE801 doesn't support Edge interrupts */ 828 + if (id != STMPE801_ID) { 829 + if (irq_trigger == IRQF_TRIGGER_FALLING || 830 + irq_trigger == IRQF_TRIGGER_RISING) 831 + icr |= STMPE_ICR_LSB_EDGE; 832 + } 893 833 894 834 if (irq_trigger == IRQF_TRIGGER_RISING || 895 - irq_trigger == IRQF_TRIGGER_HIGH) 896 - icr |= STMPE_ICR_LSB_HIGH; 835 + irq_trigger == IRQF_TRIGGER_HIGH) { 836 + if (id == STMPE801_ID) 837 + icr |= STMPE801_REG_SYS_CTRL_INT_HI; 838 + else 839 + icr |= STMPE_ICR_LSB_HIGH; 840 + } 897 841 898 - if (stmpe->pdata->irq_invert_polarity) 899 - icr ^= STMPE_ICR_LSB_HIGH; 842 + if (stmpe->pdata->irq_invert_polarity) { 843 + if (id == STMPE801_ID) 844 + icr ^= STMPE801_REG_SYS_CTRL_INT_HI; 845 + else 846 + icr ^= STMPE_ICR_LSB_HIGH; 847 + } 900 848 901 849 if (stmpe->pdata->autosleep) { 902 850 ret = stmpe_autosleep(stmpe, autosleep_timeout); ··· 957 873 return ret; 958 874 } 959 875 960 - #ifdef CONFIG_PM 961 - static int stmpe_suspend(struct device *dev) 876 + /* Called from client specific probe routines */ 877 + int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum) 962 878 { 963 - struct i2c_client *i2c = to_i2c_client(dev); 964 - 965 - if (device_may_wakeup(&i2c->dev)) 966 - enable_irq_wake(i2c->irq); 967 - 968 - return 0; 969 - } 970 - 971 - static int stmpe_resume(struct device *dev) 972 - { 973 - struct i2c_client *i2c = to_i2c_client(dev); 974 - 975 - if (device_may_wakeup(&i2c->dev)) 976 - disable_irq_wake(i2c->irq); 977 - 978 - return 0; 979 - } 980 - #endif 981 - 982 - static int __devinit stmpe_probe(struct i2c_client *i2c, 983 - const struct i2c_device_id *id) 984 - { 985 - struct stmpe_platform_data *pdata = i2c->dev.platform_data; 879 + struct stmpe_platform_data *pdata = dev_get_platdata(ci->dev); 986 880 struct stmpe *stmpe; 987 881 int ret; 988 882 ··· 974 912 mutex_init(&stmpe->irq_lock); 975 913 mutex_init(&stmpe->lock); 976 914 977 - stmpe->dev = &i2c->dev; 978 - stmpe->i2c = i2c; 979 - 915 + stmpe->dev = ci->dev; 916 + stmpe->client = ci->client; 980 917 stmpe->pdata = pdata; 981 918 stmpe->irq_base = pdata->irq_base; 982 - 983 - stmpe->partnum = id->driver_data; 984 - stmpe->variant = stmpe_variant_info[stmpe->partnum]; 919 + stmpe->ci = ci; 920 + stmpe->partnum = partnum; 921 + stmpe->variant = stmpe_variant_info[partnum]; 985 922 stmpe->regs = stmpe->variant->regs; 986 923 stmpe->num_gpios = stmpe->variant->num_gpios; 924 + dev_set_drvdata(stmpe->dev, stmpe); 987 925 988 - i2c_set_clientdata(i2c, stmpe); 926 + if (ci->init) 927 + ci->init(stmpe); 928 + 929 + if (pdata->irq_over_gpio) { 930 + ret = gpio_request_one(pdata->irq_gpio, GPIOF_DIR_IN, "stmpe"); 931 + if (ret) { 932 + dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n", 933 + ret); 934 + goto out_free; 935 + } 936 + 937 + stmpe->irq = gpio_to_irq(pdata->irq_gpio); 938 + } else { 939 + stmpe->irq = ci->irq; 940 + } 989 941 990 942 ret = stmpe_chip_init(stmpe); 991 943 if (ret) 992 - goto out_free; 944 + goto free_gpio; 993 945 994 946 ret = stmpe_irq_init(stmpe); 995 947 if (ret) 996 - goto out_free; 948 + goto free_gpio; 997 949 998 - ret = request_threaded_irq(stmpe->i2c->irq, NULL, stmpe_irq, 999 - pdata->irq_trigger | IRQF_ONESHOT, 1000 - "stmpe", stmpe); 950 + ret = request_threaded_irq(stmpe->irq, NULL, stmpe_irq, 951 + pdata->irq_trigger | IRQF_ONESHOT, "stmpe", stmpe); 1001 952 if (ret) { 1002 953 dev_err(stmpe->dev, "failed to request IRQ: %d\n", ret); 1003 954 goto out_removeirq; ··· 1026 951 1027 952 out_removedevs: 1028 953 mfd_remove_devices(stmpe->dev); 1029 - free_irq(stmpe->i2c->irq, stmpe); 954 + free_irq(stmpe->irq, stmpe); 1030 955 out_removeirq: 1031 956 stmpe_irq_remove(stmpe); 957 + free_gpio: 958 + if (pdata->irq_over_gpio) 959 + gpio_free(pdata->irq_gpio); 1032 960 out_free: 1033 961 kfree(stmpe); 1034 962 return ret; 1035 963 } 1036 964 1037 - static int __devexit stmpe_remove(struct i2c_client *client) 965 + int stmpe_remove(struct stmpe *stmpe) 1038 966 { 1039 - struct stmpe *stmpe = i2c_get_clientdata(client); 1040 - 1041 967 mfd_remove_devices(stmpe->dev); 1042 968 1043 - free_irq(stmpe->i2c->irq, stmpe); 969 + free_irq(stmpe->irq, stmpe); 1044 970 stmpe_irq_remove(stmpe); 971 + 972 + if (stmpe->pdata->irq_over_gpio) 973 + gpio_free(stmpe->pdata->irq_gpio); 1045 974 1046 975 kfree(stmpe); 1047 976 1048 977 return 0; 1049 978 } 1050 979 1051 - static const struct i2c_device_id stmpe_id[] = { 1052 - { "stmpe811", STMPE811 }, 1053 - { "stmpe1601", STMPE1601 }, 1054 - { "stmpe2401", STMPE2401 }, 1055 - { "stmpe2403", STMPE2403 }, 1056 - { } 1057 - }; 1058 - MODULE_DEVICE_TABLE(i2c, stmpe_id); 1059 - 1060 980 #ifdef CONFIG_PM 1061 - static const struct dev_pm_ops stmpe_dev_pm_ops = { 981 + static int stmpe_suspend(struct device *dev) 982 + { 983 + struct stmpe *stmpe = dev_get_drvdata(dev); 984 + 985 + if (device_may_wakeup(dev)) 986 + enable_irq_wake(stmpe->irq); 987 + 988 + return 0; 989 + } 990 + 991 + static int stmpe_resume(struct device *dev) 992 + { 993 + struct stmpe *stmpe = dev_get_drvdata(dev); 994 + 995 + if (device_may_wakeup(dev)) 996 + disable_irq_wake(stmpe->irq); 997 + 998 + return 0; 999 + } 1000 + 1001 + const struct dev_pm_ops stmpe_dev_pm_ops = { 1062 1002 .suspend = stmpe_suspend, 1063 1003 .resume = stmpe_resume, 1064 1004 }; 1065 1005 #endif 1066 - 1067 - static struct i2c_driver stmpe_driver = { 1068 - .driver.name = "stmpe", 1069 - .driver.owner = THIS_MODULE, 1070 - #ifdef CONFIG_PM 1071 - .driver.pm = &stmpe_dev_pm_ops, 1072 - #endif 1073 - .probe = stmpe_probe, 1074 - .remove = __devexit_p(stmpe_remove), 1075 - .id_table = stmpe_id, 1076 - }; 1077 - 1078 - static int __init stmpe_init(void) 1079 - { 1080 - return i2c_add_driver(&stmpe_driver); 1081 - } 1082 - subsys_initcall(stmpe_init); 1083 - 1084 - static void __exit stmpe_exit(void) 1085 - { 1086 - i2c_del_driver(&stmpe_driver); 1087 - } 1088 - module_exit(stmpe_exit); 1089 - 1090 - MODULE_LICENSE("GPL v2"); 1091 - MODULE_DESCRIPTION("STMPE MFD core driver"); 1092 - MODULE_AUTHOR("Rabin Vincent <rabin.vincent@stericsson.com>");
+53
drivers/mfd/stmpe.h
··· 8 8 #ifndef __STMPE_H 9 9 #define __STMPE_H 10 10 11 + #include <linux/device.h> 12 + #include <linux/mfd/core.h> 13 + #include <linux/mfd/stmpe.h> 14 + #include <linux/printk.h> 15 + #include <linux/types.h> 16 + 17 + extern const struct dev_pm_ops stmpe_dev_pm_ops; 18 + 11 19 #ifdef STMPE_DUMP_BYTES 12 20 static inline void stmpe_dump_bytes(const char *str, const void *buf, 13 21 size_t len) ··· 75 67 int (*enable_autosleep)(struct stmpe *stmpe, int autosleep_timeout); 76 68 }; 77 69 70 + /** 71 + * struct stmpe_client_info - i2c or spi specific routines/info 72 + * @data: client specific data 73 + * @read_byte: read single byte 74 + * @write_byte: write single byte 75 + * @read_block: read block or multiple bytes 76 + * @write_block: write block or multiple bytes 77 + * @init: client init routine, called during probe 78 + */ 79 + struct stmpe_client_info { 80 + void *data; 81 + int irq; 82 + void *client; 83 + struct device *dev; 84 + int (*read_byte)(struct stmpe *stmpe, u8 reg); 85 + int (*write_byte)(struct stmpe *stmpe, u8 reg, u8 val); 86 + int (*read_block)(struct stmpe *stmpe, u8 reg, u8 len, u8 *values); 87 + int (*write_block)(struct stmpe *stmpe, u8 reg, u8 len, 88 + const u8 *values); 89 + void (*init)(struct stmpe *stmpe); 90 + }; 91 + 92 + int stmpe_probe(struct stmpe_client_info *ci, int partnum); 93 + int stmpe_remove(struct stmpe *stmpe); 94 + 78 95 #define STMPE_ICR_LSB_HIGH (1 << 2) 79 96 #define STMPE_ICR_LSB_EDGE (1 << 1) 80 97 #define STMPE_ICR_LSB_GIM (1 << 0) 98 + 99 + /* 100 + * STMPE801 101 + */ 102 + #define STMPE801_ID 0x0108 103 + #define STMPE801_NR_INTERNAL_IRQS 1 104 + 105 + #define STMPE801_REG_CHIP_ID 0x00 106 + #define STMPE801_REG_VERSION_ID 0x02 107 + #define STMPE801_REG_SYS_CTRL 0x04 108 + #define STMPE801_REG_GPIO_INT_EN 0x08 109 + #define STMPE801_REG_GPIO_INT_STA 0x09 110 + #define STMPE801_REG_GPIO_MP_STA 0x10 111 + #define STMPE801_REG_GPIO_SET_PIN 0x11 112 + #define STMPE801_REG_GPIO_DIR 0x12 113 + 114 + #define STMPE801_REG_SYS_CTRL_RESET (1 << 7) 115 + #define STMPE801_REG_SYS_CTRL_INT_EN (1 << 2) 116 + #define STMPE801_REG_SYS_CTRL_INT_HI (1 << 0) 81 117 82 118 /* 83 119 * STMPE811 ··· 139 87 140 88 #define STMPE811_REG_CHIP_ID 0x00 141 89 #define STMPE811_REG_SYS_CTRL2 0x04 90 + #define STMPE811_REG_SPI_CFG 0x08 142 91 #define STMPE811_REG_INT_CTRL 0x09 143 92 #define STMPE811_REG_INT_EN 0x0A 144 93 #define STMPE811_REG_INT_STA 0x0B
+1 -15
drivers/mfd/t7l66xb.c
··· 442 442 443 443 /*--------------------------------------------------------------------------*/ 444 444 445 - static int __init t7l66xb_init(void) 446 - { 447 - int retval = 0; 448 - 449 - retval = platform_driver_register(&t7l66xb_platform_driver); 450 - return retval; 451 - } 452 - 453 - static void __exit t7l66xb_exit(void) 454 - { 455 - platform_driver_unregister(&t7l66xb_platform_driver); 456 - } 457 - 458 - module_init(t7l66xb_init); 459 - module_exit(t7l66xb_exit); 445 + module_platform_driver(t7l66xb_platform_driver); 460 446 461 447 MODULE_DESCRIPTION("Toshiba T7L66XB core driver"); 462 448 MODULE_LICENSE("GPL v2");
+1 -13
drivers/mfd/tc6387xb.c
··· 234 234 .resume = tc6387xb_resume, 235 235 }; 236 236 237 - 238 - static int __init tc6387xb_init(void) 239 - { 240 - return platform_driver_register(&tc6387xb_platform_driver); 241 - } 242 - 243 - static void __exit tc6387xb_exit(void) 244 - { 245 - platform_driver_unregister(&tc6387xb_platform_driver); 246 - } 247 - 248 - module_init(tc6387xb_init); 249 - module_exit(tc6387xb_exit); 237 + module_platform_driver(tc6387xb_platform_driver); 250 238 251 239 MODULE_DESCRIPTION("Toshiba TC6387XB core driver"); 252 240 MODULE_LICENSE("GPL v2");
+1 -11
drivers/mfd/ti-ssp.c
··· 458 458 } 459 459 }; 460 460 461 - static int __init ti_ssp_init(void) 462 - { 463 - return platform_driver_register(&ti_ssp_driver); 464 - } 465 - module_init(ti_ssp_init); 466 - 467 - static void __exit ti_ssp_exit(void) 468 - { 469 - platform_driver_unregister(&ti_ssp_driver); 470 - } 471 - module_exit(ti_ssp_exit); 461 + module_platform_driver(ti_ssp_driver); 472 462 473 463 MODULE_DESCRIPTION("Sequencer Serial Port (SSP) Driver"); 474 464 MODULE_AUTHOR("Cyril Chemparathy");
+1 -1
drivers/mfd/timberdale.c
··· 857 857 kfree(priv); 858 858 } 859 859 860 - static struct pci_device_id timberdale_pci_tbl[] = { 860 + static DEFINE_PCI_DEVICE_TABLE(timberdale_pci_tbl) = { 861 861 { PCI_DEVICE(PCI_VENDOR_ID_TIMB, PCI_DEVICE_ID_TIMB) }, 862 862 { 0 } 863 863 };
+2 -1
drivers/mfd/tps65910-irq.c
··· 215 215 216 216 int tps65910_irq_exit(struct tps65910 *tps65910) 217 217 { 218 - free_irq(tps65910->chip_irq, tps65910); 218 + if (tps65910->chip_irq) 219 + free_irq(tps65910->chip_irq, tps65910); 219 220 return 0; 220 221 }
+2 -5
drivers/mfd/tps65910.c
··· 172 172 173 173 tps65910_gpio_init(tps65910, pmic_plat_data->gpio_base); 174 174 175 - ret = tps65910_irq_init(tps65910, init_data->irq, init_data); 176 - if (ret < 0) 177 - goto err; 175 + tps65910_irq_init(tps65910, init_data->irq, init_data); 178 176 179 177 kfree(init_data); 180 178 return ret; 181 179 182 180 err: 183 - mfd_remove_devices(tps65910->dev); 184 181 kfree(tps65910); 185 182 kfree(init_data); 186 183 return ret; ··· 187 190 { 188 191 struct tps65910 *tps65910 = i2c_get_clientdata(i2c); 189 192 190 - mfd_remove_devices(tps65910->dev); 191 193 tps65910_irq_exit(tps65910); 194 + mfd_remove_devices(tps65910->dev); 192 195 kfree(tps65910); 193 196 194 197 return 0;
-1
drivers/mfd/tps65912-spi.c
··· 111 111 static struct spi_driver tps65912_spi_driver = { 112 112 .driver = { 113 113 .name = "tps65912", 114 - .bus = &spi_bus_type, 115 114 .owner = THIS_MODULE, 116 115 }, 117 116 .probe = tps65912_spi_probe,
+50 -1
drivers/mfd/twl-core.c
··· 34 34 #include <linux/platform_device.h> 35 35 #include <linux/clk.h> 36 36 #include <linux/err.h> 37 + #include <linux/device.h> 38 + #include <linux/of.h> 39 + #include <linux/of_irq.h> 40 + #include <linux/of_platform.h> 41 + #include <linux/irqdomain.h> 37 42 38 43 #include <linux/regulator/machine.h> 39 44 ··· 148 143 #define SUB_CHIP_ID3 3 149 144 150 145 #define TWL_MODULE_LAST TWL4030_MODULE_LAST 146 + 147 + #define TWL4030_NR_IRQS 8 148 + #define TWL6030_NR_IRQS 20 151 149 152 150 /* Base Address defns for twl4030_map[] */ 153 151 ··· 263 255 264 256 static struct twl_client twl_modules[TWL_NUM_SLAVES]; 265 257 258 + static struct irq_domain domain; 266 259 267 260 /* mapping the module id to slave id and base address */ 268 261 struct twl_mapping { ··· 1192 1183 int status; 1193 1184 unsigned i; 1194 1185 struct twl4030_platform_data *pdata = client->dev.platform_data; 1186 + struct device_node *node = client->dev.of_node; 1195 1187 u8 temp; 1196 1188 int ret = 0; 1189 + int nr_irqs = TWL4030_NR_IRQS; 1190 + 1191 + if ((id->driver_data) & TWL6030_CLASS) 1192 + nr_irqs = TWL6030_NR_IRQS; 1193 + 1194 + if (node && !pdata) { 1195 + /* 1196 + * XXX: Temporary pdata until the information is correctly 1197 + * retrieved by every TWL modules from DT. 1198 + */ 1199 + pdata = devm_kzalloc(&client->dev, 1200 + sizeof(struct twl4030_platform_data), 1201 + GFP_KERNEL); 1202 + if (!pdata) 1203 + return -ENOMEM; 1204 + } 1197 1205 1198 1206 if (!pdata) { 1199 1207 dev_dbg(&client->dev, "no platform data?\n"); 1200 1208 return -EINVAL; 1201 1209 } 1210 + 1211 + status = irq_alloc_descs(-1, pdata->irq_base, nr_irqs, 0); 1212 + if (IS_ERR_VALUE(status)) { 1213 + dev_err(&client->dev, "Fail to allocate IRQ descs\n"); 1214 + return status; 1215 + } 1216 + 1217 + pdata->irq_base = status; 1218 + pdata->irq_end = pdata->irq_base + nr_irqs; 1219 + 1220 + domain.irq_base = pdata->irq_base; 1221 + domain.nr_irq = nr_irqs; 1222 + #ifdef CONFIG_OF_IRQ 1223 + domain.of_node = of_node_get(node); 1224 + domain.ops = &irq_domain_simple_ops; 1225 + #endif 1226 + irq_domain_add(&domain); 1202 1227 1203 1228 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) { 1204 1229 dev_dbg(&client->dev, "can't talk I2C?\n"); ··· 1313 1270 twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1); 1314 1271 } 1315 1272 1316 - status = add_children(pdata, id->driver_data); 1273 + #ifdef CONFIG_OF_DEVICE 1274 + if (node) 1275 + status = of_platform_populate(node, NULL, NULL, &client->dev); 1276 + else 1277 + #endif 1278 + status = add_children(pdata, id->driver_data); 1279 + 1317 1280 fail: 1318 1281 if (status < 0) 1319 1282 twl_remove(client);
+1 -11
drivers/mfd/twl4030-audio.c
··· 261 261 }, 262 262 }; 263 263 264 - static int __devinit twl4030_audio_init(void) 265 - { 266 - return platform_driver_register(&twl4030_audio_driver); 267 - } 268 - module_init(twl4030_audio_init); 269 - 270 - static void __devexit twl4030_audio_exit(void) 271 - { 272 - platform_driver_unregister(&twl4030_audio_driver); 273 - } 274 - module_exit(twl4030_audio_exit); 264 + module_platform_driver(twl4030_audio_driver); 275 265 276 266 MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>"); 277 267 MODULE_LICENSE("GPL");
+2 -1
drivers/mfd/twl4030-irq.c
··· 492 492 u8 bytes[4]; 493 493 } imr; 494 494 495 - /* byte[0] gets overwriten as we write ... */ 495 + /* byte[0] gets overwritten as we write ... */ 496 496 imr.word = cpu_to_le32(agent->imr << 8); 497 497 agent->imr_change_pending = false; 498 498 ··· 667 667 irq_set_chip_data(irq, agent); 668 668 irq_set_chip_and_handler(irq, &twl4030_sih_irq_chip, 669 669 handle_edge_irq); 670 + irq_set_nested_thread(irq, 1); 670 671 activate_irq(irq); 671 672 } 672 673
+1 -13
drivers/mfd/twl4030-madc.c
··· 807 807 }, 808 808 }; 809 809 810 - static int __init twl4030_madc_init(void) 811 - { 812 - return platform_driver_register(&twl4030_madc_driver); 813 - } 814 - 815 - module_init(twl4030_madc_init); 816 - 817 - static void __exit twl4030_madc_exit(void) 818 - { 819 - platform_driver_unregister(&twl4030_madc_driver); 820 - } 821 - 822 - module_exit(twl4030_madc_exit); 810 + module_platform_driver(twl4030_madc_driver); 823 811 824 812 MODULE_DESCRIPTION("TWL4030 ADC driver"); 825 813 MODULE_LICENSE("GPL");
+40 -2
drivers/mfd/twl4030-power.c
··· 34 34 static u8 twl4030_start_script_address = 0x2b; 35 35 36 36 #define PWR_P1_SW_EVENTS 0x10 37 - #define PWR_DEVOFF (1<<0) 37 + #define PWR_DEVOFF (1 << 0) 38 + #define SEQ_OFFSYNC (1 << 0) 38 39 39 40 #define PHY_TO_OFF_PM_MASTER(p) (p - 0x36) 40 41 #define PHY_TO_OFF_PM_RECEIVER(p) (p - 0x5b) ··· 512 511 return err; 513 512 } 514 513 514 + /* 515 + * In master mode, start the power off sequence. 516 + * After a successful execution, TWL shuts down the power to the SoC 517 + * and all peripherals connected to it. 518 + */ 519 + void twl4030_power_off(void) 520 + { 521 + int err; 522 + 523 + err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, PWR_DEVOFF, 524 + TWL4030_PM_MASTER_P1_SW_EVENTS); 525 + if (err) 526 + pr_err("TWL4030 Unable to power off\n"); 527 + } 528 + 515 529 void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts) 516 530 { 517 531 int err = 0; 518 532 int i; 519 533 struct twl4030_resconfig *resconfig; 520 - u8 address = twl4030_start_script_address; 534 + u8 val, address = twl4030_start_script_address; 521 535 522 536 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 523 537 TWL4030_PM_MASTER_KEY_CFG1, ··· 564 548 } 565 549 } 566 550 551 + /* Board has to be wired properly to use this feature */ 552 + if (twl4030_scripts->use_poweroff && !pm_power_off) { 553 + /* Default for SEQ_OFFSYNC is set, lets ensure this */ 554 + err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &val, 555 + TWL4030_PM_MASTER_CFG_P123_TRANSITION); 556 + if (err) { 557 + pr_warning("TWL4030 Unable to read registers\n"); 558 + 559 + } else if (!(val & SEQ_OFFSYNC)) { 560 + val |= SEQ_OFFSYNC; 561 + err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, val, 562 + TWL4030_PM_MASTER_CFG_P123_TRANSITION); 563 + if (err) { 564 + pr_err("TWL4030 Unable to setup SEQ_OFFSYNC\n"); 565 + goto relock; 566 + } 567 + } 568 + 569 + pm_power_off = twl4030_power_off; 570 + } 571 + 572 + relock: 567 573 err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, 568 574 TWL4030_PM_MASTER_PROTECT_KEY); 569 575 if (err)
+3 -17
drivers/mfd/twl6040-core.c
··· 509 509 twl6040->audpwron = -EINVAL; 510 510 511 511 if (gpio_is_valid(twl6040->audpwron)) { 512 - ret = gpio_request(twl6040->audpwron, "audpwron"); 512 + ret = gpio_request_one(twl6040->audpwron, GPIOF_OUT_INIT_LOW, 513 + "audpwron"); 513 514 if (ret) 514 515 goto gpio1_err; 515 - 516 - ret = gpio_direction_output(twl6040->audpwron, 0); 517 - if (ret) 518 - goto gpio2_err; 519 516 } 520 517 521 518 /* codec interrupt */ ··· 616 619 }, 617 620 }; 618 621 619 - static int __devinit twl6040_init(void) 620 - { 621 - return platform_driver_register(&twl6040_driver); 622 - } 623 - module_init(twl6040_init); 624 - 625 - static void __devexit twl6040_exit(void) 626 - { 627 - platform_driver_unregister(&twl6040_driver); 628 - } 629 - 630 - module_exit(twl6040_exit); 622 + module_platform_driver(twl6040_driver); 631 623 632 624 MODULE_DESCRIPTION("TWL6040 MFD"); 633 625 MODULE_AUTHOR("Misael Lopez Cruz <misael.lopez@ti.com>");
+37 -11
drivers/mfd/ucb1x00-core.c
··· 36 36 static LIST_HEAD(ucb1x00_drivers); 37 37 static LIST_HEAD(ucb1x00_devices); 38 38 39 + static struct mcp_device_id ucb1x00_id[] = { 40 + { "ucb1x00", 0 }, /* auto-detection */ 41 + { "ucb1200", UCB_ID_1200 }, 42 + { "ucb1300", UCB_ID_1300 }, 43 + { "tc35143", UCB_ID_TC35143 }, 44 + { } 45 + }; 46 + MODULE_DEVICE_TABLE(mcp, ucb1x00_id); 47 + 39 48 /** 40 49 * ucb1x00_io_set_dir - set IO direction 41 50 * @ucb: UCB1x00 structure describing chip ··· 536 527 537 528 static int ucb1x00_probe(struct mcp *mcp) 538 529 { 530 + const struct mcp_device_id *mid; 539 531 struct ucb1x00 *ucb; 540 532 struct ucb1x00_driver *drv; 533 + struct ucb1x00_plat_data *pdata; 541 534 unsigned int id; 542 535 int ret = -ENODEV; 543 536 int temp; 544 537 545 538 mcp_enable(mcp); 546 539 id = mcp_reg_read(mcp, UCB_ID); 540 + mid = mcp_get_device_id(mcp); 547 541 548 - if (id != UCB_ID_1200 && id != UCB_ID_1300 && id != UCB_ID_TC35143) { 549 - printk(KERN_WARNING "UCB1x00 ID not found: %04x\n", id); 542 + if (mid && mid->driver_data) { 543 + if (id != mid->driver_data) { 544 + printk(KERN_WARNING "%s wrong ID %04x found: %04x\n", 545 + mid->name, (unsigned int) mid->driver_data, id); 546 + goto err_disable; 547 + } 548 + } else { 549 + mid = &ucb1x00_id[1]; 550 + while (mid->driver_data) { 551 + if (id == mid->driver_data) 552 + break; 553 + mid++; 554 + } 555 + printk(KERN_WARNING "%s ID not found: %04x\n", 556 + ucb1x00_id[0].name, id); 550 557 goto err_disable; 551 558 } 552 559 ··· 571 546 if (!ucb) 572 547 goto err_disable; 573 548 574 - 549 + pdata = mcp->attached_device.platform_data; 575 550 ucb->dev.class = &ucb1x00_class; 576 551 ucb->dev.parent = &mcp->attached_device; 577 - dev_set_name(&ucb->dev, "ucb1x00"); 552 + dev_set_name(&ucb->dev, mid->name); 578 553 579 554 spin_lock_init(&ucb->lock); 580 555 spin_lock_init(&ucb->io_lock); 581 556 sema_init(&ucb->adc_sem, 1); 582 557 583 - ucb->id = id; 558 + ucb->id = mid; 584 559 ucb->mcp = mcp; 585 560 ucb->irq = ucb1x00_detect_irq(ucb); 586 561 if (ucb->irq == NO_IRQ) { 587 - printk(KERN_ERR "UCB1x00: IRQ probe failed\n"); 562 + printk(KERN_ERR "%s: IRQ probe failed\n", mid->name); 588 563 ret = -ENODEV; 589 564 goto err_free; 590 565 } 591 566 592 567 ucb->gpio.base = -1; 593 - if (mcp->gpio_base != 0) { 568 + if (pdata && (pdata->gpio_base >= 0)) { 594 569 ucb->gpio.label = dev_name(&ucb->dev); 595 - ucb->gpio.base = mcp->gpio_base; 570 + ucb->gpio.base = pdata->gpio_base; 596 571 ucb->gpio.ngpio = 10; 597 572 ucb->gpio.set = ucb1x00_gpio_set; 598 573 ucb->gpio.get = ucb1x00_gpio_get; ··· 605 580 dev_info(&ucb->dev, "gpio_base not set so no gpiolib support"); 606 581 607 582 ret = request_irq(ucb->irq, ucb1x00_irq, IRQF_TRIGGER_RISING, 608 - "UCB1x00", ucb); 583 + mid->name, ucb); 609 584 if (ret) { 610 - printk(KERN_ERR "ucb1x00: unable to grab irq%d: %d\n", 611 - ucb->irq, ret); 585 + printk(KERN_ERR "%s: unable to grab irq%d: %d\n", 586 + mid->name, ucb->irq, ret); 612 587 goto err_gpio; 613 588 } 614 589 ··· 730 705 .remove = ucb1x00_remove, 731 706 .suspend = ucb1x00_suspend, 732 707 .resume = ucb1x00_resume, 708 + .id_table = ucb1x00_id, 733 709 }; 734 710 735 711 static int __init ucb1x00_init(void)
+1 -1
drivers/mfd/ucb1x00-ts.c
··· 382 382 ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC; 383 383 384 384 idev->name = "Touchscreen panel"; 385 - idev->id.product = ts->ucb->id; 385 + idev->id.product = ts->ucb->id->driver_data; 386 386 idev->open = ucb1x00_ts_open; 387 387 idev->close = ucb1x00_ts_close; 388 388
+1 -1
drivers/mfd/vx855.c
··· 118 118 pci_disable_device(pdev); 119 119 } 120 120 121 - static struct pci_device_id vx855_pci_tbl[] = { 121 + static DEFINE_PCI_DEVICE_TABLE(vx855_pci_tbl) = { 122 122 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) }, 123 123 { 0, } 124 124 };
+2 -2
drivers/mfd/wm831x-core.c
··· 559 559 dev_vdbg(wm831x->dev, "Write %04x to R%d(0x%x)\n", 560 560 buf[i], reg + i, reg + i); 561 561 ret = regmap_write(wm831x->regmap, reg + i, buf[i]); 562 + if (ret != 0) 563 + return ret; 562 564 } 563 565 564 566 return 0; ··· 1877 1875 err_regmap: 1878 1876 mfd_remove_devices(wm831x->dev); 1879 1877 regmap_exit(wm831x->regmap); 1880 - kfree(wm831x); 1881 1878 return ret; 1882 1879 } 1883 1880 ··· 1888 1887 free_irq(wm831x->irq_base + WM831X_IRQ_AUXADC_DATA, wm831x); 1889 1888 wm831x_irq_exit(wm831x); 1890 1889 regmap_exit(wm831x->regmap); 1891 - kfree(wm831x); 1892 1890 } 1893 1891 1894 1892 int wm831x_device_suspend(struct wm831x *wm831x)
+1 -2
drivers/mfd/wm831x-i2c.c
··· 30 30 struct wm831x *wm831x; 31 31 int ret; 32 32 33 - wm831x = kzalloc(sizeof(struct wm831x), GFP_KERNEL); 33 + wm831x = devm_kzalloc(&i2c->dev, sizeof(struct wm831x), GFP_KERNEL); 34 34 if (wm831x == NULL) 35 35 return -ENOMEM; 36 36 ··· 42 42 ret = PTR_ERR(wm831x->regmap); 43 43 dev_err(wm831x->dev, "Failed to allocate register map: %d\n", 44 44 ret); 45 - kfree(wm831x); 46 45 return ret; 47 46 } 48 47
+1 -7
drivers/mfd/wm831x-irq.c
··· 325 325 return WM831X_INTERRUPT_STATUS_1 - 1 + irq_data->reg; 326 326 } 327 327 328 - static inline int irq_data_to_mask_reg(struct wm831x_irq_data *irq_data) 329 - { 330 - return WM831X_INTERRUPT_STATUS_1_MASK - 1 + irq_data->reg; 331 - } 332 - 333 328 static inline struct wm831x_irq_data *irq_to_wm831x_irq(struct wm831x *wm831x, 334 329 int irq) 335 330 { ··· 472 477 handle_nested_irq(wm831x->irq_base + WM831X_IRQ_TCHPD); 473 478 if (primary & WM831X_TCHDATA_INT) 474 479 handle_nested_irq(wm831x->irq_base + WM831X_IRQ_TCHDATA); 475 - if (primary & (WM831X_TCHDATA_EINT | WM831X_TCHPD_EINT)) 476 - goto out; 480 + primary &= ~(WM831X_TCHDATA_EINT | WM831X_TCHPD_EINT); 477 481 478 482 for (i = 0; i < ARRAY_SIZE(wm831x_irqs); i++) { 479 483 int offset = wm831x_irqs[i].reg - 1;
+1 -3
drivers/mfd/wm831x-spi.c
··· 30 30 31 31 type = (enum wm831x_parent)id->driver_data; 32 32 33 - wm831x = kzalloc(sizeof(struct wm831x), GFP_KERNEL); 33 + wm831x = devm_kzalloc(&spi->dev, sizeof(struct wm831x), GFP_KERNEL); 34 34 if (wm831x == NULL) 35 35 return -ENOMEM; 36 36 ··· 45 45 ret = PTR_ERR(wm831x->regmap); 46 46 dev_err(wm831x->dev, "Failed to allocate register map: %d\n", 47 47 ret); 48 - kfree(wm831x); 49 48 return ret; 50 49 } 51 50 ··· 94 95 static struct spi_driver wm831x_spi_driver = { 95 96 .driver = { 96 97 .name = "wm831x", 97 - .bus = &spi_bus_type, 98 98 .owner = THIS_MODULE, 99 99 .pm = &wm831x_spi_pm, 100 100 },
+2
drivers/mfd/wm8350-core.c
··· 573 573 u16 id1, id2, mask_rev; 574 574 u16 cust_id, mode, chip_rev; 575 575 576 + dev_set_drvdata(wm8350->dev, wm8350); 577 + 576 578 /* get WM8350 revision and config mode */ 577 579 ret = wm8350->read_dev(wm8350, WM8350_RESET_ID, sizeof(id1), &id1); 578 580 if (ret != 0) {
+1 -3
drivers/mfd/wm8350-i2c.c
··· 63 63 struct wm8350 *wm8350; 64 64 int ret = 0; 65 65 66 - wm8350 = kzalloc(sizeof(struct wm8350), GFP_KERNEL); 66 + wm8350 = devm_kzalloc(&i2c->dev, sizeof(struct wm8350), GFP_KERNEL); 67 67 if (wm8350 == NULL) 68 68 return -ENOMEM; 69 69 ··· 80 80 return ret; 81 81 82 82 err: 83 - kfree(wm8350); 84 83 return ret; 85 84 } 86 85 ··· 88 89 struct wm8350 *wm8350 = i2c_get_clientdata(i2c); 89 90 90 91 wm8350_device_exit(wm8350); 91 - kfree(wm8350); 92 92 93 93 return 0; 94 94 }
+2 -5
drivers/mfd/wm8400-core.c
··· 344 344 struct wm8400 *wm8400; 345 345 int ret; 346 346 347 - wm8400 = kzalloc(sizeof(struct wm8400), GFP_KERNEL); 347 + wm8400 = devm_kzalloc(&i2c->dev, sizeof(struct wm8400), GFP_KERNEL); 348 348 if (wm8400 == NULL) { 349 349 ret = -ENOMEM; 350 350 goto err; ··· 353 353 wm8400->regmap = regmap_init_i2c(i2c, &wm8400_regmap_config); 354 354 if (IS_ERR(wm8400->regmap)) { 355 355 ret = PTR_ERR(wm8400->regmap); 356 - goto struct_err; 356 + goto err; 357 357 } 358 358 359 359 wm8400->dev = &i2c->dev; ··· 367 367 368 368 map_err: 369 369 regmap_exit(wm8400->regmap); 370 - struct_err: 371 - kfree(wm8400); 372 370 err: 373 371 return ret; 374 372 } ··· 377 379 378 380 wm8400_release(wm8400); 379 381 regmap_exit(wm8400->regmap); 380 - kfree(wm8400); 381 382 382 383 return 0; 383 384 }
+8
drivers/misc/Kconfig
··· 500 500 stereo and mono audio, video, microphone and UART data to use 501 501 a common connector port. 502 502 503 + config MAX8997_MUIC 504 + tristate "MAX8997 MUIC Support" 505 + depends on MFD_MAX8997 506 + help 507 + If you say yes here you get support for the MUIC device of 508 + Maxim MAX8997 PMIC. 509 + The MAX8997 MUIC is a USB port accessory detector and switch. 510 + 503 511 source "drivers/misc/c2port/Kconfig" 504 512 source "drivers/misc/eeprom/Kconfig" 505 513 source "drivers/misc/cb710/Kconfig"
+1
drivers/misc/Makefile
··· 48 48 obj-y += carma/ 49 49 obj-$(CONFIG_USB_SWITCH_FSA9480) += fsa9480.o 50 50 obj-$(CONFIG_ALTERA_STAPL) +=altera-stapl/ 51 + obj-$(CONFIG_MAX8997_MUIC) += max8997-muic.o
+1 -1
drivers/misc/ab8500-pwm.c
··· 8 8 #include <linux/platform_device.h> 9 9 #include <linux/slab.h> 10 10 #include <linux/pwm.h> 11 - #include <linux/mfd/ab8500.h> 12 11 #include <linux/mfd/abx500.h> 12 + #include <linux/mfd/abx500/ab8500.h> 13 13 #include <linux/module.h> 14 14 15 15 /*
+505
drivers/misc/max8997-muic.c
··· 1 + /* 2 + * max8997-muic.c - MAX8997 muic driver for the Maxim 8997 3 + * 4 + * Copyright (C) 2011 Samsung Electrnoics 5 + * Donggeun Kim <dg77.kim@samsung.com> 6 + * 7 + * This program is free software; you can redistribute it and/or modify 8 + * it under the terms of the GNU General Public License as published by 9 + * the Free Software Foundation; either version 2 of the License, or 10 + * (at your option) any later version. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU 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 02111-1307 USA 20 + * 21 + */ 22 + 23 + #include <linux/kernel.h> 24 + #include <linux/module.h> 25 + #include <linux/i2c.h> 26 + #include <linux/slab.h> 27 + #include <linux/interrupt.h> 28 + #include <linux/err.h> 29 + #include <linux/platform_device.h> 30 + #include <linux/kobject.h> 31 + #include <linux/mfd/max8997.h> 32 + #include <linux/mfd/max8997-private.h> 33 + 34 + /* MAX8997-MUIC STATUS1 register */ 35 + #define STATUS1_ADC_SHIFT 0 36 + #define STATUS1_ADCLOW_SHIFT 5 37 + #define STATUS1_ADCERR_SHIFT 6 38 + #define STATUS1_ADC_MASK (0x1f << STATUS1_ADC_SHIFT) 39 + #define STATUS1_ADCLOW_MASK (0x1 << STATUS1_ADCLOW_SHIFT) 40 + #define STATUS1_ADCERR_MASK (0x1 << STATUS1_ADCERR_SHIFT) 41 + 42 + /* MAX8997-MUIC STATUS2 register */ 43 + #define STATUS2_CHGTYP_SHIFT 0 44 + #define STATUS2_CHGDETRUN_SHIFT 3 45 + #define STATUS2_DCDTMR_SHIFT 4 46 + #define STATUS2_DBCHG_SHIFT 5 47 + #define STATUS2_VBVOLT_SHIFT 6 48 + #define STATUS2_CHGTYP_MASK (0x7 << STATUS2_CHGTYP_SHIFT) 49 + #define STATUS2_CHGDETRUN_MASK (0x1 << STATUS2_CHGDETRUN_SHIFT) 50 + #define STATUS2_DCDTMR_MASK (0x1 << STATUS2_DCDTMR_SHIFT) 51 + #define STATUS2_DBCHG_MASK (0x1 << STATUS2_DBCHG_SHIFT) 52 + #define STATUS2_VBVOLT_MASK (0x1 << STATUS2_VBVOLT_SHIFT) 53 + 54 + /* MAX8997-MUIC STATUS3 register */ 55 + #define STATUS3_OVP_SHIFT 2 56 + #define STATUS3_OVP_MASK (0x1 << STATUS3_OVP_SHIFT) 57 + 58 + /* MAX8997-MUIC CONTROL1 register */ 59 + #define COMN1SW_SHIFT 0 60 + #define COMP2SW_SHIFT 3 61 + #define COMN1SW_MASK (0x7 << COMN1SW_SHIFT) 62 + #define COMP2SW_MASK (0x7 << COMP2SW_SHIFT) 63 + #define SW_MASK (COMP2SW_MASK | COMN1SW_MASK) 64 + 65 + #define MAX8997_SW_USB ((1 << COMP2SW_SHIFT) | (1 << COMN1SW_SHIFT)) 66 + #define MAX8997_SW_AUDIO ((2 << COMP2SW_SHIFT) | (2 << COMN1SW_SHIFT)) 67 + #define MAX8997_SW_UART ((3 << COMP2SW_SHIFT) | (3 << COMN1SW_SHIFT)) 68 + #define MAX8997_SW_OPEN ((0 << COMP2SW_SHIFT) | (0 << COMN1SW_SHIFT)) 69 + 70 + #define MAX8997_ADC_GROUND 0x00 71 + #define MAX8997_ADC_MHL 0x01 72 + #define MAX8997_ADC_JIG_USB_1 0x18 73 + #define MAX8997_ADC_JIG_USB_2 0x19 74 + #define MAX8997_ADC_DESKDOCK 0x1a 75 + #define MAX8997_ADC_JIG_UART 0x1c 76 + #define MAX8997_ADC_CARDOCK 0x1d 77 + #define MAX8997_ADC_OPEN 0x1f 78 + 79 + struct max8997_muic_irq { 80 + unsigned int irq; 81 + const char *name; 82 + }; 83 + 84 + static struct max8997_muic_irq muic_irqs[] = { 85 + { MAX8997_MUICIRQ_ADCError, "muic-ADC_error" }, 86 + { MAX8997_MUICIRQ_ADCLow, "muic-ADC_low" }, 87 + { MAX8997_MUICIRQ_ADC, "muic-ADC" }, 88 + { MAX8997_MUICIRQ_VBVolt, "muic-VB_voltage" }, 89 + { MAX8997_MUICIRQ_DBChg, "muic-DB_charger" }, 90 + { MAX8997_MUICIRQ_DCDTmr, "muic-DCD_timer" }, 91 + { MAX8997_MUICIRQ_ChgDetRun, "muic-CDR_status" }, 92 + { MAX8997_MUICIRQ_ChgTyp, "muic-charger_type" }, 93 + { MAX8997_MUICIRQ_OVP, "muic-over_voltage" }, 94 + }; 95 + 96 + struct max8997_muic_info { 97 + struct device *dev; 98 + struct max8997_dev *iodev; 99 + struct i2c_client *muic; 100 + struct max8997_muic_platform_data *muic_pdata; 101 + 102 + int irq; 103 + struct work_struct irq_work; 104 + 105 + enum max8997_muic_charger_type pre_charger_type; 106 + int pre_adc; 107 + 108 + struct mutex mutex; 109 + }; 110 + 111 + static int max8997_muic_handle_usb(struct max8997_muic_info *info, 112 + enum max8997_muic_usb_type usb_type, bool attached) 113 + { 114 + struct max8997_muic_platform_data *mdata = info->muic_pdata; 115 + int ret = 0; 116 + 117 + if (usb_type == MAX8997_USB_HOST) { 118 + /* switch to USB */ 119 + ret = max8997_update_reg(info->muic, MAX8997_MUIC_REG_CONTROL1, 120 + attached ? MAX8997_SW_USB : MAX8997_SW_OPEN, 121 + SW_MASK); 122 + if (ret) { 123 + dev_err(info->dev, "failed to update muic register\n"); 124 + goto out; 125 + } 126 + } 127 + 128 + if (mdata->usb_callback) 129 + mdata->usb_callback(usb_type, attached); 130 + out: 131 + return ret; 132 + } 133 + 134 + static void max8997_muic_handle_mhl(struct max8997_muic_info *info, 135 + bool attached) 136 + { 137 + struct max8997_muic_platform_data *mdata = info->muic_pdata; 138 + 139 + if (mdata->mhl_callback) 140 + mdata->mhl_callback(attached); 141 + } 142 + 143 + static int max8997_muic_handle_dock(struct max8997_muic_info *info, 144 + int adc, bool attached) 145 + { 146 + struct max8997_muic_platform_data *mdata = info->muic_pdata; 147 + int ret = 0; 148 + 149 + /* switch to AUDIO */ 150 + ret = max8997_update_reg(info->muic, MAX8997_MUIC_REG_CONTROL1, 151 + attached ? MAX8997_SW_AUDIO : MAX8997_SW_OPEN, 152 + SW_MASK); 153 + if (ret) { 154 + dev_err(info->dev, "failed to update muic register\n"); 155 + goto out; 156 + } 157 + 158 + switch (adc) { 159 + case MAX8997_ADC_DESKDOCK: 160 + if (mdata->deskdock_callback) 161 + mdata->deskdock_callback(attached); 162 + break; 163 + case MAX8997_ADC_CARDOCK: 164 + if (mdata->cardock_callback) 165 + mdata->cardock_callback(attached); 166 + break; 167 + default: 168 + break; 169 + } 170 + out: 171 + return ret; 172 + } 173 + 174 + static int max8997_muic_handle_jig_uart(struct max8997_muic_info *info, 175 + bool attached) 176 + { 177 + struct max8997_muic_platform_data *mdata = info->muic_pdata; 178 + int ret = 0; 179 + 180 + /* switch to UART */ 181 + ret = max8997_update_reg(info->muic, MAX8997_MUIC_REG_CONTROL1, 182 + attached ? MAX8997_SW_UART : MAX8997_SW_OPEN, 183 + SW_MASK); 184 + if (ret) { 185 + dev_err(info->dev, "failed to update muic register\n"); 186 + goto out; 187 + } 188 + 189 + if (mdata->uart_callback) 190 + mdata->uart_callback(attached); 191 + out: 192 + return ret; 193 + } 194 + 195 + static int max8997_muic_handle_adc_detach(struct max8997_muic_info *info) 196 + { 197 + int ret = 0; 198 + 199 + switch (info->pre_adc) { 200 + case MAX8997_ADC_GROUND: 201 + ret = max8997_muic_handle_usb(info, MAX8997_USB_HOST, false); 202 + break; 203 + case MAX8997_ADC_MHL: 204 + max8997_muic_handle_mhl(info, false); 205 + break; 206 + case MAX8997_ADC_JIG_USB_1: 207 + case MAX8997_ADC_JIG_USB_2: 208 + ret = max8997_muic_handle_usb(info, MAX8997_USB_DEVICE, false); 209 + break; 210 + case MAX8997_ADC_DESKDOCK: 211 + case MAX8997_ADC_CARDOCK: 212 + ret = max8997_muic_handle_dock(info, info->pre_adc, false); 213 + break; 214 + case MAX8997_ADC_JIG_UART: 215 + ret = max8997_muic_handle_jig_uart(info, false); 216 + break; 217 + default: 218 + break; 219 + } 220 + 221 + return ret; 222 + } 223 + 224 + static int max8997_muic_handle_adc(struct max8997_muic_info *info, int adc) 225 + { 226 + int ret = 0; 227 + 228 + switch (adc) { 229 + case MAX8997_ADC_GROUND: 230 + ret = max8997_muic_handle_usb(info, MAX8997_USB_HOST, true); 231 + break; 232 + case MAX8997_ADC_MHL: 233 + max8997_muic_handle_mhl(info, true); 234 + break; 235 + case MAX8997_ADC_JIG_USB_1: 236 + case MAX8997_ADC_JIG_USB_2: 237 + ret = max8997_muic_handle_usb(info, MAX8997_USB_DEVICE, true); 238 + break; 239 + case MAX8997_ADC_DESKDOCK: 240 + case MAX8997_ADC_CARDOCK: 241 + ret = max8997_muic_handle_dock(info, adc, true); 242 + break; 243 + case MAX8997_ADC_JIG_UART: 244 + ret = max8997_muic_handle_jig_uart(info, true); 245 + break; 246 + case MAX8997_ADC_OPEN: 247 + ret = max8997_muic_handle_adc_detach(info); 248 + break; 249 + default: 250 + break; 251 + } 252 + 253 + info->pre_adc = adc; 254 + 255 + return ret; 256 + } 257 + 258 + static int max8997_muic_handle_charger_type(struct max8997_muic_info *info, 259 + enum max8997_muic_charger_type charger_type) 260 + { 261 + struct max8997_muic_platform_data *mdata = info->muic_pdata; 262 + u8 adc; 263 + int ret; 264 + 265 + ret = max8997_read_reg(info->muic, MAX8997_MUIC_REG_STATUS1, &adc); 266 + if (ret) { 267 + dev_err(info->dev, "failed to read muic register\n"); 268 + goto out; 269 + } 270 + 271 + switch (charger_type) { 272 + case MAX8997_CHARGER_TYPE_NONE: 273 + if (mdata->charger_callback) 274 + mdata->charger_callback(false, charger_type); 275 + if (info->pre_charger_type == MAX8997_CHARGER_TYPE_USB) { 276 + max8997_muic_handle_usb(info, 277 + MAX8997_USB_DEVICE, false); 278 + } 279 + break; 280 + case MAX8997_CHARGER_TYPE_USB: 281 + if ((adc & STATUS1_ADC_MASK) == MAX8997_ADC_OPEN) { 282 + max8997_muic_handle_usb(info, 283 + MAX8997_USB_DEVICE, true); 284 + } 285 + if (mdata->charger_callback) 286 + mdata->charger_callback(true, charger_type); 287 + break; 288 + case MAX8997_CHARGER_TYPE_DOWNSTREAM_PORT: 289 + case MAX8997_CHARGER_TYPE_DEDICATED_CHG: 290 + case MAX8997_CHARGER_TYPE_500MA: 291 + case MAX8997_CHARGER_TYPE_1A: 292 + if (mdata->charger_callback) 293 + mdata->charger_callback(true, charger_type); 294 + break; 295 + default: 296 + break; 297 + } 298 + 299 + info->pre_charger_type = charger_type; 300 + out: 301 + return ret; 302 + } 303 + 304 + static void max8997_muic_irq_work(struct work_struct *work) 305 + { 306 + struct max8997_muic_info *info = container_of(work, 307 + struct max8997_muic_info, irq_work); 308 + struct max8997_platform_data *pdata = 309 + dev_get_platdata(info->iodev->dev); 310 + u8 status[3]; 311 + u8 adc, chg_type; 312 + 313 + int irq_type = info->irq - pdata->irq_base; 314 + int ret; 315 + 316 + mutex_lock(&info->mutex); 317 + 318 + ret = max8997_bulk_read(info->muic, MAX8997_MUIC_REG_STATUS1, 319 + 3, status); 320 + if (ret) { 321 + dev_err(info->dev, "failed to read muic register\n"); 322 + mutex_unlock(&info->mutex); 323 + return; 324 + } 325 + 326 + dev_dbg(info->dev, "%s: STATUS1:0x%x, 2:0x%x\n", __func__, 327 + status[0], status[1]); 328 + 329 + switch (irq_type) { 330 + case MAX8997_MUICIRQ_ADC: 331 + adc = status[0] & STATUS1_ADC_MASK; 332 + adc >>= STATUS1_ADC_SHIFT; 333 + 334 + max8997_muic_handle_adc(info, adc); 335 + break; 336 + case MAX8997_MUICIRQ_ChgTyp: 337 + chg_type = status[1] & STATUS2_CHGTYP_MASK; 338 + chg_type >>= STATUS2_CHGTYP_SHIFT; 339 + 340 + max8997_muic_handle_charger_type(info, chg_type); 341 + break; 342 + default: 343 + dev_info(info->dev, "misc interrupt: %s occurred\n", 344 + muic_irqs[irq_type].name); 345 + break; 346 + } 347 + 348 + mutex_unlock(&info->mutex); 349 + 350 + return; 351 + } 352 + 353 + static irqreturn_t max8997_muic_irq_handler(int irq, void *data) 354 + { 355 + struct max8997_muic_info *info = data; 356 + 357 + dev_dbg(info->dev, "irq:%d\n", irq); 358 + info->irq = irq; 359 + 360 + schedule_work(&info->irq_work); 361 + 362 + return IRQ_HANDLED; 363 + } 364 + 365 + static void max8997_muic_detect_dev(struct max8997_muic_info *info) 366 + { 367 + int ret; 368 + u8 status[2], adc, chg_type; 369 + 370 + ret = max8997_bulk_read(info->muic, MAX8997_MUIC_REG_STATUS1, 371 + 2, status); 372 + if (ret) { 373 + dev_err(info->dev, "failed to read muic register\n"); 374 + return; 375 + } 376 + 377 + dev_info(info->dev, "STATUS1:0x%x, STATUS2:0x%x\n", 378 + status[0], status[1]); 379 + 380 + adc = status[0] & STATUS1_ADC_MASK; 381 + adc >>= STATUS1_ADC_SHIFT; 382 + 383 + chg_type = status[1] & STATUS2_CHGTYP_MASK; 384 + chg_type >>= STATUS2_CHGTYP_SHIFT; 385 + 386 + max8997_muic_handle_adc(info, adc); 387 + max8997_muic_handle_charger_type(info, chg_type); 388 + } 389 + 390 + static void max8997_initialize_device(struct max8997_muic_info *info) 391 + { 392 + struct max8997_muic_platform_data *mdata = info->muic_pdata; 393 + int i; 394 + 395 + for (i = 0; i < mdata->num_init_data; i++) { 396 + max8997_write_reg(info->muic, mdata->init_data[i].addr, 397 + mdata->init_data[i].data); 398 + } 399 + } 400 + 401 + static int __devinit max8997_muic_probe(struct platform_device *pdev) 402 + { 403 + struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); 404 + struct max8997_platform_data *pdata = dev_get_platdata(iodev->dev); 405 + struct max8997_muic_info *info; 406 + int ret, i; 407 + 408 + info = kzalloc(sizeof(struct max8997_muic_info), GFP_KERNEL); 409 + if (!info) { 410 + dev_err(&pdev->dev, "failed to allocate memory\n"); 411 + ret = -ENOMEM; 412 + goto err_kfree; 413 + } 414 + 415 + if (!pdata->muic_pdata) { 416 + dev_err(&pdev->dev, "failed to get platform_data\n"); 417 + ret = -EINVAL; 418 + goto err_pdata; 419 + } 420 + info->muic_pdata = pdata->muic_pdata; 421 + 422 + info->dev = &pdev->dev; 423 + info->iodev = iodev; 424 + info->muic = iodev->muic; 425 + 426 + platform_set_drvdata(pdev, info); 427 + mutex_init(&info->mutex); 428 + 429 + INIT_WORK(&info->irq_work, max8997_muic_irq_work); 430 + 431 + for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) { 432 + struct max8997_muic_irq *muic_irq = &muic_irqs[i]; 433 + 434 + ret = request_threaded_irq(pdata->irq_base + muic_irq->irq, 435 + NULL, max8997_muic_irq_handler, 436 + 0, muic_irq->name, 437 + info); 438 + if (ret) { 439 + dev_err(&pdev->dev, 440 + "failed: irq request (IRQ: %d," 441 + " error :%d)\n", 442 + muic_irq->irq, ret); 443 + 444 + for (i = i - 1; i >= 0; i--) 445 + free_irq(muic_irq->irq, info); 446 + 447 + goto err_irq; 448 + } 449 + } 450 + 451 + /* Initialize registers according to platform data */ 452 + max8997_initialize_device(info); 453 + 454 + /* Initial device detection */ 455 + max8997_muic_detect_dev(info); 456 + 457 + return ret; 458 + 459 + err_irq: 460 + err_pdata: 461 + kfree(info); 462 + err_kfree: 463 + return ret; 464 + } 465 + 466 + static int __devexit max8997_muic_remove(struct platform_device *pdev) 467 + { 468 + struct max8997_muic_info *info = platform_get_drvdata(pdev); 469 + struct max8997_platform_data *pdata = 470 + dev_get_platdata(info->iodev->dev); 471 + int i; 472 + 473 + for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) 474 + free_irq(pdata->irq_base + muic_irqs[i].irq, info); 475 + cancel_work_sync(&info->irq_work); 476 + 477 + kfree(info); 478 + 479 + return 0; 480 + } 481 + 482 + static struct platform_driver max8997_muic_driver = { 483 + .driver = { 484 + .name = "max8997-muic", 485 + .owner = THIS_MODULE, 486 + }, 487 + .probe = max8997_muic_probe, 488 + .remove = __devexit_p(max8997_muic_remove), 489 + }; 490 + 491 + static int __init max8997_muic_init(void) 492 + { 493 + return platform_driver_register(&max8997_muic_driver); 494 + } 495 + module_init(max8997_muic_init); 496 + 497 + static void __exit max8997_muic_exit(void) 498 + { 499 + platform_driver_unregister(&max8997_muic_driver); 500 + } 501 + module_exit(max8997_muic_exit); 502 + 503 + MODULE_DESCRIPTION("Maxim MAX8997 MUIC driver"); 504 + MODULE_AUTHOR("Donggeun Kim <dg77.kim@samsung.com>"); 505 + MODULE_LICENSE("GPL");
+1 -1
drivers/regulator/ab8500.c
··· 16 16 #include <linux/module.h> 17 17 #include <linux/err.h> 18 18 #include <linux/platform_device.h> 19 - #include <linux/mfd/ab8500.h> 20 19 #include <linux/mfd/abx500.h> 20 + #include <linux/mfd/abx500/ab8500.h> 21 21 #include <linux/regulator/driver.h> 22 22 #include <linux/regulator/machine.h> 23 23 #include <linux/regulator/ab8500.h>
+1 -1
drivers/rtc/rtc-ab8500.c
··· 15 15 #include <linux/platform_device.h> 16 16 #include <linux/rtc.h> 17 17 #include <linux/mfd/abx500.h> 18 - #include <linux/mfd/ab8500.h> 18 + #include <linux/mfd/abx500/ab8500.h> 19 19 #include <linux/delay.h> 20 20 21 21 #define AB8500_RTC_SOFF_STAT_REG 0x00
+26
drivers/rtc/rtc-max8925.c
··· 261 261 /* XXX - isn't this redundant? */ 262 262 platform_set_drvdata(pdev, info); 263 263 264 + device_init_wakeup(&pdev->dev, 1); 265 + 264 266 info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev, 265 267 &max8925_rtc_ops, THIS_MODULE); 266 268 ret = PTR_ERR(info->rtc_dev); ··· 292 290 return 0; 293 291 } 294 292 293 + #ifdef CONFIG_PM_SLEEP 294 + static int max8925_rtc_suspend(struct device *dev) 295 + { 296 + struct platform_device *pdev = to_platform_device(dev); 297 + struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); 298 + 299 + if (device_may_wakeup(dev)) 300 + chip->wakeup_flag |= 1 << MAX8925_IRQ_RTC_ALARM0; 301 + return 0; 302 + } 303 + static int max8925_rtc_resume(struct device *dev) 304 + { 305 + struct platform_device *pdev = to_platform_device(dev); 306 + struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); 307 + 308 + if (device_may_wakeup(dev)) 309 + chip->wakeup_flag &= ~(1 << MAX8925_IRQ_RTC_ALARM0); 310 + return 0; 311 + } 312 + #endif 313 + 314 + static SIMPLE_DEV_PM_OPS(max8925_rtc_pm_ops, max8925_rtc_suspend, max8925_rtc_resume); 315 + 295 316 static struct platform_driver max8925_rtc_driver = { 296 317 .driver = { 297 318 .name = "max8925-rtc", 298 319 .owner = THIS_MODULE, 320 + .pm = &max8925_rtc_pm_ops, 299 321 }, 300 322 .probe = max8925_rtc_probe, 301 323 .remove = __devexit_p(max8925_rtc_remove),
+1 -1
drivers/usb/otg/ab8500-usb.c
··· 30 30 #include <linux/interrupt.h> 31 31 #include <linux/delay.h> 32 32 #include <linux/mfd/abx500.h> 33 - #include <linux/mfd/ab8500.h> 33 + #include <linux/mfd/abx500/ab8500.h> 34 34 35 35 #define AB8500_MAIN_WD_CTRL_REG 0x01 36 36 #define AB8500_USB_LINE_STAT_REG 0x80
+2
include/linux/i2c/twl.h
··· 652 652 unsigned num; 653 653 struct twl4030_resconfig *resource_config; 654 654 #define TWL4030_RESCONFIG_UNDEF ((u8)-1) 655 + bool use_poweroff; /* Board is wired for TWL poweroff */ 655 656 }; 656 657 657 658 extern void twl4030_power_init(struct twl4030_power_data *triton2_scripts); 658 659 extern int twl4030_remove_script(u8 flags); 660 + extern void twl4030_power_off(void); 659 661 660 662 struct twl4030_codec_data { 661 663 unsigned int digimic_delay; /* in ms */
+2 -1
include/linux/mfd/88pm860x.h
··· 297 297 298 298 struct pm860x_chip { 299 299 struct device *dev; 300 - struct mutex io_lock; 301 300 struct mutex irq_lock; 302 301 struct i2c_client *client; 303 302 struct i2c_client *companion; /* companion chip client */ 303 + struct regmap *regmap; 304 + struct regmap *regmap_companion; 304 305 305 306 int buck3_double; /* DVC ramp slope double */ 306 307 unsigned short companion_addr;
include/linux/mfd/ab5500/ab5500.h include/linux/mfd/abx500/ab5500.h
include/linux/mfd/ab8500.h include/linux/mfd/abx500/ab8500.h
include/linux/mfd/ab8500/gpadc.h include/linux/mfd/abx500/ab8500-gpadc.h
include/linux/mfd/ab8500/gpio.h include/linux/mfd/abx500/ab8500-gpio.h
include/linux/mfd/ab8500/sysctrl.h include/linux/mfd/abx500/ab8500-sysctrl.h
+2
include/linux/mfd/max8925.h
··· 203 203 int irq_base; 204 204 int core_irq; 205 205 int tsc_irq; 206 + 207 + unsigned int wakeup_flag; 206 208 }; 207 209 208 210 struct max8925_backlight_pdata {
+81 -2
include/linux/mfd/max8997.h
··· 77 77 struct regulator_init_data *initdata; 78 78 }; 79 79 80 + enum max8997_muic_usb_type { 81 + MAX8997_USB_HOST, 82 + MAX8997_USB_DEVICE, 83 + }; 84 + 85 + enum max8997_muic_charger_type { 86 + MAX8997_CHARGER_TYPE_NONE = 0, 87 + MAX8997_CHARGER_TYPE_USB, 88 + MAX8997_CHARGER_TYPE_DOWNSTREAM_PORT, 89 + MAX8997_CHARGER_TYPE_DEDICATED_CHG, 90 + MAX8997_CHARGER_TYPE_500MA, 91 + MAX8997_CHARGER_TYPE_1A, 92 + MAX8997_CHARGER_TYPE_DEAD_BATTERY = 7, 93 + }; 94 + 95 + struct max8997_muic_reg_data { 96 + u8 addr; 97 + u8 data; 98 + }; 99 + 100 + /** 101 + * struct max8997_muic_platform_data 102 + * @usb_callback: callback function for USB 103 + * inform callee of USB type (HOST or DEVICE) 104 + * and attached state(true or false) 105 + * @charger_callback: callback function for charger 106 + * inform callee of charger_type 107 + * and attached state(true or false) 108 + * @deskdock_callback: callback function for desk dock 109 + * inform callee of attached state(true or false) 110 + * @cardock_callback: callback function for car dock 111 + * inform callee of attached state(true or false) 112 + * @mhl_callback: callback function for MHL (Mobile High-definition Link) 113 + * inform callee of attached state(true or false) 114 + * @uart_callback: callback function for JIG UART 115 + * inform callee of attached state(true or false) 116 + * @init_data: array of max8997_muic_reg_data 117 + * used for initializing registers of MAX8997 MUIC device 118 + * @num_init_data: array size of init_data 119 + */ 120 + struct max8997_muic_platform_data { 121 + void (*usb_callback)(enum max8997_muic_usb_type usb_type, 122 + bool attached); 123 + void (*charger_callback)(bool attached, 124 + enum max8997_muic_charger_type charger_type); 125 + void (*deskdock_callback) (bool attached); 126 + void (*cardock_callback) (bool attached); 127 + void (*mhl_callback) (bool attached); 128 + void (*uart_callback) (bool attached); 129 + 130 + struct max8997_muic_reg_data *init_data; 131 + int num_init_data; 132 + }; 133 + 134 + enum max8997_led_mode { 135 + MAX8997_NONE, 136 + MAX8997_FLASH_MODE, 137 + MAX8997_MOVIE_MODE, 138 + MAX8997_FLASH_PIN_CONTROL_MODE, 139 + MAX8997_MOVIE_PIN_CONTROL_MODE, 140 + }; 141 + 142 + /** 143 + * struct max8997_led_platform_data 144 + * The number of LED devices for MAX8997 is two 145 + * @mode: LED mode for each LED device 146 + * @brightness: initial brightness for each LED device 147 + * range: 148 + * [0 - 31]: MAX8997_FLASH_MODE and MAX8997_FLASH_PIN_CONTROL_MODE 149 + * [0 - 15]: MAX8997_MOVIE_MODE and MAX8997_MOVIE_PIN_CONTROL_MODE 150 + */ 151 + struct max8997_led_platform_data { 152 + enum max8997_led_mode mode[2]; 153 + u8 brightness[2]; 154 + }; 155 + 80 156 struct max8997_platform_data { 81 157 /* IRQ */ 82 158 int irq_base; ··· 189 113 /* charge Full Timeout */ 190 114 int timeout; /* 0 (no timeout), 5, 6, 7 hours */ 191 115 192 - /* MUIC: Not implemented */ 116 + /* ---- MUIC ---- */ 117 + struct max8997_muic_platform_data *muic_pdata; 118 + 193 119 /* HAPTIC: Not implemented */ 194 120 /* RTC: Not implemented */ 195 - /* Flash: Not implemented */ 121 + /* ---- LED ---- */ 122 + struct max8997_led_platform_data *led_pdata; 196 123 }; 197 124 198 125 #endif /* __LINUX_MFD_MAX8998_H */
+8
include/linux/mfd/mc13xxx.h
··· 174 174 #define MC13XXX_ADC_MODE_MULT_CHAN 3 175 175 176 176 #define MC13XXX_ADC0 43 177 + #define MC13XXX_ADC0_LICELLCON (1 << 0) 178 + #define MC13XXX_ADC0_CHRGICON (1 << 1) 179 + #define MC13XXX_ADC0_BATICON (1 << 2) 177 180 #define MC13XXX_ADC0_ADREFEN (1 << 10) 178 181 #define MC13XXX_ADC0_TSMOD0 (1 << 12) 179 182 #define MC13XXX_ADC0_TSMOD1 (1 << 13) ··· 187 184 #define MC13XXX_ADC0_TSMOD_MASK (MC13XXX_ADC0_TSMOD0 | \ 188 185 MC13XXX_ADC0_TSMOD1 | \ 189 186 MC13XXX_ADC0_TSMOD2) 187 + 188 + #define MC13XXX_ADC0_CONFIG_MASK (MC13XXX_ADC0_TSMOD_MASK | \ 189 + MC13XXX_ADC0_LICELLCON | \ 190 + MC13XXX_ADC0_CHRGICON | \ 191 + MC13XXX_ADC0_BATICON) 190 192 191 193 #endif /* ifndef __LINUX_MFD_MC13XXX_H */
+5 -2
include/linux/mfd/mcp.h
··· 10 10 #ifndef MCP_H 11 11 #define MCP_H 12 12 13 + #include <linux/mod_devicetable.h> 13 14 #include <mach/dma.h> 14 15 15 16 struct mcp_ops; ··· 27 26 dma_device_t dma_telco_rd; 28 27 dma_device_t dma_telco_wr; 29 28 struct device attached_device; 30 - int gpio_base; 29 + const char *codec; 31 30 }; 32 31 33 32 struct mcp_ops { ··· 45 44 unsigned int mcp_reg_read(struct mcp *, unsigned int); 46 45 void mcp_enable(struct mcp *); 47 46 void mcp_disable(struct mcp *); 47 + const struct mcp_device_id *mcp_get_device_id(const struct mcp *mcp); 48 48 #define mcp_get_sclk_rate(mcp) ((mcp)->sclk_rate) 49 49 50 50 struct mcp *mcp_host_alloc(struct device *, size_t); 51 - int mcp_host_register(struct mcp *); 51 + int mcp_host_register(struct mcp *, void *); 52 52 void mcp_host_unregister(struct mcp *); 53 53 54 54 struct mcp_driver { ··· 58 56 void (*remove)(struct mcp *); 59 57 int (*suspend)(struct mcp *, pm_message_t); 60 58 int (*resume)(struct mcp *); 59 + const struct mcp_device_id *id_table; 61 60 }; 62 61 63 62 int mcp_driver_register(struct mcp_driver *);
+373
include/linux/mfd/s5m87xx/s5m-core.h
··· 1 + /* 2 + * s5m-core.h 3 + * 4 + * Copyright (c) 2011 Samsung Electronics Co., Ltd 5 + * http://www.samsung.com 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License as published by the 9 + * Free Software Foundation; either version 2 of the License, or (at your 10 + * option) any later version. 11 + * 12 + */ 13 + 14 + #ifndef __LINUX_MFD_S5M_CORE_H 15 + #define __LINUX_MFD_S5M_CORE_H 16 + 17 + #define NUM_IRQ_REGS 4 18 + 19 + enum s5m_device_type { 20 + S5M8751X, 21 + S5M8763X, 22 + S5M8767X, 23 + }; 24 + 25 + /* S5M8767 registers */ 26 + enum s5m8767_reg { 27 + S5M8767_REG_ID, 28 + S5M8767_REG_INT1, 29 + S5M8767_REG_INT2, 30 + S5M8767_REG_INT3, 31 + S5M8767_REG_INT1M, 32 + S5M8767_REG_INT2M, 33 + S5M8767_REG_INT3M, 34 + S5M8767_REG_STATUS1, 35 + S5M8767_REG_STATUS2, 36 + S5M8767_REG_STATUS3, 37 + S5M8767_REG_CTRL1, 38 + S5M8767_REG_CTRL2, 39 + S5M8767_REG_LOWBAT1, 40 + S5M8767_REG_LOWBAT2, 41 + S5M8767_REG_BUCHG, 42 + S5M8767_REG_DVSRAMP, 43 + S5M8767_REG_DVSTIMER2 = 0x10, 44 + S5M8767_REG_DVSTIMER3, 45 + S5M8767_REG_DVSTIMER4, 46 + S5M8767_REG_LDO1, 47 + S5M8767_REG_LDO2, 48 + S5M8767_REG_LDO3, 49 + S5M8767_REG_LDO4, 50 + S5M8767_REG_LDO5, 51 + S5M8767_REG_LDO6, 52 + S5M8767_REG_LDO7, 53 + S5M8767_REG_LDO8, 54 + S5M8767_REG_LDO9, 55 + S5M8767_REG_LDO10, 56 + S5M8767_REG_LDO11, 57 + S5M8767_REG_LDO12, 58 + S5M8767_REG_LDO13, 59 + S5M8767_REG_LDO14 = 0x20, 60 + S5M8767_REG_LDO15, 61 + S5M8767_REG_LDO16, 62 + S5M8767_REG_LDO17, 63 + S5M8767_REG_LDO18, 64 + S5M8767_REG_LDO19, 65 + S5M8767_REG_LDO20, 66 + S5M8767_REG_LDO21, 67 + S5M8767_REG_LDO22, 68 + S5M8767_REG_LDO23, 69 + S5M8767_REG_LDO24, 70 + S5M8767_REG_LDO25, 71 + S5M8767_REG_LDO26, 72 + S5M8767_REG_LDO27, 73 + S5M8767_REG_LDO28, 74 + S5M8767_REG_UVLO = 0x31, 75 + S5M8767_REG_BUCK1CTRL1, 76 + S5M8767_REG_BUCK1CTRL2, 77 + S5M8767_REG_BUCK2CTRL, 78 + S5M8767_REG_BUCK2DVS1, 79 + S5M8767_REG_BUCK2DVS2, 80 + S5M8767_REG_BUCK2DVS3, 81 + S5M8767_REG_BUCK2DVS4, 82 + S5M8767_REG_BUCK2DVS5, 83 + S5M8767_REG_BUCK2DVS6, 84 + S5M8767_REG_BUCK2DVS7, 85 + S5M8767_REG_BUCK2DVS8, 86 + S5M8767_REG_BUCK3CTRL, 87 + S5M8767_REG_BUCK3DVS1, 88 + S5M8767_REG_BUCK3DVS2, 89 + S5M8767_REG_BUCK3DVS3, 90 + S5M8767_REG_BUCK3DVS4, 91 + S5M8767_REG_BUCK3DVS5, 92 + S5M8767_REG_BUCK3DVS6, 93 + S5M8767_REG_BUCK3DVS7, 94 + S5M8767_REG_BUCK3DVS8, 95 + S5M8767_REG_BUCK4CTRL, 96 + S5M8767_REG_BUCK4DVS1, 97 + S5M8767_REG_BUCK4DVS2, 98 + S5M8767_REG_BUCK4DVS3, 99 + S5M8767_REG_BUCK4DVS4, 100 + S5M8767_REG_BUCK4DVS5, 101 + S5M8767_REG_BUCK4DVS6, 102 + S5M8767_REG_BUCK4DVS7, 103 + S5M8767_REG_BUCK4DVS8, 104 + S5M8767_REG_BUCK5CTRL1, 105 + S5M8767_REG_BUCK5CTRL2, 106 + S5M8767_REG_BUCK5CTRL3, 107 + S5M8767_REG_BUCK5CTRL4, 108 + S5M8767_REG_BUCK5CTRL5, 109 + S5M8767_REG_BUCK6CTRL1, 110 + S5M8767_REG_BUCK6CTRL2, 111 + S5M8767_REG_BUCK7CTRL1, 112 + S5M8767_REG_BUCK7CTRL2, 113 + S5M8767_REG_BUCK8CTRL1, 114 + S5M8767_REG_BUCK8CTRL2, 115 + S5M8767_REG_BUCK9CTRL1, 116 + S5M8767_REG_BUCK9CTRL2, 117 + S5M8767_REG_LDO1CTRL, 118 + S5M8767_REG_LDO2_1CTRL, 119 + S5M8767_REG_LDO2_2CTRL, 120 + S5M8767_REG_LDO2_3CTRL, 121 + S5M8767_REG_LDO2_4CTRL, 122 + S5M8767_REG_LDO3CTRL, 123 + S5M8767_REG_LDO4CTRL, 124 + S5M8767_REG_LDO5CTRL, 125 + S5M8767_REG_LDO6CTRL, 126 + S5M8767_REG_LDO7CTRL, 127 + S5M8767_REG_LDO8CTRL, 128 + S5M8767_REG_LDO9CTRL, 129 + S5M8767_REG_LDO10CTRL, 130 + S5M8767_REG_LDO11CTRL, 131 + S5M8767_REG_LDO12CTRL, 132 + S5M8767_REG_LDO13CTRL, 133 + S5M8767_REG_LDO14CTRL, 134 + S5M8767_REG_LDO15CTRL, 135 + S5M8767_REG_LDO16CTRL, 136 + S5M8767_REG_LDO17CTRL, 137 + S5M8767_REG_LDO18CTRL, 138 + S5M8767_REG_LDO19CTRL, 139 + S5M8767_REG_LDO20CTRL, 140 + S5M8767_REG_LDO21CTRL, 141 + S5M8767_REG_LDO22CTRL, 142 + S5M8767_REG_LDO23CTRL, 143 + S5M8767_REG_LDO24CTRL, 144 + S5M8767_REG_LDO25CTRL, 145 + S5M8767_REG_LDO26CTRL, 146 + S5M8767_REG_LDO27CTRL, 147 + S5M8767_REG_LDO28CTRL, 148 + }; 149 + 150 + /* S5M8763 registers */ 151 + enum s5m8763_reg { 152 + S5M8763_REG_IRQ1, 153 + S5M8763_REG_IRQ2, 154 + S5M8763_REG_IRQ3, 155 + S5M8763_REG_IRQ4, 156 + S5M8763_REG_IRQM1, 157 + S5M8763_REG_IRQM2, 158 + S5M8763_REG_IRQM3, 159 + S5M8763_REG_IRQM4, 160 + S5M8763_REG_STATUS1, 161 + S5M8763_REG_STATUS2, 162 + S5M8763_REG_STATUSM1, 163 + S5M8763_REG_STATUSM2, 164 + S5M8763_REG_CHGR1, 165 + S5M8763_REG_CHGR2, 166 + S5M8763_REG_LDO_ACTIVE_DISCHARGE1, 167 + S5M8763_REG_LDO_ACTIVE_DISCHARGE2, 168 + S5M8763_REG_BUCK_ACTIVE_DISCHARGE3, 169 + S5M8763_REG_ONOFF1, 170 + S5M8763_REG_ONOFF2, 171 + S5M8763_REG_ONOFF3, 172 + S5M8763_REG_ONOFF4, 173 + S5M8763_REG_BUCK1_VOLTAGE1, 174 + S5M8763_REG_BUCK1_VOLTAGE2, 175 + S5M8763_REG_BUCK1_VOLTAGE3, 176 + S5M8763_REG_BUCK1_VOLTAGE4, 177 + S5M8763_REG_BUCK2_VOLTAGE1, 178 + S5M8763_REG_BUCK2_VOLTAGE2, 179 + S5M8763_REG_BUCK3, 180 + S5M8763_REG_BUCK4, 181 + S5M8763_REG_LDO1_LDO2, 182 + S5M8763_REG_LDO3, 183 + S5M8763_REG_LDO4, 184 + S5M8763_REG_LDO5, 185 + S5M8763_REG_LDO6, 186 + S5M8763_REG_LDO7, 187 + S5M8763_REG_LDO7_LDO8, 188 + S5M8763_REG_LDO9_LDO10, 189 + S5M8763_REG_LDO11, 190 + S5M8763_REG_LDO12, 191 + S5M8763_REG_LDO13, 192 + S5M8763_REG_LDO14, 193 + S5M8763_REG_LDO15, 194 + S5M8763_REG_LDO16, 195 + S5M8763_REG_BKCHR, 196 + S5M8763_REG_LBCNFG1, 197 + S5M8763_REG_LBCNFG2, 198 + }; 199 + 200 + enum s5m8767_irq { 201 + S5M8767_IRQ_PWRR, 202 + S5M8767_IRQ_PWRF, 203 + S5M8767_IRQ_PWR1S, 204 + S5M8767_IRQ_JIGR, 205 + S5M8767_IRQ_JIGF, 206 + S5M8767_IRQ_LOWBAT2, 207 + S5M8767_IRQ_LOWBAT1, 208 + 209 + S5M8767_IRQ_MRB, 210 + S5M8767_IRQ_DVSOK2, 211 + S5M8767_IRQ_DVSOK3, 212 + S5M8767_IRQ_DVSOK4, 213 + 214 + S5M8767_IRQ_RTC60S, 215 + S5M8767_IRQ_RTCA1, 216 + S5M8767_IRQ_RTCA2, 217 + S5M8767_IRQ_SMPL, 218 + S5M8767_IRQ_RTC1S, 219 + S5M8767_IRQ_WTSR, 220 + 221 + S5M8767_IRQ_NR, 222 + }; 223 + 224 + #define S5M8767_IRQ_PWRR_MASK (1 << 0) 225 + #define S5M8767_IRQ_PWRF_MASK (1 << 1) 226 + #define S5M8767_IRQ_PWR1S_MASK (1 << 3) 227 + #define S5M8767_IRQ_JIGR_MASK (1 << 4) 228 + #define S5M8767_IRQ_JIGF_MASK (1 << 5) 229 + #define S5M8767_IRQ_LOWBAT2_MASK (1 << 6) 230 + #define S5M8767_IRQ_LOWBAT1_MASK (1 << 7) 231 + 232 + #define S5M8767_IRQ_MRB_MASK (1 << 2) 233 + #define S5M8767_IRQ_DVSOK2_MASK (1 << 3) 234 + #define S5M8767_IRQ_DVSOK3_MASK (1 << 4) 235 + #define S5M8767_IRQ_DVSOK4_MASK (1 << 5) 236 + 237 + #define S5M8767_IRQ_RTC60S_MASK (1 << 0) 238 + #define S5M8767_IRQ_RTCA1_MASK (1 << 1) 239 + #define S5M8767_IRQ_RTCA2_MASK (1 << 2) 240 + #define S5M8767_IRQ_SMPL_MASK (1 << 3) 241 + #define S5M8767_IRQ_RTC1S_MASK (1 << 4) 242 + #define S5M8767_IRQ_WTSR_MASK (1 << 5) 243 + 244 + enum s5m8763_irq { 245 + S5M8763_IRQ_DCINF, 246 + S5M8763_IRQ_DCINR, 247 + S5M8763_IRQ_JIGF, 248 + S5M8763_IRQ_JIGR, 249 + S5M8763_IRQ_PWRONF, 250 + S5M8763_IRQ_PWRONR, 251 + 252 + S5M8763_IRQ_WTSREVNT, 253 + S5M8763_IRQ_SMPLEVNT, 254 + S5M8763_IRQ_ALARM1, 255 + S5M8763_IRQ_ALARM0, 256 + 257 + S5M8763_IRQ_ONKEY1S, 258 + S5M8763_IRQ_TOPOFFR, 259 + S5M8763_IRQ_DCINOVPR, 260 + S5M8763_IRQ_CHGRSTF, 261 + S5M8763_IRQ_DONER, 262 + S5M8763_IRQ_CHGFAULT, 263 + 264 + S5M8763_IRQ_LOBAT1, 265 + S5M8763_IRQ_LOBAT2, 266 + 267 + S5M8763_IRQ_NR, 268 + }; 269 + 270 + #define S5M8763_IRQ_DCINF_MASK (1 << 2) 271 + #define S5M8763_IRQ_DCINR_MASK (1 << 3) 272 + #define S5M8763_IRQ_JIGF_MASK (1 << 4) 273 + #define S5M8763_IRQ_JIGR_MASK (1 << 5) 274 + #define S5M8763_IRQ_PWRONF_MASK (1 << 6) 275 + #define S5M8763_IRQ_PWRONR_MASK (1 << 7) 276 + 277 + #define S5M8763_IRQ_WTSREVNT_MASK (1 << 0) 278 + #define S5M8763_IRQ_SMPLEVNT_MASK (1 << 1) 279 + #define S5M8763_IRQ_ALARM1_MASK (1 << 2) 280 + #define S5M8763_IRQ_ALARM0_MASK (1 << 3) 281 + 282 + #define S5M8763_IRQ_ONKEY1S_MASK (1 << 0) 283 + #define S5M8763_IRQ_TOPOFFR_MASK (1 << 2) 284 + #define S5M8763_IRQ_DCINOVPR_MASK (1 << 3) 285 + #define S5M8763_IRQ_CHGRSTF_MASK (1 << 4) 286 + #define S5M8763_IRQ_DONER_MASK (1 << 5) 287 + #define S5M8763_IRQ_CHGFAULT_MASK (1 << 7) 288 + 289 + #define S5M8763_IRQ_LOBAT1_MASK (1 << 0) 290 + #define S5M8763_IRQ_LOBAT2_MASK (1 << 1) 291 + 292 + #define S5M8763_ENRAMP (1 << 4) 293 + 294 + /** 295 + * struct s5m87xx_dev - s5m87xx master device for sub-drivers 296 + * @dev: master device of the chip (can be used to access platform data) 297 + * @i2c: i2c client private data for regulator 298 + * @rtc: i2c client private data for rtc 299 + * @iolock: mutex for serializing io access 300 + * @irqlock: mutex for buslock 301 + * @irq_base: base IRQ number for s5m87xx, required for IRQs 302 + * @irq: generic IRQ number for s5m87xx 303 + * @ono: power onoff IRQ number for s5m87xx 304 + * @irq_masks_cur: currently active value 305 + * @irq_masks_cache: cached hardware value 306 + * @type: indicate which s5m87xx "variant" is used 307 + */ 308 + struct s5m87xx_dev { 309 + struct device *dev; 310 + struct regmap *regmap; 311 + struct i2c_client *i2c; 312 + struct i2c_client *rtc; 313 + struct mutex iolock; 314 + struct mutex irqlock; 315 + 316 + int device_type; 317 + int irq_base; 318 + int irq; 319 + int ono; 320 + u8 irq_masks_cur[NUM_IRQ_REGS]; 321 + u8 irq_masks_cache[NUM_IRQ_REGS]; 322 + int type; 323 + bool wakeup; 324 + }; 325 + 326 + int s5m_irq_init(struct s5m87xx_dev *s5m87xx); 327 + void s5m_irq_exit(struct s5m87xx_dev *s5m87xx); 328 + int s5m_irq_resume(struct s5m87xx_dev *s5m87xx); 329 + 330 + extern int s5m_reg_read(struct s5m87xx_dev *s5m87xx, u8 reg, void *dest); 331 + extern int s5m_bulk_read(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf); 332 + extern int s5m_reg_write(struct s5m87xx_dev *s5m87xx, u8 reg, u8 value); 333 + extern int s5m_bulk_write(struct s5m87xx_dev *s5m87xx, u8 reg, int count, u8 *buf); 334 + extern int s5m_reg_update(struct s5m87xx_dev *s5m87xx, u8 reg, u8 val, u8 mask); 335 + 336 + struct s5m_platform_data { 337 + struct s5m_regulator_data *regulators; 338 + int device_type; 339 + int num_regulators; 340 + 341 + int irq_base; 342 + int (*cfg_pmic_irq)(void); 343 + 344 + int ono; 345 + bool wakeup; 346 + bool buck_voltage_lock; 347 + 348 + int buck_gpios[3]; 349 + int buck2_voltage[8]; 350 + bool buck2_gpiodvs; 351 + int buck3_voltage[8]; 352 + bool buck3_gpiodvs; 353 + int buck4_voltage[8]; 354 + bool buck4_gpiodvs; 355 + 356 + int buck_set1; 357 + int buck_set2; 358 + int buck_set3; 359 + int buck2_enable; 360 + int buck3_enable; 361 + int buck4_enable; 362 + int buck_default_idx; 363 + int buck2_default_idx; 364 + int buck3_default_idx; 365 + int buck4_default_idx; 366 + 367 + int buck_ramp_delay; 368 + bool buck2_ramp_enable; 369 + bool buck3_ramp_enable; 370 + bool buck4_ramp_enable; 371 + }; 372 + 373 + #endif /* __LINUX_MFD_S5M_CORE_H */
+100
include/linux/mfd/s5m87xx/s5m-pmic.h
··· 1 + /* s5m87xx.h 2 + * 3 + * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. 4 + * http://www.samsung.com 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + */ 10 + 11 + #ifndef __LINUX_MFD_S5M_PMIC_H 12 + #define __LINUX_MFD_S5M_PMIC_H 13 + 14 + #include <linux/regulator/machine.h> 15 + 16 + /* S5M8767 regulator ids */ 17 + enum s5m8767_regulators { 18 + S5M8767_LDO1, 19 + S5M8767_LDO2, 20 + S5M8767_LDO3, 21 + S5M8767_LDO4, 22 + S5M8767_LDO5, 23 + S5M8767_LDO6, 24 + S5M8767_LDO7, 25 + S5M8767_LDO8, 26 + S5M8767_LDO9, 27 + S5M8767_LDO10, 28 + S5M8767_LDO11, 29 + S5M8767_LDO12, 30 + S5M8767_LDO13, 31 + S5M8767_LDO14, 32 + S5M8767_LDO15, 33 + S5M8767_LDO16, 34 + S5M8767_LDO17, 35 + S5M8767_LDO18, 36 + S5M8767_LDO19, 37 + S5M8767_LDO20, 38 + S5M8767_LDO21, 39 + S5M8767_LDO22, 40 + S5M8767_LDO23, 41 + S5M8767_LDO24, 42 + S5M8767_LDO25, 43 + S5M8767_LDO26, 44 + S5M8767_LDO27, 45 + S5M8767_LDO28, 46 + S5M8767_BUCK1, 47 + S5M8767_BUCK2, 48 + S5M8767_BUCK3, 49 + S5M8767_BUCK4, 50 + S5M8767_BUCK5, 51 + S5M8767_BUCK6, 52 + S5M8767_BUCK7, 53 + S5M8767_BUCK8, 54 + S5M8767_BUCK9, 55 + S5M8767_AP_EN32KHZ, 56 + S5M8767_CP_EN32KHZ, 57 + 58 + S5M8767_REG_MAX, 59 + }; 60 + 61 + /* S5M8763 regulator ids */ 62 + enum s5m8763_regulators { 63 + S5M8763_LDO1, 64 + S5M8763_LDO2, 65 + S5M8763_LDO3, 66 + S5M8763_LDO4, 67 + S5M8763_LDO5, 68 + S5M8763_LDO6, 69 + S5M8763_LDO7, 70 + S5M8763_LDO8, 71 + S5M8763_LDO9, 72 + S5M8763_LDO10, 73 + S5M8763_LDO11, 74 + S5M8763_LDO12, 75 + S5M8763_LDO13, 76 + S5M8763_LDO14, 77 + S5M8763_LDO15, 78 + S5M8763_LDO16, 79 + S5M8763_BUCK1, 80 + S5M8763_BUCK2, 81 + S5M8763_BUCK3, 82 + S5M8763_BUCK4, 83 + S5M8763_AP_EN32KHZ, 84 + S5M8763_CP_EN32KHZ, 85 + S5M8763_ENCHGVI, 86 + S5M8763_ESAFEUSB1, 87 + S5M8763_ESAFEUSB2, 88 + }; 89 + 90 + /** 91 + * s5m87xx_regulator_data - regulator data 92 + * @id: regulator id 93 + * @initdata: regulator init data (contraints, supplies, ...) 94 + */ 95 + struct s5m_regulator_data { 96 + int id; 97 + struct regulator_init_data *initdata; 98 + }; 99 + 100 + #endif /* __LINUX_MFD_S5M_PMIC_H */
+84
include/linux/mfd/s5m87xx/s5m-rtc.h
··· 1 + /* 2 + * s5m-rtc.h 3 + * 4 + * Copyright (c) 2011 Samsung Electronics Co., Ltd 5 + * http://www.samsung.com 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License as published by the 9 + * Free Software Foundation; either version 2 of the License, or (at your 10 + * option) any later version. 11 + * 12 + */ 13 + 14 + #ifndef __LINUX_MFD_S5M_RTC_H 15 + #define __LINUX_MFD_S5M_RTC_H 16 + 17 + enum s5m87xx_rtc_reg { 18 + S5M87XX_RTC_SEC, 19 + S5M87XX_RTC_MIN, 20 + S5M87XX_RTC_HOUR, 21 + S5M87XX_RTC_WEEKDAY, 22 + S5M87XX_RTC_DATE, 23 + S5M87XX_RTC_MONTH, 24 + S5M87XX_RTC_YEAR1, 25 + S5M87XX_RTC_YEAR2, 26 + S5M87XX_ALARM0_SEC, 27 + S5M87XX_ALARM0_MIN, 28 + S5M87XX_ALARM0_HOUR, 29 + S5M87XX_ALARM0_WEEKDAY, 30 + S5M87XX_ALARM0_DATE, 31 + S5M87XX_ALARM0_MONTH, 32 + S5M87XX_ALARM0_YEAR1, 33 + S5M87XX_ALARM0_YEAR2, 34 + S5M87XX_ALARM1_SEC, 35 + S5M87XX_ALARM1_MIN, 36 + S5M87XX_ALARM1_HOUR, 37 + S5M87XX_ALARM1_WEEKDAY, 38 + S5M87XX_ALARM1_DATE, 39 + S5M87XX_ALARM1_MONTH, 40 + S5M87XX_ALARM1_YEAR1, 41 + S5M87XX_ALARM1_YEAR2, 42 + S5M87XX_ALARM0_CONF, 43 + S5M87XX_ALARM1_CONF, 44 + S5M87XX_RTC_STATUS, 45 + S5M87XX_WTSR_SMPL_CNTL, 46 + S5M87XX_RTC_UDR_CON, 47 + }; 48 + 49 + #define RTC_I2C_ADDR (0x0C >> 1) 50 + 51 + #define HOUR_12 (1 << 7) 52 + #define HOUR_AMPM (1 << 6) 53 + #define HOUR_PM (1 << 5) 54 + #define ALARM0_STATUS (1 << 1) 55 + #define ALARM1_STATUS (1 << 2) 56 + #define UPDATE_AD (1 << 0) 57 + 58 + /* RTC Control Register */ 59 + #define BCD_EN_SHIFT 0 60 + #define BCD_EN_MASK (1 << BCD_EN_SHIFT) 61 + #define MODEL24_SHIFT 1 62 + #define MODEL24_MASK (1 << MODEL24_SHIFT) 63 + /* RTC Update Register1 */ 64 + #define RTC_UDR_SHIFT 0 65 + #define RTC_UDR_MASK (1 << RTC_UDR_SHIFT) 66 + /* RTC Hour register */ 67 + #define HOUR_PM_SHIFT 6 68 + #define HOUR_PM_MASK (1 << HOUR_PM_SHIFT) 69 + /* RTC Alarm Enable */ 70 + #define ALARM_ENABLE_SHIFT 7 71 + #define ALARM_ENABLE_MASK (1 << ALARM_ENABLE_SHIFT) 72 + 73 + enum { 74 + RTC_SEC = 0, 75 + RTC_MIN, 76 + RTC_HOUR, 77 + RTC_WEEKDAY, 78 + RTC_DATE, 79 + RTC_MONTH, 80 + RTC_YEAR1, 81 + RTC_YEAR2, 82 + }; 83 + 84 + #endif /* __LINUX_MFD_S5M_RTC_H */
+14 -2
include/linux/mfd/stmpe.h
··· 20 20 }; 21 21 22 22 enum stmpe_partnum { 23 + STMPE610, 24 + STMPE801, 23 25 STMPE811, 24 26 STMPE1601, 25 27 STMPE2401, ··· 52 50 53 51 54 52 struct stmpe_variant_info; 53 + struct stmpe_client_info; 55 54 56 55 /** 57 56 * struct stmpe - STMPE MFD structure 58 57 * @lock: lock protecting I/O operations 59 58 * @irq_lock: IRQ bus lock 60 59 * @dev: device, mostly for dev_dbg() 61 - * @i2c: i2c client 60 + * @client: client - i2c or spi 61 + * @ci: client specific information 62 62 * @partnum: part number 63 63 * @variant: the detected STMPE model number 64 64 * @regs: list of addresses of registers which are at different addresses on 65 65 * different variants. Indexed by one of STMPE_IDX_*. 66 + * @irq: irq number for stmpe 66 67 * @irq_base: starting IRQ number for internal IRQs 67 68 * @num_gpios: number of gpios, differs for variants 68 69 * @ier: cache of IER registers for bus_lock ··· 76 71 struct mutex lock; 77 72 struct mutex irq_lock; 78 73 struct device *dev; 79 - struct i2c_client *i2c; 74 + void *client; 75 + struct stmpe_client_info *ci; 80 76 enum stmpe_partnum partnum; 81 77 struct stmpe_variant_info *variant; 82 78 const u8 *regs; 83 79 80 + int irq; 84 81 int irq_base; 85 82 int num_gpios; 86 83 u8 ier[2]; ··· 190 183 * @autosleep_timeout: inactivity timeout in milliseconds for autosleep 191 184 * @irq_base: base IRQ number. %STMPE_NR_IRQS irqs will be used, or 192 185 * %STMPE_NR_INTERNAL_IRQS if the GPIO driver is not used. 186 + * @irq_over_gpio: true if gpio is used to get irq 187 + * @irq_gpio: gpio number over which irq will be requested (significant only if 188 + * irq_over_gpio is true) 193 189 * @gpio: GPIO-specific platform data 194 190 * @keypad: keypad-specific platform data 195 191 * @ts: touchscreen-specific platform data ··· 204 194 unsigned int irq_trigger; 205 195 bool irq_invert_polarity; 206 196 bool autosleep; 197 + bool irq_over_gpio; 198 + int irq_gpio; 207 199 int autosleep_timeout; 208 200 209 201 struct stmpe_gpio_platform_data *gpio;
+4 -1
include/linux/mfd/ucb1x00.h
··· 104 104 #define UCB_MODE_DYN_VFLAG_ENA (1 << 12) 105 105 #define UCB_MODE_AUD_OFF_CAN (1 << 13) 106 106 107 + struct ucb1x00_plat_data { 108 + int gpio_base; 109 + }; 107 110 108 111 struct ucb1x00_irq { 109 112 void *devid; ··· 119 116 unsigned int irq; 120 117 struct semaphore adc_sem; 121 118 spinlock_t io_lock; 122 - u16 id; 119 + const struct mcp_device_id *id; 123 120 u16 io_dir; 124 121 u16 io_out; 125 122 u16 adc_cr;
+11
include/linux/mod_devicetable.h
··· 436 436 __attribute__((aligned(sizeof(kernel_ulong_t)))); 437 437 }; 438 438 439 + /* mcp */ 440 + 441 + #define MCP_NAME_SIZE 20 442 + #define MCP_MODULE_PREFIX "mcp:" 443 + 444 + struct mcp_device_id { 445 + char name[MCP_NAME_SIZE]; 446 + kernel_ulong_t driver_data /* Data private to the driver */ 447 + __attribute__((aligned(sizeof(kernel_ulong_t)))); 448 + }; 449 + 439 450 /* dmi */ 440 451 enum dmi_field { 441 452 DMI_NONE,
+13
scripts/mod/file2alias.c
··· 774 774 return 1; 775 775 } 776 776 777 + /* Looks like: mcp:S */ 778 + static int do_mcp_entry(const char *filename, struct mcp_device_id *id, 779 + char *alias) 780 + { 781 + sprintf(alias, MCP_MODULE_PREFIX "%s", id->name); 782 + 783 + return 1; 784 + } 785 + 777 786 static const struct dmifield { 778 787 const char *prefix; 779 788 int field; ··· 1104 1095 do_table(symval, sym->st_size, 1105 1096 sizeof(struct spi_device_id), "spi", 1106 1097 do_spi_entry, mod); 1098 + else if (sym_is(symname, "__mod_mcp_device_table")) 1099 + do_table(symval, sym->st_size, 1100 + sizeof(struct mcp_device_id), "mcp", 1101 + do_mcp_entry, mod); 1107 1102 else if (sym_is(symname, "__mod_dmi_device_table")) 1108 1103 do_table(symval, sym->st_size, 1109 1104 sizeof(struct dmi_system_id), "dmi",