mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
/*
|
|
|
|
* Base driver for Marvell 88PM800
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Marvell International Ltd.
|
|
|
|
* Haojian Zhuang <haojian.zhuang@marvell.com>
|
|
|
|
* Joseph(Yossi) Hanin <yhanin@marvell.com>
|
|
|
|
* Qiao Zhou <zhouqiao@marvell.com>
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General
|
|
|
|
* Public License. See the file "COPYING" in the main directory of this
|
|
|
|
* archive for more details.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
2013-06-14 05:21:50 +00:00
|
|
|
#include <linux/err.h>
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/mfd/core.h>
|
|
|
|
#include <linux/mfd/88pm80x.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
|
|
|
|
/* Interrupt Registers */
|
|
|
|
#define PM800_INT_STATUS1 (0x05)
|
|
|
|
#define PM800_ONKEY_INT_STS1 (1 << 0)
|
|
|
|
#define PM800_EXTON_INT_STS1 (1 << 1)
|
|
|
|
#define PM800_CHG_INT_STS1 (1 << 2)
|
|
|
|
#define PM800_BAT_INT_STS1 (1 << 3)
|
|
|
|
#define PM800_RTC_INT_STS1 (1 << 4)
|
|
|
|
#define PM800_CLASSD_OC_INT_STS1 (1 << 5)
|
|
|
|
|
|
|
|
#define PM800_INT_STATUS2 (0x06)
|
|
|
|
#define PM800_VBAT_INT_STS2 (1 << 0)
|
|
|
|
#define PM800_VSYS_INT_STS2 (1 << 1)
|
|
|
|
#define PM800_VCHG_INT_STS2 (1 << 2)
|
|
|
|
#define PM800_TINT_INT_STS2 (1 << 3)
|
|
|
|
#define PM800_GPADC0_INT_STS2 (1 << 4)
|
|
|
|
#define PM800_TBAT_INT_STS2 (1 << 5)
|
|
|
|
#define PM800_GPADC2_INT_STS2 (1 << 6)
|
|
|
|
#define PM800_GPADC3_INT_STS2 (1 << 7)
|
|
|
|
|
|
|
|
#define PM800_INT_STATUS3 (0x07)
|
|
|
|
|
|
|
|
#define PM800_INT_STATUS4 (0x08)
|
|
|
|
#define PM800_GPIO0_INT_STS4 (1 << 0)
|
|
|
|
#define PM800_GPIO1_INT_STS4 (1 << 1)
|
|
|
|
#define PM800_GPIO2_INT_STS4 (1 << 2)
|
|
|
|
#define PM800_GPIO3_INT_STS4 (1 << 3)
|
|
|
|
#define PM800_GPIO4_INT_STS4 (1 << 4)
|
|
|
|
|
|
|
|
#define PM800_INT_ENA_1 (0x09)
|
|
|
|
#define PM800_ONKEY_INT_ENA1 (1 << 0)
|
|
|
|
#define PM800_EXTON_INT_ENA1 (1 << 1)
|
|
|
|
#define PM800_CHG_INT_ENA1 (1 << 2)
|
|
|
|
#define PM800_BAT_INT_ENA1 (1 << 3)
|
|
|
|
#define PM800_RTC_INT_ENA1 (1 << 4)
|
|
|
|
#define PM800_CLASSD_OC_INT_ENA1 (1 << 5)
|
|
|
|
|
|
|
|
#define PM800_INT_ENA_2 (0x0A)
|
|
|
|
#define PM800_VBAT_INT_ENA2 (1 << 0)
|
|
|
|
#define PM800_VSYS_INT_ENA2 (1 << 1)
|
|
|
|
#define PM800_VCHG_INT_ENA2 (1 << 2)
|
|
|
|
#define PM800_TINT_INT_ENA2 (1 << 3)
|
|
|
|
|
|
|
|
#define PM800_INT_ENA_3 (0x0B)
|
|
|
|
#define PM800_GPADC0_INT_ENA3 (1 << 0)
|
|
|
|
#define PM800_GPADC1_INT_ENA3 (1 << 1)
|
|
|
|
#define PM800_GPADC2_INT_ENA3 (1 << 2)
|
|
|
|
#define PM800_GPADC3_INT_ENA3 (1 << 3)
|
|
|
|
#define PM800_GPADC4_INT_ENA3 (1 << 4)
|
|
|
|
|
|
|
|
#define PM800_INT_ENA_4 (0x0C)
|
|
|
|
#define PM800_GPIO0_INT_ENA4 (1 << 0)
|
|
|
|
#define PM800_GPIO1_INT_ENA4 (1 << 1)
|
|
|
|
#define PM800_GPIO2_INT_ENA4 (1 << 2)
|
|
|
|
#define PM800_GPIO3_INT_ENA4 (1 << 3)
|
|
|
|
#define PM800_GPIO4_INT_ENA4 (1 << 4)
|
|
|
|
|
|
|
|
/* number of INT_ENA & INT_STATUS regs */
|
|
|
|
#define PM800_INT_REG_NUM (4)
|
|
|
|
|
|
|
|
/* Interrupt Number in 88PM800 */
|
|
|
|
enum {
|
|
|
|
PM800_IRQ_ONKEY, /*EN1b0 *//*0 */
|
|
|
|
PM800_IRQ_EXTON, /*EN1b1 */
|
|
|
|
PM800_IRQ_CHG, /*EN1b2 */
|
|
|
|
PM800_IRQ_BAT, /*EN1b3 */
|
|
|
|
PM800_IRQ_RTC, /*EN1b4 */
|
|
|
|
PM800_IRQ_CLASSD, /*EN1b5 *//*5 */
|
|
|
|
PM800_IRQ_VBAT, /*EN2b0 */
|
|
|
|
PM800_IRQ_VSYS, /*EN2b1 */
|
|
|
|
PM800_IRQ_VCHG, /*EN2b2 */
|
|
|
|
PM800_IRQ_TINT, /*EN2b3 */
|
|
|
|
PM800_IRQ_GPADC0, /*EN3b0 *//*10 */
|
|
|
|
PM800_IRQ_GPADC1, /*EN3b1 */
|
|
|
|
PM800_IRQ_GPADC2, /*EN3b2 */
|
|
|
|
PM800_IRQ_GPADC3, /*EN3b3 */
|
|
|
|
PM800_IRQ_GPADC4, /*EN3b4 */
|
|
|
|
PM800_IRQ_GPIO0, /*EN4b0 *//*15 */
|
|
|
|
PM800_IRQ_GPIO1, /*EN4b1 */
|
|
|
|
PM800_IRQ_GPIO2, /*EN4b2 */
|
|
|
|
PM800_IRQ_GPIO3, /*EN4b3 */
|
|
|
|
PM800_IRQ_GPIO4, /*EN4b4 *//*19 */
|
|
|
|
PM800_MAX_IRQ,
|
|
|
|
};
|
|
|
|
|
2013-06-14 05:21:51 +00:00
|
|
|
/* PM800: generation identification number */
|
|
|
|
#define PM800_CHIP_GEN_ID_NUM 0x3
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
|
|
|
|
static const struct i2c_device_id pm80x_id_table[] = {
|
2024-05-10 21:10:11 +00:00
|
|
|
{ "88PM800" },
|
2012-07-09 13:11:46 +00:00
|
|
|
{} /* NULL terminated */
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(i2c, pm80x_id_table);
|
|
|
|
|
2020-09-22 19:26:59 +00:00
|
|
|
static const struct resource rtc_resources[] = {
|
2021-06-01 07:06:30 +00:00
|
|
|
DEFINE_RES_IRQ_NAMED(PM800_IRQ_RTC, "88pm80x-rtc"),
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct mfd_cell rtc_devs[] = {
|
|
|
|
{
|
|
|
|
.name = "88pm80x-rtc",
|
|
|
|
.num_resources = ARRAY_SIZE(rtc_resources),
|
|
|
|
.resources = &rtc_resources[0],
|
|
|
|
.id = -1,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource onkey_resources[] = {
|
2021-06-01 07:06:30 +00:00
|
|
|
DEFINE_RES_IRQ_NAMED(PM800_IRQ_ONKEY, "88pm80x-onkey"),
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
};
|
|
|
|
|
2013-11-18 13:32:59 +00:00
|
|
|
static const struct mfd_cell onkey_devs[] = {
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
{
|
|
|
|
.name = "88pm80x-onkey",
|
|
|
|
.num_resources = 1,
|
|
|
|
.resources = &onkey_resources[0],
|
|
|
|
.id = -1,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2013-11-18 13:32:59 +00:00
|
|
|
static const struct mfd_cell regulator_devs[] = {
|
2013-06-14 05:21:53 +00:00
|
|
|
{
|
|
|
|
.name = "88pm80x-regulator",
|
|
|
|
.id = -1,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
static const struct regmap_irq pm800_irqs[] = {
|
|
|
|
/* INT0 */
|
|
|
|
[PM800_IRQ_ONKEY] = {
|
|
|
|
.mask = PM800_ONKEY_INT_ENA1,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_EXTON] = {
|
|
|
|
.mask = PM800_EXTON_INT_ENA1,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_CHG] = {
|
|
|
|
.mask = PM800_CHG_INT_ENA1,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_BAT] = {
|
|
|
|
.mask = PM800_BAT_INT_ENA1,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_RTC] = {
|
|
|
|
.mask = PM800_RTC_INT_ENA1,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_CLASSD] = {
|
|
|
|
.mask = PM800_CLASSD_OC_INT_ENA1,
|
|
|
|
},
|
|
|
|
/* INT1 */
|
|
|
|
[PM800_IRQ_VBAT] = {
|
|
|
|
.reg_offset = 1,
|
|
|
|
.mask = PM800_VBAT_INT_ENA2,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_VSYS] = {
|
|
|
|
.reg_offset = 1,
|
|
|
|
.mask = PM800_VSYS_INT_ENA2,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_VCHG] = {
|
|
|
|
.reg_offset = 1,
|
|
|
|
.mask = PM800_VCHG_INT_ENA2,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_TINT] = {
|
|
|
|
.reg_offset = 1,
|
|
|
|
.mask = PM800_TINT_INT_ENA2,
|
|
|
|
},
|
|
|
|
/* INT2 */
|
|
|
|
[PM800_IRQ_GPADC0] = {
|
|
|
|
.reg_offset = 2,
|
|
|
|
.mask = PM800_GPADC0_INT_ENA3,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_GPADC1] = {
|
|
|
|
.reg_offset = 2,
|
|
|
|
.mask = PM800_GPADC1_INT_ENA3,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_GPADC2] = {
|
|
|
|
.reg_offset = 2,
|
|
|
|
.mask = PM800_GPADC2_INT_ENA3,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_GPADC3] = {
|
|
|
|
.reg_offset = 2,
|
|
|
|
.mask = PM800_GPADC3_INT_ENA3,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_GPADC4] = {
|
|
|
|
.reg_offset = 2,
|
|
|
|
.mask = PM800_GPADC4_INT_ENA3,
|
|
|
|
},
|
|
|
|
/* INT3 */
|
|
|
|
[PM800_IRQ_GPIO0] = {
|
|
|
|
.reg_offset = 3,
|
|
|
|
.mask = PM800_GPIO0_INT_ENA4,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_GPIO1] = {
|
|
|
|
.reg_offset = 3,
|
|
|
|
.mask = PM800_GPIO1_INT_ENA4,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_GPIO2] = {
|
|
|
|
.reg_offset = 3,
|
|
|
|
.mask = PM800_GPIO2_INT_ENA4,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_GPIO3] = {
|
|
|
|
.reg_offset = 3,
|
|
|
|
.mask = PM800_GPIO3_INT_ENA4,
|
|
|
|
},
|
|
|
|
[PM800_IRQ_GPIO4] = {
|
|
|
|
.reg_offset = 3,
|
|
|
|
.mask = PM800_GPIO4_INT_ENA4,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-11-19 18:23:04 +00:00
|
|
|
static int device_gpadc_init(struct pm80x_chip *chip,
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
struct pm80x_platform_data *pdata)
|
|
|
|
{
|
|
|
|
struct pm80x_subchip *subchip = chip->subchip;
|
|
|
|
struct regmap *map = subchip->regmap_gpadc;
|
|
|
|
int data = 0, mask = 0, ret = 0;
|
|
|
|
|
|
|
|
if (!map) {
|
|
|
|
dev_warn(chip->dev,
|
|
|
|
"Warning: gpadc regmap is not available!\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* initialize GPADC without activating it turn on GPADC
|
|
|
|
* measurments
|
|
|
|
*/
|
|
|
|
ret = regmap_update_bits(map,
|
|
|
|
PM800_GPADC_MISC_CONFIG2,
|
|
|
|
PM800_GPADC_MISC_GPFSM_EN,
|
|
|
|
PM800_GPADC_MISC_GPFSM_EN);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out;
|
|
|
|
/*
|
|
|
|
* This function configures the ADC as requires for
|
|
|
|
* CP implementation.CP does not "own" the ADC configuration
|
|
|
|
* registers and relies on AP.
|
|
|
|
* Reason: enable automatic ADC measurements needed
|
|
|
|
* for CP to get VBAT and RF temperature readings.
|
|
|
|
*/
|
|
|
|
ret = regmap_update_bits(map, PM800_GPADC_MEAS_EN1,
|
|
|
|
PM800_MEAS_EN1_VBAT, PM800_MEAS_EN1_VBAT);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out;
|
|
|
|
ret = regmap_update_bits(map, PM800_GPADC_MEAS_EN2,
|
|
|
|
(PM800_MEAS_EN2_RFTMP | PM800_MEAS_GP0_EN),
|
|
|
|
(PM800_MEAS_EN2_RFTMP | PM800_MEAS_GP0_EN));
|
|
|
|
if (ret < 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* the defult of PM800 is GPADC operates at 100Ks/s rate
|
|
|
|
* and Number of GPADC slots with active current bias prior
|
|
|
|
* to GPADC sampling = 1 slot for all GPADCs set for
|
|
|
|
* Temprature mesurmants
|
|
|
|
*/
|
|
|
|
mask = (PM800_GPADC_GP_BIAS_EN0 | PM800_GPADC_GP_BIAS_EN1 |
|
|
|
|
PM800_GPADC_GP_BIAS_EN2 | PM800_GPADC_GP_BIAS_EN3);
|
|
|
|
|
|
|
|
if (pdata && (pdata->batt_det == 0))
|
|
|
|
data = (PM800_GPADC_GP_BIAS_EN0 | PM800_GPADC_GP_BIAS_EN1 |
|
|
|
|
PM800_GPADC_GP_BIAS_EN2 | PM800_GPADC_GP_BIAS_EN3);
|
|
|
|
else
|
|
|
|
data = (PM800_GPADC_GP_BIAS_EN0 | PM800_GPADC_GP_BIAS_EN2 |
|
|
|
|
PM800_GPADC_GP_BIAS_EN3);
|
|
|
|
|
|
|
|
ret = regmap_update_bits(map, PM800_GP_BIAS_ENA1, mask, data);
|
|
|
|
if (ret < 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
dev_info(chip->dev, "pm800 device_gpadc_init: Done\n");
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out:
|
|
|
|
dev_info(chip->dev, "pm800 device_gpadc_init: Failed!\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-06-14 05:21:52 +00:00
|
|
|
static int device_onkey_init(struct pm80x_chip *chip,
|
|
|
|
struct pm80x_platform_data *pdata)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = mfd_add_devices(chip->dev, 0, &onkey_devs[0],
|
|
|
|
ARRAY_SIZE(onkey_devs), &onkey_resources[0], 0,
|
|
|
|
NULL);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(chip->dev, "Failed to add onkey subdev\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int device_rtc_init(struct pm80x_chip *chip,
|
|
|
|
struct pm80x_platform_data *pdata)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2013-08-19 01:27:54 +00:00
|
|
|
if (pdata) {
|
|
|
|
rtc_devs[0].platform_data = pdata->rtc;
|
|
|
|
rtc_devs[0].pdata_size =
|
|
|
|
pdata->rtc ? sizeof(struct pm80x_rtc_pdata) : 0;
|
|
|
|
}
|
2013-06-14 05:21:52 +00:00
|
|
|
ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
|
|
|
|
ARRAY_SIZE(rtc_devs), NULL, 0, NULL);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(chip->dev, "Failed to add rtc subdev\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-14 05:21:53 +00:00
|
|
|
static int device_regulator_init(struct pm80x_chip *chip,
|
|
|
|
struct pm80x_platform_data *pdata)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[0],
|
|
|
|
ARRAY_SIZE(regulator_devs), NULL, 0, NULL);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(chip->dev, "Failed to add regulator subdev\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-11-19 18:23:04 +00:00
|
|
|
static int device_irq_init_800(struct pm80x_chip *chip)
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
{
|
|
|
|
struct regmap *map = chip->regmap;
|
2013-06-14 05:21:48 +00:00
|
|
|
unsigned long flags = IRQF_ONESHOT;
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
int data, mask, ret = -EINVAL;
|
|
|
|
|
|
|
|
if (!map || !chip->irq) {
|
|
|
|
dev_err(chip->dev, "incorrect parameters\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* irq_mode defines the way of clearing interrupt. it's read-clear by
|
|
|
|
* default.
|
|
|
|
*/
|
|
|
|
mask =
|
|
|
|
PM800_WAKEUP2_INV_INT | PM800_WAKEUP2_INT_CLEAR |
|
|
|
|
PM800_WAKEUP2_INT_MASK;
|
|
|
|
|
|
|
|
data = PM800_WAKEUP2_INT_CLEAR;
|
|
|
|
ret = regmap_update_bits(map, PM800_WAKEUP2, mask, data);
|
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
ret =
|
|
|
|
regmap_add_irq_chip(chip->regmap, chip->irq, flags, -1,
|
|
|
|
chip->regmap_irq_chip, &chip->irq_data);
|
|
|
|
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void device_irq_exit_800(struct pm80x_chip *chip)
|
|
|
|
{
|
|
|
|
regmap_del_irq_chip(chip->irq, chip->irq_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct regmap_irq_chip pm800_irq_chip = {
|
|
|
|
.name = "88pm800",
|
|
|
|
.irqs = pm800_irqs,
|
|
|
|
.num_irqs = ARRAY_SIZE(pm800_irqs),
|
|
|
|
|
|
|
|
.num_regs = 4,
|
|
|
|
.status_base = PM800_INT_STATUS1,
|
2022-11-12 15:18:18 +00:00
|
|
|
.unmask_base = PM800_INT_ENA_1,
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
.ack_base = PM800_INT_STATUS1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int pm800_pages_init(struct pm80x_chip *chip)
|
|
|
|
{
|
|
|
|
struct pm80x_subchip *subchip;
|
|
|
|
struct i2c_client *client = chip->client;
|
|
|
|
|
2013-06-14 05:21:50 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
subchip = chip->subchip;
|
2013-06-14 05:21:50 +00:00
|
|
|
if (!subchip || !subchip->power_page_addr || !subchip->gpadc_page_addr)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/* PM800 block power page */
|
2019-07-22 17:26:08 +00:00
|
|
|
subchip->power_page = i2c_new_dummy_device(client->adapter,
|
2013-06-14 05:21:50 +00:00
|
|
|
subchip->power_page_addr);
|
2019-07-22 17:26:08 +00:00
|
|
|
if (IS_ERR(subchip->power_page)) {
|
|
|
|
ret = PTR_ERR(subchip->power_page);
|
2013-06-14 05:21:50 +00:00
|
|
|
goto out;
|
|
|
|
}
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
|
2013-06-14 05:21:50 +00:00
|
|
|
subchip->regmap_power = devm_regmap_init_i2c(subchip->power_page,
|
|
|
|
&pm80x_regmap_config);
|
|
|
|
if (IS_ERR(subchip->regmap_power)) {
|
|
|
|
ret = PTR_ERR(subchip->regmap_power);
|
|
|
|
dev_err(chip->dev,
|
|
|
|
"Failed to allocate regmap_power: %d\n", ret);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
i2c_set_clientdata(subchip->power_page, chip);
|
|
|
|
|
|
|
|
/* PM800 block GPADC */
|
2019-07-22 17:26:08 +00:00
|
|
|
subchip->gpadc_page = i2c_new_dummy_device(client->adapter,
|
2013-06-14 05:21:50 +00:00
|
|
|
subchip->gpadc_page_addr);
|
2019-07-22 17:26:08 +00:00
|
|
|
if (IS_ERR(subchip->gpadc_page)) {
|
|
|
|
ret = PTR_ERR(subchip->gpadc_page);
|
2013-06-14 05:21:50 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
subchip->regmap_gpadc = devm_regmap_init_i2c(subchip->gpadc_page,
|
|
|
|
&pm80x_regmap_config);
|
|
|
|
if (IS_ERR(subchip->regmap_gpadc)) {
|
|
|
|
ret = PTR_ERR(subchip->regmap_gpadc);
|
|
|
|
dev_err(chip->dev,
|
|
|
|
"Failed to allocate regmap_gpadc: %d\n", ret);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
i2c_set_clientdata(subchip->gpadc_page, chip);
|
|
|
|
|
|
|
|
out:
|
|
|
|
return ret;
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void pm800_pages_exit(struct pm80x_chip *chip)
|
|
|
|
{
|
|
|
|
struct pm80x_subchip *subchip;
|
|
|
|
|
|
|
|
subchip = chip->subchip;
|
2013-06-14 05:21:50 +00:00
|
|
|
|
|
|
|
if (subchip && subchip->power_page)
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
i2c_unregister_device(subchip->power_page);
|
2013-06-14 05:21:50 +00:00
|
|
|
|
|
|
|
if (subchip && subchip->gpadc_page)
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
i2c_unregister_device(subchip->gpadc_page);
|
|
|
|
}
|
|
|
|
|
2012-11-19 18:23:04 +00:00
|
|
|
static int device_800_init(struct pm80x_chip *chip,
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
struct pm80x_platform_data *pdata)
|
|
|
|
{
|
2013-06-14 05:21:51 +00:00
|
|
|
int ret;
|
2012-07-11 01:27:54 +00:00
|
|
|
unsigned int val;
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* alarm wake up bit will be clear in device_irq_init(),
|
|
|
|
* read before that
|
|
|
|
*/
|
2012-07-11 01:27:54 +00:00
|
|
|
ret = regmap_read(chip->regmap, PM800_RTC_CONTROL, &val);
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(chip->dev, "Failed to read RTC register: %d\n", ret);
|
|
|
|
goto out;
|
|
|
|
}
|
2012-07-11 01:27:54 +00:00
|
|
|
if (val & PM800_ALARM_WAKEUP) {
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
if (pdata && pdata->rtc)
|
|
|
|
pdata->rtc->rtc_wakeup = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = device_gpadc_init(chip, pdata);
|
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(chip->dev, "[%s]Failed to init gpadc\n", __func__);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
chip->regmap_irq_chip = &pm800_irq_chip;
|
|
|
|
|
|
|
|
ret = device_irq_init_800(chip);
|
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(chip->dev, "[%s]Failed to init pm800 irq\n", __func__);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2013-06-14 05:21:52 +00:00
|
|
|
ret = device_onkey_init(chip, pdata);
|
|
|
|
if (ret) {
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
dev_err(chip->dev, "Failed to add onkey subdev\n");
|
|
|
|
goto out_dev;
|
2013-06-14 05:21:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = device_rtc_init(chip, pdata);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(chip->dev, "Failed to add rtc subdev\n");
|
|
|
|
goto out;
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
}
|
|
|
|
|
2013-06-14 05:21:53 +00:00
|
|
|
ret = device_regulator_init(chip, pdata);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(chip->dev, "Failed to add regulators subdev\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
return 0;
|
|
|
|
out_dev:
|
|
|
|
mfd_remove_devices(chip->dev);
|
|
|
|
device_irq_exit_800(chip);
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-11-18 22:42:27 +00:00
|
|
|
static int pm800_probe(struct i2c_client *client)
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
struct pm80x_chip *chip;
|
2013-07-30 08:10:05 +00:00
|
|
|
struct pm80x_platform_data *pdata = dev_get_platdata(&client->dev);
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
struct pm80x_subchip *subchip;
|
|
|
|
|
2013-06-14 05:21:51 +00:00
|
|
|
ret = pm80x_init(client);
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
if (ret) {
|
|
|
|
dev_err(&client->dev, "pm800_init fail\n");
|
|
|
|
goto out_init;
|
|
|
|
}
|
|
|
|
|
|
|
|
chip = i2c_get_clientdata(client);
|
|
|
|
|
|
|
|
/* init subchip for PM800 */
|
|
|
|
subchip =
|
|
|
|
devm_kzalloc(&client->dev, sizeof(struct pm80x_subchip),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!subchip) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err_subchip_alloc;
|
|
|
|
}
|
|
|
|
|
2013-06-14 05:21:49 +00:00
|
|
|
/* pm800 has 2 addtional pages to support power and gpadc. */
|
|
|
|
subchip->power_page_addr = client->addr + 1;
|
|
|
|
subchip->gpadc_page_addr = client->addr + 2;
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
chip->subchip = subchip;
|
|
|
|
|
|
|
|
ret = pm800_pages_init(chip);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(&client->dev, "pm800_pages_init failed!\n");
|
2014-02-12 10:10:56 +00:00
|
|
|
goto err_device_init;
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
}
|
|
|
|
|
2013-06-14 05:21:45 +00:00
|
|
|
ret = device_800_init(chip, pdata);
|
|
|
|
if (ret) {
|
2013-06-14 05:21:51 +00:00
|
|
|
dev_err(chip->dev, "Failed to initialize 88pm800 devices\n");
|
2013-06-14 05:21:45 +00:00
|
|
|
goto err_device_init;
|
|
|
|
}
|
|
|
|
|
2013-08-19 01:27:54 +00:00
|
|
|
if (pdata && pdata->plat_config)
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
pdata->plat_config(chip, pdata);
|
|
|
|
|
2013-06-14 05:21:45 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_device_init:
|
|
|
|
pm800_pages_exit(chip);
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
err_subchip_alloc:
|
2013-01-22 02:43:45 +00:00
|
|
|
pm80x_deinit();
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
out_init:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-08-15 08:02:30 +00:00
|
|
|
static void pm800_remove(struct i2c_client *client)
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
{
|
|
|
|
struct pm80x_chip *chip = i2c_get_clientdata(client);
|
|
|
|
|
|
|
|
mfd_remove_devices(chip->dev);
|
|
|
|
device_irq_exit_800(chip);
|
|
|
|
|
|
|
|
pm800_pages_exit(chip);
|
2013-01-22 02:43:45 +00:00
|
|
|
pm80x_deinit();
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct i2c_driver pm800_driver = {
|
|
|
|
.driver = {
|
2013-06-14 05:21:46 +00:00
|
|
|
.name = "88PM800",
|
2022-10-23 09:48:25 +00:00
|
|
|
.pm = pm_sleep_ptr(&pm80x_pm_ops),
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
},
|
2023-05-15 18:27:52 +00:00
|
|
|
.probe = pm800_probe,
|
2012-11-19 18:20:24 +00:00
|
|
|
.remove = pm800_remove,
|
mfd: Support 88pm80x in 80x driver
88PM800 and 88PM805 are two discrete chips used for power management.
Hardware designer can use them together or only one of them according
to requirement.
88pm80x.c provides common i2c driver handling for both 800 and
805, such as i2c_driver init, regmap init, read/write api etc.
88pm800.c handles specifically for 800, such as chip init, irq
init/handle, mfd device register, including rtc, onkey, regulator(
to be add later) etc. besides that, 800 has three i2c device, one
regular i2c client, two other i2c dummy for gpadc and power purpose.
88pm805.c handles specifically for 805, such as chip init, irq
init/handle, mfd device register, including codec, headset/mic detect
etc.
the i2c operation of both 800 and 805 are via regmap, and 88pm80x-i2c
exported a group of r/w bulk r/w and bits set API for facility.
Signed-off-by: Qiao Zhou <zhouqiao@marvell.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2012-07-09 06:37:32 +00:00
|
|
|
.id_table = pm80x_id_table,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init pm800_i2c_init(void)
|
|
|
|
{
|
|
|
|
return i2c_add_driver(&pm800_driver);
|
|
|
|
}
|
|
|
|
subsys_initcall(pm800_i2c_init);
|
|
|
|
|
|
|
|
static void __exit pm800_i2c_exit(void)
|
|
|
|
{
|
|
|
|
i2c_del_driver(&pm800_driver);
|
|
|
|
}
|
|
|
|
module_exit(pm800_i2c_exit);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("PMIC Driver for Marvell 88PM800");
|
|
|
|
MODULE_AUTHOR("Qiao Zhou <zhouqiao@marvell.com>");
|
|
|
|
MODULE_LICENSE("GPL");
|