Skip to content

Commit

Permalink
(WIP/UNFINISHED) bcm590xx: add support for bcm59054
Browse files Browse the repository at this point in the history
This commit adds support for the bcm59054 to the bcm590xx driver.
It also splits 59054 and 59056 regulator registers into separate
header files to avoid cluttering up the main driver.
  • Loading branch information
knuxify committed May 7, 2021
1 parent 8806586 commit 80ff432
Show file tree
Hide file tree
Showing 5 changed files with 450 additions and 229 deletions.
15 changes: 4 additions & 11 deletions drivers/mfd/bcm590xx.c
Expand Up @@ -19,12 +19,6 @@
#include <linux/regmap.h>
#include <linux/slab.h>

enum bcm590xx_device_type {
BCM590XX_DEVICE_TYPE_BCM59056,
BCM590XX_DEVICE_TYPE_BCM59055,
BCM590XX_DEVICE_TYPE_BCM59054,
};

static const struct mfd_cell bcm590xx_devs[] = {
{
.name = "bcm590xx-vregs",
Expand All @@ -51,12 +45,12 @@ static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri,
struct bcm590xx *bcm590xx;
int ret;

printk(id->name);

bcm590xx = devm_kzalloc(&i2c_pri->dev, sizeof(*bcm590xx), GFP_KERNEL);
if (!bcm590xx)
return -ENOMEM;

bcm590xx->device_type = id->name;

i2c_set_clientdata(i2c_pri, bcm590xx);
bcm590xx->dev = &i2c_pri->dev;
bcm590xx->i2c_pri = i2c_pri;
Expand Down Expand Up @@ -102,9 +96,8 @@ static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri,
}

static const struct of_device_id bcm590xx_of_match[] = {
{ .compatible = "brcm,bcm59056", .data = (void *)BCM590XX_DEVICE_TYPE_BCM59056 },
{ .compatible = "brcm,bcm59055", .data = (void *)BCM590XX_DEVICE_TYPE_BCM59055 },
{ .compatible = "brcm,bcm59054", .data = (void *)BCM590XX_DEVICE_TYPE_BCM59054 },
{ .compatible = "brcm,bcm59056", },
{ .compatible = "brcm,bcm59054", },
{ }
};
MODULE_DEVICE_TABLE(of, bcm590xx_of_match);
Expand Down
116 changes: 116 additions & 0 deletions drivers/regulator/bcm59054-regulator.h
@@ -0,0 +1,116 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* bcm59054-regulator.h - Regulator definitions for BCM59054
* (bcm590xx-regulator driver)
*/

#ifndef __BCM59054_REGISTERS_H__
#define __BCM59054_REGISTERS_H__

#include <linux/mfd/bcm590xx.h>

/* I2C slave 0 registers */
#define BCM59054_RFLDOPMCTRL1 0x60
#define BCM59054_IOSR1PMCTRL1 0x7a
#define BCM59054_IOSR2PMCTRL1 0x7c
#define BCM59054_CSRPMCTRL1 0x7e
#define BCM59054_SDSR1PMCTRL1 0x82
#define BCM59054_SDSR2PMCTRL1 0x86
#define BCM59054_MMSRPMCTRL1 0x8a
#define BCM59054_VSRPMCTRL1 0x8e
#define BCM59054_RFLDOCTRL 0x96
#define BCM59054_CSRVOUT1 0xc0

/* I2C slave 1 registers */
#define BCM59054_LVLDO1PMCTRL1 0x16
#define BCM59054_LVLDO2PMCTRL1 0x18
#define BCM59054_GPLDO1CTRL 0x1a
#define BCM59054_GPLDO2CTRL 0x1b
#define BCM59054_GPLDO3CTRL 0x1c
#define BCM59054_TCXLDOCTRL 0x1d
#define BCM59054_LVLDO1CTRL 0x1e
#define BCM59054_LVLDO2CTRL 0x1f
#define BCM59054_OTG_CTRL 0x40
#define BCM59054_GPLDO1PMCTRL1 0x57
#define BCM59054_GPLDO2PMCTRL1 0x59
#define BCM59054_GPLDO3PMCTRL1 0x5b
#define BCM59054_TCXLDOPMCTRL1 0x5d

/*
* RFLDO to VSR regulators are
* accessed via I2C slave 0
*/

/* LDO regulator IDs */
#define BCM59054_REG_RFLDO 0
#define BCM59054_REG_CAMLDO1 1
#define BCM59054_REG_CAMLDO2 2
#define BCM59054_REG_SIMLDO1 3
#define BCM59054_REG_SIMLDO2 4
#define BCM59054_REG_SDLDO 5
#define BCM59054_REG_SDXLDO 6
#define BCM59054_REG_MMCLDO1 7
#define BCM59054_REG_MMCLDO2 8
#define BCM59054_REG_AUDLDO 9
#define BCM59054_REG_MICLDO 10
#define BCM59054_REG_USBLDO 11
#define BCM59054_REG_VIBLDO 12

/* DCDC regulator IDs */
#define BCM59054_REG_CSR 13
#define BCM59054_REG_IOSR1 14
#define BCM59054_REG_IOSR2 15
#define BCM59054_REG_MMSR 16
#define BCM59054_REG_SDSR1 17
#define BCM59054_REG_SDSR2 18
#define BCM59054_REG_VSR 19

/*
* GPLDO1 to LVLDO regulators are
* accessed via I2C slave 1
*/

#define BCM59054_REG_GPLDO1 20
#define BCM59054_REG_GPLDO2 21
#define BCM59054_REG_GPLDO3 22
#define BCM59054_REG_TCXLDO 23
#define BCM59054_REG_LVLDO1 24
#define BCM59054_REG_LVLDO2 25

#define BCM59054_NUM_REGS 26

#define BCM59054_REG_IS_LDO(n) (n < BCM59054_REG_GPLDO1)
#define BCM59054_REG_IS_GPLDO(n) \
((n > BCM59054_REG_VIBLDO) && (n < BCM59054_REG_VSR))
/*#define BCM59054_REG_IS_VBUS(n) (n == BCM59054_REG_VBUS)*/

static struct bcm590xx_info bcm59054_regs[] = {
BCM590XX_REG_TABLE(rfldo, ldo_a_table),
BCM590XX_REG_TABLE(camldo1, ldo_c_table),
BCM590XX_REG_TABLE(camldo2, ldo_c_table),
BCM590XX_REG_TABLE(simldo1, ldo_a_table),
BCM590XX_REG_TABLE(simldo2, ldo_a_table),
BCM590XX_REG_TABLE(sdldo, ldo_c_table),
BCM590XX_REG_TABLE(sdxldo, ldo_a_table),
BCM590XX_REG_TABLE(mmcldo1, ldo_a_table),
BCM590XX_REG_TABLE(mmcldo2, ldo_a_table),
BCM590XX_REG_TABLE(audldo, ldo_a_table),
BCM590XX_REG_TABLE(micldo, ldo_mic),
BCM590XX_REG_TABLE(usbldo, ldo_a_table),
BCM590XX_REG_TABLE(vibldo, ldo_c_table),
BCM590XX_REG_TABLE(gpldo1, ldo_a_table),
BCM590XX_REG_TABLE(gpldo2, ldo_a_table),
BCM590XX_REG_TABLE(gpldo3, ldo_a_table),
BCM590XX_REG_TABLE(tcxldo, ldo_a_table),
BCM590XX_REG_TABLE(lvldo1, ldo_d_table),
BCM590XX_REG_TABLE(lvldo2, ldo_d_table),
BCM590XX_REG_RANGES(vsr, dcdc_iosr1_ranges),
BCM590XX_REG_RANGES(csr, dcdc_csr_ranges),
BCM590XX_REG_RANGES(mmsr, dcdc_iosr1_ranges),
BCM590XX_REG_RANGES(sdsr1, dcdc_sdsr1_ranges),
BCM590XX_REG_RANGES(sdsr2, dcdc_iosr1_ranges),
BCM590XX_REG_RANGES(iosr1, dcdc_iosr1_ranges),
BCM590XX_REG_RANGES(iosr2, dcdc_iosr1_ranges),
};

#endif /* __BCM59054_REGISTERS_H__ */
118 changes: 118 additions & 0 deletions drivers/regulator/bcm59056-regulator.h
@@ -0,0 +1,118 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* bcm59056-regulator.h - Regulator definitions for BCM59056
* (bcm590xx-regulator driver)
*/

#ifndef __BCM59056_REGISTERS_H__
#define __BCM59056_REGISTERS_H__

#include <linux/mfd/bcm590xx.h>

/* I2C slave 0 registers */
#define BCM59056_RFLDOPMCTRL1 0x60
#define BCM59056_IOSR1PMCTRL1 0x7a
#define BCM59056_IOSR2PMCTRL1 0x7c
#define BCM59056_CSRPMCTRL1 0x7e
#define BCM59056_SDSR1PMCTRL1 0x82
#define BCM59056_SDSR2PMCTRL1 0x86
#define BCM59056_MSRPMCTRL1 0x8a
#define BCM59056_VSRPMCTRL1 0x8e
#define BCM59056_RFLDOCTRL 0x96
#define BCM59056_CSRVOUT1 0xc0

/* I2C slave 1 registers */
#define BCM59056_GPLDO5PMCTRL1 0x16
#define BCM59056_GPLDO6PMCTRL1 0x18
#define BCM59056_GPLDO1CTRL 0x1a
#define BCM59056_GPLDO2CTRL 0x1b
#define BCM59056_GPLDO3CTRL 0x1c
#define BCM59056_GPLDO4CTRL 0x1d
#define BCM59056_GPLDO5CTRL 0x1e
#define BCM59056_GPLDO6CTRL 0x1f
#define BCM59056_OTG_CTRL 0x40
#define BCM59056_GPLDO1PMCTRL1 0x57
#define BCM59056_GPLDO2PMCTRL1 0x59
#define BCM59056_GPLDO3PMCTRL1 0x5b
#define BCM59056_GPLDO4PMCTRL1 0x5d

/*
* RFLDO to VSR regulators are
* accessed via I2C slave 0
*/

/* LDO regulator IDs */
#define BCM59056_REG_RFLDO 0
#define BCM59056_REG_CAMLDO1 1
#define BCM59056_REG_CAMLDO2 2
#define BCM59056_REG_SIMLDO1 3
#define BCM59056_REG_SIMLDO2 4
#define BCM59056_REG_SDLDO 5
#define BCM59056_REG_SDXLDO 6
#define BCM59056_REG_MMCLDO1 7
#define BCM59056_REG_MMCLDO2 8
#define BCM59056_REG_AUDLDO 9
#define BCM59056_REG_MICLDO 10
#define BCM59056_REG_USBLDO 11
#define BCM59056_REG_VIBLDO 12

/* DCDC regulator IDs */
#define BCM59056_REG_CSR 13
#define BCM59056_REG_IOSR1 14
#define BCM59056_REG_IOSR2 15
#define BCM59056_REG_MSR 16
#define BCM59056_REG_SDSR1 17
#define BCM59056_REG_SDSR2 18
#define BCM59056_REG_VSR 19

/*
* GPLDO1 to VBUS regulators are
* accessed via I2C slave 1
*/

#define BCM59056_REG_GPLDO1 20
#define BCM59056_REG_GPLDO2 21
#define BCM59056_REG_GPLDO3 22
#define BCM59056_REG_GPLDO4 23
#define BCM59056_REG_GPLDO5 24
#define BCM59056_REG_GPLDO6 25
#define BCM59056_REG_VBUS 26

#define BCM59056_NUM_REGS 27

#define BCM59056_REG_IS_LDO(n) (n < BCM59056_REG_CSR)
#define BCM59056_REG_IS_GPLDO(n) \
((n > BCM59056_REG_VSR) && (n < BCM59056_REG_VBUS))
#define BCM59056_REG_IS_VBUS(n) (n == BCM59056_REG_VBUS)

static struct bcm590xx_info bcm59056_regs[] = {
BCM590XX_REG_TABLE(rfldo, ldo_a_table),
BCM590XX_REG_TABLE(camldo1, ldo_c_table),
BCM590XX_REG_TABLE(camldo2, ldo_c_table),
BCM590XX_REG_TABLE(simldo1, ldo_a_table),
BCM590XX_REG_TABLE(simldo2, ldo_a_table),
BCM590XX_REG_TABLE(sdldo, ldo_c_table),
BCM590XX_REG_TABLE(sdxldo, ldo_a_table),
BCM590XX_REG_TABLE(mmcldo1, ldo_a_table),
BCM590XX_REG_TABLE(mmcldo2, ldo_a_table),
BCM590XX_REG_TABLE(audldo, ldo_a_table),
BCM590XX_REG_TABLE(micldo, ldo_a_table),
BCM590XX_REG_TABLE(usbldo, ldo_a_table),
BCM590XX_REG_TABLE(vibldo, ldo_c_table),
BCM590XX_REG_RANGES(csr, dcdc_csr_ranges),
BCM590XX_REG_RANGES(iosr1, dcdc_iosr1_ranges),
BCM590XX_REG_RANGES(iosr2, dcdc_iosr1_ranges),
BCM590XX_REG_RANGES(msr, dcdc_iosr1_ranges),
BCM590XX_REG_RANGES(sdsr1, dcdc_sdsr1_ranges),
BCM590XX_REG_RANGES(sdsr2, dcdc_iosr1_ranges),
BCM590XX_REG_RANGES(vsr, dcdc_iosr1_ranges),
BCM590XX_REG_TABLE(gpldo1, ldo_a_table),
BCM590XX_REG_TABLE(gpldo2, ldo_a_table),
BCM590XX_REG_TABLE(gpldo3, ldo_a_table),
BCM590XX_REG_TABLE(gpldo4, ldo_a_table),
BCM590XX_REG_TABLE(gpldo5, ldo_a_table),
BCM590XX_REG_TABLE(gpldo6, ldo_a_table),
BCM590XX_REG_TABLE(vbus, ldo_vbus),
};

#endif /* __BCM59056_REGISTERS_H__ */

0 comments on commit 80ff432

Please sign in to comment.