r4187 - trunk/src/target/u-boot/patches

werner at sita.openmoko.org werner at sita.openmoko.org
Sun Mar 9 18:09:04 CET 2008


Author: werner
Date: 2008-03-09 18:09:00 +0100 (Sun, 09 Mar 2008)
New Revision: 4187

Added:
   trunk/src/target/u-boot/patches/dont-smoke.patch
Modified:
   trunk/src/target/u-boot/patches/series
Log:
This patch prevents us from drawing more than 100mA from USB, unless we're
sure we're allowed to. Thus, we don't make the upstream port produce smoke.

series: added dont-smoke.patch (for later merging into uboot-gta02.patch)

dont-smoke.patch:
- drivers/misc/pcf50633.c (pcf50633_read_charger_type, pcf50633_init): return 
  100 (mA) for USB, not 500
- drivers/misc/pcf50633.c (pcf50633_init): use pcf50633_usb_maxcurrent instead
  of open-coding current setting again
- drivers/misc/pcf50633.c (pcf50633_usb_maxcurrent): use symbolic names for
  current limits instead of numbers
- board/neo1973/gta02/pcf50633.c (pcf50633_initial_regs): set initial USB
  current to 100mA, not 500mA



Added: trunk/src/target/u-boot/patches/dont-smoke.patch
===================================================================
--- trunk/src/target/u-boot/patches/dont-smoke.patch	2008-03-09 15:41:05 UTC (rev 4186)
+++ trunk/src/target/u-boot/patches/dont-smoke.patch	2008-03-09 17:09:00 UTC (rev 4187)
@@ -0,0 +1,89 @@
+This patch prevents us from drawing more than 100mA from USB, unless we're
+sure we're allowed to. Thus, we don't make the upstream port produce smoke.
+
+Index: u-boot/board/neo1973/gta02/pcf50633.c
+===================================================================
+--- u-boot.orig/board/neo1973/gta02/pcf50633.c
++++ u-boot/board/neo1973/gta02/pcf50633.c
+@@ -107,7 +107,7 @@
+ 	[PCF50633_REG_MBCC4]	= 0xff, /* 255/255 == 1A adapter fast */
+ 	[PCF50633_REG_MBCC5]	= 0x7f,	/* 127/255 == 500mA usb fast */
+ 	[PCF50633_REG_MBCC6]	= 0x00, /* cutoff current 1/32 * Ichg */
+-	[PCF50633_REG_MBCC7]	= 0x01,	/* 1.6A max bat curr, USB 500mA */
++	[PCF50633_REG_MBCC7]	= 0x00,	/* 1.6A max bat curr, USB 100mA */
+ 	[PCF50633_REG_MBCC8]	= 0x00,
+ 
+ 	[PCF50633_REG_BBCCTL]	= 0x19,	/* 3V, 200uA, on */
+Index: u-boot/drivers/misc/pcf50633.c
+===================================================================
+--- u-boot.orig/drivers/misc/pcf50633.c
++++ u-boot/drivers/misc/pcf50633.c
+@@ -141,7 +141,7 @@
+ 
+ 	/* ok all we know is there is no resistor, it can be USB pwr or none */
+ 	if ((pcf50633_reg_read(PCF50633_REG_MBCS1) & 0x3) == 0x3)
+-		return 500; /* USB power then */
++		return 100; /* USB power then */
+ 
+ 	return 0; /* nope, no power, just battery */
+ }
+@@ -152,7 +152,8 @@
+ void pcf50633_init(void)
+ {
+ 	unsigned long flags;
+-	u_int8_t i, limit;
++	u_int8_t i;
++	int limit;
+ 
+ 	local_irq_save(flags);
+ 	for (i = 0; i < PCF50633_LAST_REG; i++) {
+@@ -163,23 +164,15 @@
+ 	local_irq_restore(flags);
+ 
+ 	printf("Power: ");
+-	switch (pcf50633_read_charger_type()) {
+-	case 0: /* no charger, battery only */
+-		printf("Battery\n");
+-		limit = PCF50633_MBCC7_USB_SUSPEND;
+-		break;
+-	case 500:
+-		printf("USB / 500mA\n");
+-		limit = PCF50633_MBCC7_USB_500mA;
+-		break;
+-	default:
+-		printf("1A\n");
+-		limit = PCF50633_MBCC7_USB_1000mA;
+-		break;
++	limit = pcf50633_read_charger_type();
++	/*
++	 * If we're on real USB, don't change the setting to avoid racing with
++	 * USB signaling.
++	 */
++	if (limit != 100) {
++		printf("%dmA\n", limit);
++		pcf50633_usb_maxcurrent(limit);
+ 	}
+-	pcf50633_reg_write(PCF50633_REG_MBCC7,
+-			   (pcf50633_reg_read(PCF50633_REG_MBCC7) &
+-			   (~PCF56033_MBCC7_USB_MASK)) | limit);
+ }
+ 
+ void pcf50633_usb_maxcurrent(unsigned int ma)
+@@ -187,13 +180,13 @@
+ 	u_int8_t val;
+ 
+ 	if (ma < 100)
+-		val = 0x03;
++		val = PCF50633_MBCC7_USB_SUSPEND;
+ 	else if (ma < 500)
+-		val = 0x00;
++		val = PCF50633_MBCC7_USB_100mA;
+ 	else if (ma < 1000)
+-		val = 0x01;
++		val = PCF50633_MBCC7_USB_500mA;
+ 	else
+-		val = 0x02;
++		val = PCF50633_MBCC7_USB_1000mA;
+ 
+ 	return pcf50633_reg_set_bit_mask(PCF50633_REG_MBCC7, 0x03, val);
+ }

Modified: trunk/src/target/u-boot/patches/series
===================================================================
--- trunk/src/target/u-boot/patches/series	2008-03-09 15:41:05 UTC (rev 4186)
+++ trunk/src/target/u-boot/patches/series	2008-03-09 17:09:00 UTC (rev 4187)
@@ -92,3 +92,7 @@
 
 # let's see what upstream thinks about this
 loadenv.patch
+
+# fix and improve power management
+dont-smoke.patch
+lie-low.patch





More information about the commitlog mailing list