9
0
Fork 0

Merge branch 'for-next/mc13xxx'

This commit is contained in:
Sascha Hauer 2012-09-05 12:59:29 +02:00
commit 2c8c801c67
5 changed files with 36 additions and 22 deletions

View File

@ -307,7 +307,7 @@ static int ccxmx51_power_init(void)
mc13xxx_reg_write(mc13xxx_dev, MC13892_REG_SW_2, val);
}
if (mc13xxx_dev->revision <= MC13892_REVISION_2_0) {
if (mc13xxx_revision(mc13xxx_dev) <= MC13892_REVISION_2_0) {
/* Set switchers in PWM mode for Atlas 2.0 and lower */
/* Setup the switcher mode for SW1 & SW2*/
mc13xxx_reg_read(mc13xxx_dev, MC13892_REG_SW_4, &val);

View File

@ -362,7 +362,6 @@ static int f3s_get_rev(struct mc13xxx *mc13xxx)
if (err)
return err;
dev_info(&mc13xxx->client->dev, "revision: 0x%x\n", rev);
if (rev == 0x00ffffff)
return -ENODEV;
@ -379,8 +378,7 @@ static int f3s_pmic_init_v2(struct mc13xxx *mc13xxx)
err |= mc13xxx_set_bits(mc13xxx, MC13892_REG_SETTING_0, 0x03, 0x03);
err |= mc13xxx_set_bits(mc13xxx, MC13892_REG_MODE_0, 0x01, 0x01);
if (err)
dev_err(&mc13xxx->client->dev,
"Init sequence failed, the system might not be working!\n");
printf("mc13892 Init sequence failed, the system might not be working!\n");
return err;
}

View File

@ -178,7 +178,7 @@ static void babbage_power_init(void)
mc13xxx_reg_write(mc13xxx, MC13892_REG_SW_2, val);
}
if (mc13xxx->revision < MC13892_REVISION_2_0) {
if (mc13xxx_revision(mc13xxx) < MC13892_REVISION_2_0) {
/* Set switchers in PWM mode for Atlas 2.0 and lower */
/* Setup the switcher mode for SW1 & SW2*/
mc13xxx_reg_read(mc13xxx, MC13892_REG_SW_4, &val);

View File

@ -32,6 +32,21 @@
#define DRIVERNAME "mc13xxx"
enum mc13xxx_mode {
MC13XXX_MODE_I2C,
MC13XXX_MODE_SPI,
};
struct mc13xxx {
struct cdev cdev;
union {
struct i2c_client *client;
struct spi_device *spi;
};
enum mc13xxx_mode mode;
int revision;
};
#define to_mc13xxx(a) container_of(a, struct mc13xxx, cdev)
static struct mc13xxx *mc_dev;
@ -42,6 +57,12 @@ struct mc13xxx *mc13xxx_get(void)
}
EXPORT_SYMBOL(mc13xxx_get);
int mc13xxx_revision(struct mc13xxx *mc13xxx)
{
return mc13xxx->revision;
}
EXPORT_SYMBOL(mc13xxx_revision);
#ifdef CONFIG_SPI
static int spi_rw(struct spi_device *spi, void * buf, size_t len)
{
@ -231,7 +252,7 @@ static struct mc13892_rev mc13892_revisions[] = {
static int mc13xxx_query_revision(struct mc13xxx *mc13xxx)
{
unsigned int rev_id;
char *chipname, *revstr;
char *chipname, revstr[5];
int rev, i;
mc13xxx_reg_read(mc13xxx, MC13XXX_REG_IDENTIFICATION, &rev_id);
@ -244,9 +265,9 @@ static int mc13xxx_query_revision(struct mc13xxx *mc13xxx)
/* Ver 0.2 is actually 3.2a. Report as 3.2 */
if (rev == 0x02) {
rev = 0x32;
revstr = "3.2a";
strcpy(revstr, "3.2a");
} else
revstr = asprintf("%d.%d", rev / 0x10, rev % 10);
sprintf(revstr, "%d.%d", rev / 0x10, rev % 10);
break;
case 7:
chipname = "MC13892";
@ -258,12 +279,12 @@ static int mc13xxx_query_revision(struct mc13xxx *mc13xxx)
return -EINVAL;
rev = mc13892_revisions[i].rev;
revstr = mc13892_revisions[i].revstr;
strcpy(revstr, mc13892_revisions[i].revstr);
if (rev == MC13892_REVISION_2_0) {
if ((rev_id >> 9) & 0x3) {
rev = MC13892_REVISION_2_0a;
revstr = "2.0a";
strcpy(revstr, "2.0a");
}
}
break;

View File

@ -150,21 +150,11 @@
#define MC13783_SW1B_SOFTSTART (1 << 17)
#define MC13783_SW_PLL_FACTOR(x) (((x) - 28) << 19)
enum mc13xxx_mode {
MC13XXX_MODE_I2C,
MC13XXX_MODE_SPI,
};
struct mc13xxx {
struct cdev cdev;
struct i2c_client *client;
struct spi_device *spi;
enum mc13xxx_mode mode;
int revision;
};
struct mc13xxx;
#ifdef CONFIG_MFD_MC13XXX
extern struct mc13xxx *mc13xxx_get(void);
extern int mc13xxx_revision(struct mc13xxx *mc13xxx);
extern int mc13xxx_reg_read(struct mc13xxx *mc13xxx, u8 reg, u32 *val);
extern int mc13xxx_reg_write(struct mc13xxx *mc13xxx, u8 reg, u32 val);
extern int mc13xxx_set_bits(struct mc13xxx *mc13xxx, u8 reg, u32 mask, u32 val);
@ -174,6 +164,11 @@ static inline struct mc13xxx *mc13xxx_get(void)
return NULL;
}
static inline int mc13xxx_revision(struct mc13xxx *mc13xxx)
{
return -ENODEV;
}
static inline int mc13xxx_reg_read(struct mc13xxx *mc13xxx, u8 reg, u32 *val)
{
return -ENODEV;