aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/mioa701.c
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-12-02 17:07:40 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-12-02 17:07:40 -0500
commitc5b84b3bb0c055d70dc9f1b5e900378bc9d059ea (patch)
treebd5b0b4efb552bacd812f9e6e08a29bae70c0da1 /arch/arm/mach-pxa/mioa701.c
parentd281bc9d8a22419abc254f86a7fc268bb99914e1 (diff)
parentbc2fd1c09c226ea47ab8301cde6dbcf9e5c78b73 (diff)
Merge branch 'for-rmk' of git://git.kernel.org/pub/scm/linux/kernel/git/ycmiao/pxa-linux-2.6 into devel
Conflicts: arch/arm/mach-pxa/pxa25x.c
Diffstat (limited to 'arch/arm/mach-pxa/mioa701.c')
-rw-r--r--arch/arm/mach-pxa/mioa701.c203
1 files changed, 82 insertions, 121 deletions
diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index 782903fe9c6c..2b427e015b6f 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -34,7 +34,7 @@
34#include <linux/irq.h> 34#include <linux/irq.h>
35#include <linux/pda_power.h> 35#include <linux/pda_power.h>
36#include <linux/power_supply.h> 36#include <linux/power_supply.h>
37#include <linux/wm97xx.h> 37#include <linux/wm97xx_batt.h>
38#include <linux/mtd/physmap.h> 38#include <linux/mtd/physmap.h>
39 39
40#include <asm/mach-types.h> 40#include <asm/mach-types.h>
@@ -46,6 +46,9 @@
46#include <mach/mmc.h> 46#include <mach/mmc.h>
47#include <mach/udc.h> 47#include <mach/udc.h>
48#include <mach/pxa27x-udc.h> 48#include <mach/pxa27x-udc.h>
49#include <mach/i2c.h>
50#include <mach/camera.h>
51#include <media/soc_camera.h>
49 52
50#include <mach/mioa701.h> 53#include <mach/mioa701.h>
51 54
@@ -54,10 +57,11 @@
54 57
55static unsigned long mioa701_pin_config[] = { 58static unsigned long mioa701_pin_config[] = {
56 /* Mio global */ 59 /* Mio global */
57 MIO_CFG_OUT(GPIO9_CHARGE_nEN, AF0, DRIVE_LOW), 60 MIO_CFG_OUT(GPIO9_CHARGE_EN, AF0, DRIVE_LOW),
58 MIO_CFG_OUT(GPIO18_POWEROFF, AF0, DRIVE_LOW), 61 MIO_CFG_OUT(GPIO18_POWEROFF, AF0, DRIVE_LOW),
59 MFP_CFG_OUT(GPIO3, AF0, DRIVE_HIGH), 62 MFP_CFG_OUT(GPIO3, AF0, DRIVE_HIGH),
60 MFP_CFG_OUT(GPIO4, AF0, DRIVE_HIGH), 63 MFP_CFG_OUT(GPIO4, AF0, DRIVE_HIGH),
64 MIO_CFG_IN(GPIO80_MAYBE_CHARGE_VDROP, AF0),
61 65
62 /* Backlight PWM 0 */ 66 /* Backlight PWM 0 */
63 GPIO16_PWM0_OUT, 67 GPIO16_PWM0_OUT,
@@ -74,7 +78,7 @@ static unsigned long mioa701_pin_config[] = {
74 MIO_CFG_OUT(GPIO91_SDIO_EN, AF0, DRIVE_LOW), 78 MIO_CFG_OUT(GPIO91_SDIO_EN, AF0, DRIVE_LOW),
75 79
76 /* USB */ 80 /* USB */
77 MIO_CFG_IN(GPIO13_USB_DETECT, AF0), 81 MIO_CFG_IN(GPIO13_nUSB_DETECT, AF0),
78 MIO_CFG_OUT(GPIO22_USB_ENABLE, AF0, DRIVE_LOW), 82 MIO_CFG_OUT(GPIO22_USB_ENABLE, AF0, DRIVE_LOW),
79 83
80 /* LCD */ 84 /* LCD */
@@ -98,12 +102,29 @@ static unsigned long mioa701_pin_config[] = {
98 GPIO75_LCD_LCLK, 102 GPIO75_LCD_LCLK,
99 GPIO76_LCD_PCLK, 103 GPIO76_LCD_PCLK,
100 104
105 /* QCI */
106 GPIO12_CIF_DD_7,
107 GPIO17_CIF_DD_6,
108 GPIO50_CIF_DD_3,
109 GPIO51_CIF_DD_2,
110 GPIO52_CIF_DD_4,
111 GPIO53_CIF_MCLK,
112 GPIO54_CIF_PCLK,
113 GPIO55_CIF_DD_1,
114 GPIO81_CIF_DD_0,
115 GPIO82_CIF_DD_5,
116 GPIO84_CIF_FV,
117 GPIO85_CIF_LV,
118
101 /* Bluetooth */ 119 /* Bluetooth */
120 MIO_CFG_IN(GPIO14_BT_nACTIVITY, AF0),
102 GPIO44_BTUART_CTS, 121 GPIO44_BTUART_CTS,
103 GPIO42_BTUART_RXD, 122 GPIO42_BTUART_RXD,
104 GPIO45_BTUART_RTS, 123 GPIO45_BTUART_RTS,
105 GPIO43_BTUART_TXD, 124 GPIO43_BTUART_TXD,
106 MIO_CFG_OUT(GPIO83_BT_ON, AF0, DRIVE_LOW), 125 MIO_CFG_OUT(GPIO83_BT_ON, AF0, DRIVE_LOW),
126 MIO_CFG_OUT(GPIO77_BT_UNKNOWN1, AF0, DRIVE_HIGH),
127 MIO_CFG_OUT(GPIO86_BT_MAYBE_nRESET, AF0, DRIVE_HIGH),
107 128
108 /* GPS */ 129 /* GPS */
109 MIO_CFG_OUT(GPIO23_GPS_UNKNOWN1, AF0, DRIVE_LOW), 130 MIO_CFG_OUT(GPIO23_GPS_UNKNOWN1, AF0, DRIVE_LOW),
@@ -151,16 +172,16 @@ static unsigned long mioa701_pin_config[] = {
151 GPIO104_KP_MKOUT_1, 172 GPIO104_KP_MKOUT_1,
152 GPIO105_KP_MKOUT_2, 173 GPIO105_KP_MKOUT_2,
153 174
175 /* I2C */
176 GPIO117_I2C_SCL,
177 GPIO118_I2C_SDA,
178
154 /* Unknown */ 179 /* Unknown */
155 MFP_CFG_IN(GPIO14, AF0),
156 MFP_CFG_IN(GPIO20, AF0), 180 MFP_CFG_IN(GPIO20, AF0),
157 MFP_CFG_IN(GPIO21, AF0), 181 MFP_CFG_IN(GPIO21, AF0),
158 MFP_CFG_IN(GPIO33, AF0), 182 MFP_CFG_IN(GPIO33, AF0),
159 MFP_CFG_OUT(GPIO49, AF0, DRIVE_HIGH), 183 MFP_CFG_OUT(GPIO49, AF0, DRIVE_HIGH),
160 MFP_CFG_OUT(GPIO57, AF0, DRIVE_HIGH), 184 MFP_CFG_OUT(GPIO57, AF0, DRIVE_HIGH),
161 MFP_CFG_OUT(GPIO77, AF0, DRIVE_HIGH),
162 MFP_CFG_IN(GPIO80, AF0),
163 MFP_CFG_OUT(GPIO86, AF0, DRIVE_HIGH),
164 MFP_CFG_IN(GPIO96, AF0), 185 MFP_CFG_IN(GPIO96, AF0),
165 MFP_CFG_OUT(GPIO116, AF0, DRIVE_HIGH), 186 MFP_CFG_OUT(GPIO116, AF0, DRIVE_HIGH),
166}; 187};
@@ -407,7 +428,7 @@ static void udc_power_command(int cmd)
407 428
408static int is_usb_connected(void) 429static int is_usb_connected(void)
409{ 430{
410 return !!gpio_get_value(GPIO13_USB_DETECT); 431 return !gpio_get_value(GPIO13_nUSB_DETECT);
411} 432}
412 433
413static struct pxa2xx_udc_mach_info mioa701_udc_info = { 434static struct pxa2xx_udc_mach_info mioa701_udc_info = {
@@ -659,13 +680,19 @@ static char *supplicants[] = {
659 "mioa701_battery" 680 "mioa701_battery"
660}; 681};
661 682
683static int is_ac_connected(void)
684{
685 return gpio_get_value(GPIO96_AC_DETECT);
686}
687
662static void mioa701_set_charge(int flags) 688static void mioa701_set_charge(int flags)
663{ 689{
664 gpio_set_value(GPIO9_CHARGE_nEN, !flags); 690 gpio_set_value(GPIO9_CHARGE_EN, (flags == PDA_POWER_CHARGE_USB));
665} 691}
666 692
667static struct pda_power_pdata power_pdata = { 693static struct pda_power_pdata power_pdata = {
668 .is_ac_online = is_usb_connected, 694 .is_ac_online = is_ac_connected,
695 .is_usb_online = is_usb_connected,
669 .set_charge = mioa701_set_charge, 696 .set_charge = mioa701_set_charge,
670 .supplied_to = supplicants, 697 .supplied_to = supplicants,
671 .num_supplicants = ARRAY_SIZE(supplicants), 698 .num_supplicants = ARRAY_SIZE(supplicants),
@@ -674,8 +701,15 @@ static struct pda_power_pdata power_pdata = {
674static struct resource power_resources[] = { 701static struct resource power_resources[] = {
675 [0] = { 702 [0] = {
676 .name = "ac", 703 .name = "ac",
677 .start = gpio_to_irq(GPIO13_USB_DETECT), 704 .start = gpio_to_irq(GPIO96_AC_DETECT),
678 .end = gpio_to_irq(GPIO13_USB_DETECT), 705 .end = gpio_to_irq(GPIO96_AC_DETECT),
706 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
707 IORESOURCE_IRQ_LOWEDGE,
708 },
709 [1] = {
710 .name = "usb",
711 .start = gpio_to_irq(GPIO13_nUSB_DETECT),
712 .end = gpio_to_irq(GPIO13_nUSB_DETECT),
679 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | 713 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE |
680 IORESOURCE_IRQ_LOWEDGE, 714 IORESOURCE_IRQ_LOWEDGE,
681 }, 715 },
@@ -691,120 +725,43 @@ static struct platform_device power_dev = {
691 }, 725 },
692}; 726};
693 727
694#if defined(CONFIG_PDA_POWER) && defined(CONFIG_TOUCHSCREEN_WM97XX) 728static struct wm97xx_batt_info mioa701_battery_data = {
695static struct wm97xx *battery_wm; 729 .batt_aux = WM97XX_AUX_ID1,
696 730 .temp_aux = -1,
697static enum power_supply_property battery_props[] = { 731 .charge_gpio = -1,
698 POWER_SUPPLY_PROP_STATUS, 732 .min_voltage = 0xc00,
699 POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, 733 .max_voltage = 0xfc0,
700 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, 734 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LION,
701 POWER_SUPPLY_PROP_VOLTAGE_NOW, 735 .batt_div = 1,
702 POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, /* Necessary for apm */ 736 .batt_mult = 1,
737 .batt_name = "mioa701_battery",
703}; 738};
704 739
705static int get_battery_voltage(void) 740/*
706{ 741 * Camera interface
707 int adc = -1; 742 */
708 743struct pxacamera_platform_data mioa701_pxacamera_platform_data = {
709 if (battery_wm) 744 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
710 adc = wm97xx_read_aux_adc(battery_wm, WM97XX_AUX_ID1); 745 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
711 return adc; 746 .mclk_10khz = 5000,
712}
713
714static int get_battery_status(struct power_supply *b)
715{
716 int status;
717
718 if (is_usb_connected())
719 status = POWER_SUPPLY_STATUS_CHARGING;
720 else
721 status = POWER_SUPPLY_STATUS_DISCHARGING;
722
723 return status;
724}
725
726static int get_property(struct power_supply *b,
727 enum power_supply_property psp,
728 union power_supply_propval *val)
729{
730 int rc = 0;
731
732 switch (psp) {
733 case POWER_SUPPLY_PROP_STATUS:
734 val->intval = get_battery_status(b);
735 break;
736 case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
737 val->intval = 0xfd0;
738 break;
739 case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
740 val->intval = 0xc00;
741 break;
742 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
743 val->intval = get_battery_voltage();
744 break;
745 case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
746 val->intval = 100;
747 break;
748 default:
749 val->intval = -1;
750 rc = -1;
751 }
752
753 return rc;
754}; 747};
755 748
756static struct power_supply battery_ps = { 749static struct soc_camera_link iclink = {
757 .name = "mioa701_battery", 750 .bus_id = 0, /* Must match id in pxa27x_device_camera in device.c */
758 .type = POWER_SUPPLY_TYPE_BATTERY,
759 .get_property = get_property,
760 .properties = battery_props,
761 .num_properties = ARRAY_SIZE(battery_props),
762}; 751};
763 752
764static int battery_probe(struct platform_device *pdev) 753/* Board I2C devices. */
765{ 754static struct i2c_board_info __initdata mioa701_i2c_devices[] = {
766 struct wm97xx *wm = platform_get_drvdata(pdev); 755 {
767 int rc; 756 /* Must initialize before the camera(s) */
768 757 I2C_BOARD_INFO("mt9m111", 0x5d),
769 battery_wm = wm; 758 .platform_data = &iclink,
770
771 rc = power_supply_register(NULL, &battery_ps);
772 if (rc)
773 dev_err(&pdev->dev,
774 "Could not register mioa701 battery -> %d\n", rc);
775 return rc;
776}
777
778static int battery_remove(struct platform_device *pdev)
779{
780 battery_wm = NULL;
781 return 0;
782}
783
784static struct platform_driver mioa701_battery_driver = {
785 .driver = {
786 .name = "wm97xx-battery",
787 }, 759 },
788 .probe = battery_probe,
789 .remove = battery_remove
790}; 760};
791 761
792static int __init mioa701_battery_init(void) 762struct i2c_pxa_platform_data i2c_pdata = {
793{ 763 .fast_mode = 1,
794 int rc; 764};
795
796 rc = platform_driver_register(&mioa701_battery_driver);
797 if (rc)
798 printk(KERN_ERR "Could not register mioa701 battery driver\n");
799 return rc;
800}
801
802#else
803static int __init mioa701_battery_init(void)
804{
805 return 0;
806}
807#endif
808 765
809/* 766/*
810 * Mio global 767 * Mio global
@@ -851,17 +808,17 @@ static void mioa701_machine_exit(void);
851static void mioa701_poweroff(void) 808static void mioa701_poweroff(void)
852{ 809{
853 mioa701_machine_exit(); 810 mioa701_machine_exit();
854 gpio_set_value(GPIO18_POWEROFF, 1); 811 arm_machine_restart('s');
855} 812}
856 813
857static void mioa701_restart(char c) 814static void mioa701_restart(char c)
858{ 815{
859 mioa701_machine_exit(); 816 mioa701_machine_exit();
860 arm_machine_restart(c); 817 arm_machine_restart('s');
861} 818}
862 819
863struct gpio_ress global_gpios[] = { 820struct gpio_ress global_gpios[] = {
864 MIO_GPIO_OUT(GPIO9_CHARGE_nEN, 1, "Charger enable"), 821 MIO_GPIO_OUT(GPIO9_CHARGE_EN, 1, "Charger enable"),
865 MIO_GPIO_OUT(GPIO18_POWEROFF, 0, "Power Off"), 822 MIO_GPIO_OUT(GPIO18_POWEROFF, 0, "Power Off"),
866 MIO_GPIO_OUT(GPIO87_LCD_POWER, 0, "LCD Power") 823 MIO_GPIO_OUT(GPIO87_LCD_POWER, 0, "LCD Power")
867}; 824};
@@ -879,12 +836,16 @@ static void __init mioa701_machine_init(void)
879 set_pxa_fb_info(&mioa701_pxafb_info); 836 set_pxa_fb_info(&mioa701_pxafb_info);
880 pxa_set_mci_info(&mioa701_mci_info); 837 pxa_set_mci_info(&mioa701_mci_info);
881 pxa_set_keypad_info(&mioa701_keypad_info); 838 pxa_set_keypad_info(&mioa701_keypad_info);
839 wm97xx_bat_set_pdata(&mioa701_battery_data);
882 udc_init(); 840 udc_init();
883 pm_power_off = mioa701_poweroff; 841 pm_power_off = mioa701_poweroff;
884 arm_pm_restart = mioa701_restart; 842 arm_pm_restart = mioa701_restart;
885 platform_add_devices(devices, ARRAY_SIZE(devices)); 843 platform_add_devices(devices, ARRAY_SIZE(devices));
886 gsm_init(); 844 gsm_init();
887 mioa701_battery_init(); 845
846 pxa_set_i2c_info(&i2c_pdata);
847 pxa_set_camera_info(&mioa701_pxacamera_platform_data);
848 i2c_register_board_info(0, ARRAY_AND_SIZE(mioa701_i2c_devices));
888} 849}
889 850
890static void mioa701_machine_exit(void) 851static void mioa701_machine_exit(void)