aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-shmobile
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2013-02-12 12:15:31 -0500
committerSimon Horman <horms+renesas@verge.net.au>2013-06-07 01:26:31 -0400
commit28307e0a7c3841f2d54876639235c07ebe3d2999 (patch)
treeab8b7a1d5b3da82da279c2790070ccf71ba64e86 /arch/arm/mach-shmobile
parentdf53721a60022263017c5d72e17a7780d0e5dc4c (diff)
ARM: shmobile: kzm9g: add AS3711 PMIC platform data
KZM9G uses an AS3711 PMIC to supply power to the CPU and the LCD backlight. The PMIC on the board is pre-programmed to supply correct voltages to the CPU, power supply to the backlight has to be turned on at run-time. The latter is currently performed by a hard-coded I2C command sequence in the board file. This patch removes the backlight hack and instead adds an I2C device to instantiate the AS3711 MFD driver, which will add a regulator device to dynamically adjust CPU voltages and a backlight device. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Diffstat (limited to 'arch/arm/mach-shmobile')
-rw-r--r--arch/arm/mach-shmobile/board-kzm9g.c193
1 files changed, 140 insertions, 53 deletions
diff --git a/arch/arm/mach-shmobile/board-kzm9g.c b/arch/arm/mach-shmobile/board-kzm9g.c
index 1fdf05cb6da1..165483c9bee2 100644
--- a/arch/arm/mach-shmobile/board-kzm9g.c
+++ b/arch/arm/mach-shmobile/board-kzm9g.c
@@ -29,6 +29,7 @@
29#include <linux/mmc/host.h> 29#include <linux/mmc/host.h>
30#include <linux/mmc/sh_mmcif.h> 30#include <linux/mmc/sh_mmcif.h>
31#include <linux/mmc/sh_mobile_sdhi.h> 31#include <linux/mmc/sh_mobile_sdhi.h>
32#include <linux/mfd/as3711.h>
32#include <linux/mfd/tmio.h> 33#include <linux/mfd/tmio.h>
33#include <linux/pinctrl/machine.h> 34#include <linux/pinctrl/machine.h>
34#include <linux/pinctrl/pinconf-generic.h> 35#include <linux/pinctrl/pinconf-generic.h>
@@ -606,6 +607,140 @@ static struct platform_device fsi_ak4648_device = {
606}; 607};
607 608
608/* I2C */ 609/* I2C */
610
611/* StepDown1 is used to supply 1.315V to the CPU */
612static struct regulator_init_data as3711_sd1 = {
613 .constraints = {
614 .name = "1.315V CPU",
615 .boot_on = 1,
616 .always_on = 1,
617 .min_uV = 1315000,
618 .max_uV = 1335000,
619 },
620};
621
622/* StepDown2 is used to supply 1.8V to the CPU and to the board */
623static struct regulator_init_data as3711_sd2 = {
624 .constraints = {
625 .name = "1.8V",
626 .boot_on = 1,
627 .always_on = 1,
628 .min_uV = 1800000,
629 .max_uV = 1800000,
630 },
631};
632
633/*
634 * StepDown3 is switched in parallel with StepDown2, seems to be off,
635 * according to read-back pre-set register values
636 */
637
638/* StepDown4 is used to supply 1.215V to the CPU and to the board */
639static struct regulator_init_data as3711_sd4 = {
640 .constraints = {
641 .name = "1.215V",
642 .boot_on = 1,
643 .always_on = 1,
644 .min_uV = 1215000,
645 .max_uV = 1235000,
646 },
647};
648
649/* LDO1 is unused and unconnected */
650
651/* LDO2 is used to supply 2.8V to the CPU */
652static struct regulator_init_data as3711_ldo2 = {
653 .constraints = {
654 .name = "2.8V CPU",
655 .boot_on = 1,
656 .always_on = 1,
657 .min_uV = 2800000,
658 .max_uV = 2800000,
659 },
660};
661
662/* LDO3 is used to supply 3.0V to the CPU */
663static struct regulator_init_data as3711_ldo3 = {
664 .constraints = {
665 .name = "3.0V CPU",
666 .boot_on = 1,
667 .always_on = 1,
668 .min_uV = 3000000,
669 .max_uV = 3000000,
670 },
671};
672
673/* LDO4 is used to supply 2.8V to the board */
674static struct regulator_init_data as3711_ldo4 = {
675 .constraints = {
676 .name = "2.8V",
677 .boot_on = 1,
678 .always_on = 1,
679 .min_uV = 2800000,
680 .max_uV = 2800000,
681 },
682};
683
684/* LDO5 is switched parallel to LDO4, also set to 2.8V */
685static struct regulator_init_data as3711_ldo5 = {
686 .constraints = {
687 .name = "2.8V #2",
688 .boot_on = 1,
689 .always_on = 1,
690 .min_uV = 2800000,
691 .max_uV = 2800000,
692 },
693};
694
695/* LDO6 is unused and unconnected */
696
697/* LDO7 is used to supply 1.15V to the CPU */
698static struct regulator_init_data as3711_ldo7 = {
699 .constraints = {
700 .name = "1.15V CPU",
701 .boot_on = 1,
702 .always_on = 1,
703 .min_uV = 1150000,
704 .max_uV = 1150000,
705 },
706};
707
708/* LDO8 is switched parallel to LDO7, also set to 1.15V */
709static struct regulator_init_data as3711_ldo8 = {
710 .constraints = {
711 .name = "1.15V CPU #2",
712 .boot_on = 1,
713 .always_on = 1,
714 .min_uV = 1150000,
715 .max_uV = 1150000,
716 },
717};
718
719static struct as3711_platform_data as3711_pdata = {
720 .regulator = {
721 .init_data = {
722 [AS3711_REGULATOR_SD_1] = &as3711_sd1,
723 [AS3711_REGULATOR_SD_2] = &as3711_sd2,
724 [AS3711_REGULATOR_SD_4] = &as3711_sd4,
725 [AS3711_REGULATOR_LDO_2] = &as3711_ldo2,
726 [AS3711_REGULATOR_LDO_3] = &as3711_ldo3,
727 [AS3711_REGULATOR_LDO_4] = &as3711_ldo4,
728 [AS3711_REGULATOR_LDO_5] = &as3711_ldo5,
729 [AS3711_REGULATOR_LDO_7] = &as3711_ldo7,
730 [AS3711_REGULATOR_LDO_8] = &as3711_ldo8,
731 },
732 },
733 .backlight = {
734 .su2_fb = "sh_mobile_lcdc_fb.0",
735 .su2_max_uA = 36000,
736 .su2_feedback = AS3711_SU2_CURR_AUTO,
737 .su2_fbprot = AS3711_SU2_GPIO4,
738 .su2_auto_curr1 = true,
739 .su2_auto_curr2 = true,
740 .su2_auto_curr3 = true,
741 },
742};
743
609static struct pcf857x_platform_data pcf8575_pdata = { 744static struct pcf857x_platform_data pcf8575_pdata = {
610 .gpio_base = GPIO_PCF8575_BASE, 745 .gpio_base = GPIO_PCF8575_BASE,
611}; 746};
@@ -625,6 +760,11 @@ static struct i2c_board_info i2c0_devices[] = {
625 I2C_BOARD_INFO("adxl34x", 0x1d), 760 I2C_BOARD_INFO("adxl34x", 0x1d),
626 .irq = irq_pin(26), /* IRQ26 */ 761 .irq = irq_pin(26), /* IRQ26 */
627 }, 762 },
763 {
764 I2C_BOARD_INFO("as3711", 0x40),
765 .irq = intcs_evt2irq(0x3300), /* IRQ24 */
766 .platform_data = &as3711_pdata,
767 },
628}; 768};
629 769
630static struct i2c_board_info i2c1_devices[] = { 770static struct i2c_board_info i2c1_devices[] = {
@@ -715,59 +855,6 @@ static const struct pinctrl_map kzm_pinctrl_map[] = {
715 "usb_vbus", "usb"), 855 "usb_vbus", "usb"),
716}; 856};
717 857
718/*
719 * FIXME
720 *
721 * This is quick hack for enabling LCDC backlight
722 */
723static int __init as3711_enable_lcdc_backlight(void)
724{
725 struct i2c_adapter *a = i2c_get_adapter(0);
726 struct i2c_msg msg;
727 int i, ret;
728 __u8 magic[] = {
729 0x40, 0x2a,
730 0x43, 0x3c,
731 0x44, 0x3c,
732 0x45, 0x3c,
733 0x54, 0x03,
734 0x51, 0x00,
735 0x51, 0x01,
736 0xff, 0x00, /* wait */
737 0x43, 0xf0,
738 0x44, 0xf0,
739 0x45, 0xf0,
740 };
741
742 if (!of_machine_is_compatible("renesas,kzm9g"))
743 return 0;
744
745 if (!a)
746 return 0;
747
748 msg.addr = 0x40;
749 msg.len = 2;
750 msg.flags = 0;
751
752 for (i = 0; i < ARRAY_SIZE(magic); i += 2) {
753 msg.buf = magic + i;
754
755 if (0xff == msg.buf[0]) {
756 udelay(500);
757 continue;
758 }
759
760 ret = i2c_transfer(a, &msg, 1);
761 if (ret < 0) {
762 pr_err("i2c transfer fail\n");
763 break;
764 }
765 }
766
767 return 0;
768}
769device_initcall(as3711_enable_lcdc_backlight);
770
771static void __init kzm_init(void) 858static void __init kzm_init(void)
772{ 859{
773 regulator_register_always_on(2, "fixed-1.8V", fixed1v8_power_consumers, 860 regulator_register_always_on(2, "fixed-1.8V", fixed1v8_power_consumers,