aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mfd/Kconfig7
-rw-r--r--drivers/mfd/Makefile3
-rw-r--r--drivers/mfd/pcf50633-gpio.c118
-rw-r--r--include/linux/mfd/pcf50633/gpio.h52
4 files changed, 179 insertions, 1 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 2fa3504e165..06a2b0f7737 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -233,6 +233,13 @@ config PCF50633_ADC
233 Say yes here if you want to include support for ADC in the 233 Say yes here if you want to include support for ADC in the
234 NXP PCF50633 chip. 234 NXP PCF50633 chip.
235 235
236config PCF50633_GPIO
237 tristate "Support for NXP PCF50633 GPIO"
238 depends on MFD_PCF50633
239 help
240 Say yes here if you want to include support GPIO for pins on
241 the PCF50633 chip.
242
236endmenu 243endmenu
237 244
238menu "Multimedia Capabilities Port drivers" 245menu "Multimedia Capabilities Port drivers"
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 138f9c4d3d7..3afb5192e4d 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -39,4 +39,5 @@ obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o
39obj-$(CONFIG_PMIC_DA903X) += da903x.o 39obj-$(CONFIG_PMIC_DA903X) += da903x.o
40 40
41obj-$(CONFIG_MFD_PCF50633) += pcf50633-core.o 41obj-$(CONFIG_MFD_PCF50633) += pcf50633-core.o
42obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o \ No newline at end of file 42obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o
43obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o \ No newline at end of file
diff --git a/drivers/mfd/pcf50633-gpio.c b/drivers/mfd/pcf50633-gpio.c
new file mode 100644
index 00000000000..2fa2eca5c9c
--- /dev/null
+++ b/drivers/mfd/pcf50633-gpio.c
@@ -0,0 +1,118 @@
1/* NXP PCF50633 GPIO Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18
19#include <linux/mfd/pcf50633/core.h>
20#include <linux/mfd/pcf50633/gpio.h>
21
22enum pcf50633_regulator_id {
23 PCF50633_REGULATOR_AUTO,
24 PCF50633_REGULATOR_DOWN1,
25 PCF50633_REGULATOR_DOWN2,
26 PCF50633_REGULATOR_LDO1,
27 PCF50633_REGULATOR_LDO2,
28 PCF50633_REGULATOR_LDO3,
29 PCF50633_REGULATOR_LDO4,
30 PCF50633_REGULATOR_LDO5,
31 PCF50633_REGULATOR_LDO6,
32 PCF50633_REGULATOR_HCLDO,
33 PCF50633_REGULATOR_MEMLDO,
34};
35
36#define PCF50633_REG_AUTOOUT 0x1a
37#define PCF50633_REG_DOWN1OUT 0x1e
38#define PCF50633_REG_DOWN2OUT 0x22
39#define PCF50633_REG_MEMLDOOUT 0x26
40#define PCF50633_REG_LDO1OUT 0x2d
41#define PCF50633_REG_LDO2OUT 0x2f
42#define PCF50633_REG_LDO3OUT 0x31
43#define PCF50633_REG_LDO4OUT 0x33
44#define PCF50633_REG_LDO5OUT 0x35
45#define PCF50633_REG_LDO6OUT 0x37
46#define PCF50633_REG_HCLDOOUT 0x39
47
48static const u8 pcf50633_regulator_registers[PCF50633_NUM_REGULATORS] = {
49 [PCF50633_REGULATOR_AUTO] = PCF50633_REG_AUTOOUT,
50 [PCF50633_REGULATOR_DOWN1] = PCF50633_REG_DOWN1OUT,
51 [PCF50633_REGULATOR_DOWN2] = PCF50633_REG_DOWN2OUT,
52 [PCF50633_REGULATOR_MEMLDO] = PCF50633_REG_MEMLDOOUT,
53 [PCF50633_REGULATOR_LDO1] = PCF50633_REG_LDO1OUT,
54 [PCF50633_REGULATOR_LDO2] = PCF50633_REG_LDO2OUT,
55 [PCF50633_REGULATOR_LDO3] = PCF50633_REG_LDO3OUT,
56 [PCF50633_REGULATOR_LDO4] = PCF50633_REG_LDO4OUT,
57 [PCF50633_REGULATOR_LDO5] = PCF50633_REG_LDO5OUT,
58 [PCF50633_REGULATOR_LDO6] = PCF50633_REG_LDO6OUT,
59 [PCF50633_REGULATOR_HCLDO] = PCF50633_REG_HCLDOOUT,
60};
61
62int pcf50633_gpio_set(struct pcf50633 *pcf, int gpio, u8 val)
63{
64 u8 reg;
65
66 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
67
68 return pcf50633_reg_set_bit_mask(pcf, reg, 0x07, val);
69}
70EXPORT_SYMBOL_GPL(pcf50633_gpio_set);
71
72u8 pcf50633_gpio_get(struct pcf50633 *pcf, int gpio)
73{
74 u8 reg, val;
75
76 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
77 val = pcf50633_reg_read(pcf, reg) & 0x07;
78
79 return val;
80}
81EXPORT_SYMBOL_GPL(pcf50633_gpio_get);
82
83int pcf50633_gpio_invert_set(struct pcf50633 *pcf, int gpio, int invert)
84{
85 u8 val, reg;
86
87 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
88 val = !!invert << 3;
89
90 return pcf50633_reg_set_bit_mask(pcf, reg, 1 << 3, val);
91}
92EXPORT_SYMBOL_GPL(pcf50633_gpio_invert_set);
93
94int pcf50633_gpio_invert_get(struct pcf50633 *pcf, int gpio)
95{
96 u8 reg, val;
97
98 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
99 val = pcf50633_reg_read(pcf, reg);
100
101 return val & (1 << 3);
102}
103EXPORT_SYMBOL_GPL(pcf50633_gpio_invert_get);
104
105int pcf50633_gpio_power_supply_set(struct pcf50633 *pcf,
106 int gpio, int regulator, int on)
107{
108 u8 reg, val, mask;
109
110 /* the *ENA register is always one after the *OUT register */
111 reg = pcf50633_regulator_registers[regulator] + 1;
112
113 val = !!on << (gpio - PCF50633_GPIO1);
114 mask = 1 << (gpio - PCF50633_GPIO1);
115
116 return pcf50633_reg_set_bit_mask(pcf, reg, mask, val);
117}
118EXPORT_SYMBOL_GPL(pcf50633_gpio_power_supply_set);
diff --git a/include/linux/mfd/pcf50633/gpio.h b/include/linux/mfd/pcf50633/gpio.h
new file mode 100644
index 00000000000..a42b845efc5
--- /dev/null
+++ b/include/linux/mfd/pcf50633/gpio.h
@@ -0,0 +1,52 @@
1/*
2 * gpio.h -- GPIO driver for NXP PCF50633
3 *
4 * (C) 2006-2008 by Openmoko, Inc.
5 * All rights reserved.
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#ifndef __LINUX_MFD_PCF50633_GPIO_H
14#define __LINUX_MFD_PCF50633_GPIO_H
15
16#include <linux/mfd/pcf50633/core.h>
17
18#define PCF50633_GPIO1 1
19#define PCF50633_GPIO2 2
20#define PCF50633_GPIO3 3
21#define PCF50633_GPO 4
22
23#define PCF50633_REG_GPIO1CFG 0x14
24#define PCF50633_REG_GPIO2CFG 0x15
25#define PCF50633_REG_GPIO3CFG 0x16
26#define PCF50633_REG_GPOCFG 0x17
27
28#define PCF50633_GPOCFG_GPOSEL_MASK 0x07
29
30enum pcf50633_reg_gpocfg {
31 PCF50633_GPOCFG_GPOSEL_0 = 0x00,
32 PCF50633_GPOCFG_GPOSEL_LED_NFET = 0x01,
33 PCF50633_GPOCFG_GPOSEL_SYSxOK = 0x02,
34 PCF50633_GPOCFG_GPOSEL_CLK32K = 0x03,
35 PCF50633_GPOCFG_GPOSEL_ADAPUSB = 0x04,
36 PCF50633_GPOCFG_GPOSEL_USBxOK = 0x05,
37 PCF50633_GPOCFG_GPOSEL_ACTPH4 = 0x06,
38 PCF50633_GPOCFG_GPOSEL_1 = 0x07,
39 PCF50633_GPOCFG_GPOSEL_INVERSE = 0x08,
40};
41
42int pcf50633_gpio_set(struct pcf50633 *pcf, int gpio, u8 val);
43u8 pcf50633_gpio_get(struct pcf50633 *pcf, int gpio);
44
45int pcf50633_gpio_invert_set(struct pcf50633 *, int gpio, int invert);
46int pcf50633_gpio_invert_get(struct pcf50633 *pcf, int gpio);
47
48int pcf50633_gpio_power_supply_set(struct pcf50633 *,
49 int gpio, int regulator, int on);
50#endif /* __LINUX_MFD_PCF50633_GPIO_H */
51
52