Skip to content

Commit

Permalink
ARM: mach-shmobile: bonito: add PMIC settings
Browse files Browse the repository at this point in the history
bonito board needs some settings by pmic which use i2c access.
It is dependent on the device to be used.
This patch adds standard settings.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
  • Loading branch information
Kuninori Morimoto authored and Paul Mundt committed Nov 11, 2011
1 parent b6b37e2 commit e609b7c
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions arch/arm/mach-shmobile/board-bonito.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

#include <linux/kernel.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
Expand Down Expand Up @@ -83,6 +84,56 @@ static void bonito_fpga_write(u32 offset, u16 val)
__raw_writew(val, 0xf0003000 + offset);
}

/*
* PMIC settings
*
* FIXME
*
* bonito board needs some settings by pmic which use i2c access.
* pmic settings use device_initcall() here for use it.
*/
static __u8 *pmic_settings = NULL;
static __u8 pmic_do_2A[] = {
0x1C, 0x09,
0x1A, 0x80,
0xff, 0xff,
};

static int __init pmic_init(void)
{
struct i2c_adapter *a = i2c_get_adapter(0);
struct i2c_msg msg;
__u8 buf[2];
int i, ret;

if (!pmic_settings)
return 0;
if (!a)
return 0;

msg.addr = 0x46;
msg.buf = buf;
msg.len = 2;
msg.flags = 0;

for (i = 0; ; i += 2) {
buf[0] = pmic_settings[i + 0];
buf[1] = pmic_settings[i + 1];

if ((0xff == buf[0]) && (0xff == buf[1]))
break;

ret = i2c_transfer(a, &msg, 1);
if (ret < 0) {
pr_err("i2c transfer fail\n");
break;
}
}

return 0;
}
device_initcall(pmic_init);

/*
* core board devices
*/
Expand Down Expand Up @@ -154,6 +205,8 @@ static void __init bonito_init(void)

r8a7740_pinmux_init();

pmic_settings = pmic_do_2A;

/*
* core board settings
*/
Expand Down

0 comments on commit e609b7c

Please sign in to comment.