Skip to contentSkip to conversation

LG Optimus Black (P970) codename sniper support series (and driver-model issue)

PATCH New Paul Kocialkowski 4 participants 49 messages Jul 20, 2015 – Aug 16, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover LG Optimus Black (P970) codename sniper support series (and driver-model issue)

This patch series adds support for the LG Optimus Black (P970) codename sniper, see the commit that introduces the board and config files for a short description of the device.

This should be applied on top of patches that I have submitted to the list but were not merged yet, especially:
* omap-common: Common boot code OMAP3 support and cleanup
* omap3: CONFIG_REVISION_TAG ifdef check for get_board_rev

At this point, support as submitted as this point is minimalistic. It is not ready for daily use, but introduces the basic elements that are needed to have a sane base upon which the rest of the device support will be introduced.

In particular, the device is currently headless, mainly because the display backlight is not enabled. Other important features such as the MUIC are not enabled, so USB will only work in U-Boot when the device boots with an USB cable already attached. In addition, the external MMC is not supported in U-Boot either, as it requires support for a separate PMIC.

A work in progress commit introduces support for (some of) those bits in a dirty and non-mergeable way is available at:
http://git.code.paulk.fr/gitweb/?p=u-boot.git;a=shortlog;h=refs/heads/sniper-next

Having those bits written correctly would require writing some drivers using the power framework. In the long run, those would have to use the driver model API, which would involve converting the I2C driver to DM as well. This is too much overhead for now, but it will be done eventually.

The main problem I see with doing that work now is that I2C DM seems to heavily rely on device-tree. Other parts of the OMAP platform support were converted to DM but use platform data defined in each board. That solution looks good to me, but doesn't work with I2C. Thus, we could either modify the I2C driver to cope with the lack of device-tree or make the use of device-tree a hard requirement for driver model, implying that each omap3 boards would have to provide a device-tree file as well.

Both solutions look good to me and I'll let experts decide what to do. Either way, I need to know what the right solution to this problem is to be able to move forward.

#1 lore raw

PATCH 1/12 power: twl4030: Power off support

This adds support for powering off (the omap3 SoC) from the twl4030. This is especially useful when the kernel does not actually power off the device using this method but reboots and leaves it up to the bootloader to actually turn the power off.

---
 drivers/power/twl4030.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/twl4030.h       | 32 +++++++++++++++++++-------
 2 files changed, 84 insertions(+), 8 deletions(-)
drivers/power/twl4030.c +60 -0
index 7f1fdd1..8866bf1 100644
@@ -46,6 +46,66 @@ void twl4030_power_reset_init(void)
 }
 
 /*
+ * Power off
+ */
+void twl4030_power_off(void)
+{
+	u8 data;
+
+	/* PM master unlock (CFG and TST keys) */
+
+	data = 0xCE;
+	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER,
+			     TWL4030_PM_MASTER_PROTECT_KEY, data);
+	data = 0xEC;
+	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER,
+			     TWL4030_PM_MASTER_PROTECT_KEY, data);
+
+	/* VBAT start disable */
+
+	twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER,
+			    TWL4030_PM_MASTER_CFG_P1_TRANSITION, &data);
+	data &= ~TWL4030_PM_MASTER_CFG_TRANSITION_STARTON_VBAT;
+	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER,
+			     TWL4030_PM_MASTER_CFG_P1_TRANSITION, data);
+
+	twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER,
+			    TWL4030_PM_MASTER_CFG_P2_TRANSITION, &data);
+	data &= ~TWL4030_PM_MASTER_CFG_TRANSITION_STARTON_VBAT;
+	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER,
+			     TWL4030_PM_MASTER_CFG_P2_TRANSITION, data);
+
+	twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER,
+			    TWL4030_PM_MASTER_CFG_P3_TRANSITION, &data);
+	data &= ~TWL4030_PM_MASTER_CFG_TRANSITION_STARTON_VBAT;
+	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER,
+			     TWL4030_PM_MASTER_CFG_P3_TRANSITION, data);
+
+	/* High jitter for PWRANA2 */
+
+	twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER,
+			    TWL4030_PM_MASTER_CFG_PWRANA2, &data);
+	data &= ~(TWL4030_PM_MASTER_CFG_PWRANA2_LOJIT0_LOWV |
+		  TWL4030_PM_MASTER_CFG_PWRANA2_LOJIT1_LOWV);
+	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER,
+			     TWL4030_PM_MASTER_CFG_PWRANA2, data);
+
+	/* PM master lock */
+
+	data = 0xFF;
+	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER,
+			     TWL4030_PM_MASTER_PROTECT_KEY, data);
+
+	/* Power off */
+
+	twl4030_i2c_read_u8(TWL4030_CHIP_PM_MASTER,
+			    TWL4030_PM_MASTER_P1_SW_EVENTS, &data);
+	data |= TWL4030_PM_MASTER_SW_EVENTS_DEVOFF;
+	twl4030_i2c_write_u8(TWL4030_CHIP_PM_MASTER,
+			     TWL4030_PM_MASTER_P1_SW_EVENTS, data);
+}
+
+/*
  * Set Device Group and Voltage
  */
 void twl4030_pmrecv_vsel_cfg(u8 vsel_reg, u8 vsel_val,
include/twl4030.h +24 -8
index 50f8da8..2d0ca18 100644
@@ -129,14 +129,6 @@
 #define TWL4030_PM_MASTER_BB_CFG			0x6D
 #define TWL4030_PM_MASTER_MISC_TST			0x6E
 #define TWL4030_PM_MASTER_TRIM1				0x6F
-/* P[1-3]_SW_EVENTS */
-#define TWL4030_PM_MASTER_SW_EVENTS_STOPON_PWRON	(1 << 6)
-#define TWL4030_PM_MASTER_SW_EVENTS_STOPON_SYSEN	(1 << 5)
-#define TWL4030_PM_MASTER_SW_EVENTS_ENABLE_WARMRESET	(1 << 4)
-#define TWL4030_PM_MASTER_SW_EVENTS_LVL_WAKEUP		(1 << 3)
-#define TWL4030_PM_MASTER_SW_EVENTS_DEVACT		(1 << 2)
-#define TWL4030_PM_MASTER_SW_EVENTS_DEVSLP		(1 << 1)
-#define TWL4030_PM_MASTER_SW_EVENTS_DEVOFF		(1 << 0)
 
 /* Power bus message definitions */
 
@@ -207,6 +199,28 @@
 /* Power Reference */
 #define RES_Main_Ref            28
 
+/* P[1-3]_SW_EVENTS */
+#define TWL4030_PM_MASTER_SW_EVENTS_STOPON_PWRON	(1 << 6)
+#define TWL4030_PM_MASTER_SW_EVENTS_STOPON_SYSEN	(1 << 5)
+#define TWL4030_PM_MASTER_SW_EVENTS_ENABLE_WARMRESET	(1 << 4)
+#define TWL4030_PM_MASTER_SW_EVENTS_LVL_WAKEUP		(1 << 3)
+#define TWL4030_PM_MASTER_SW_EVENTS_DEVACT		(1 << 2)
+#define TWL4030_PM_MASTER_SW_EVENTS_DEVSLP		(1 << 1)
+#define TWL4030_PM_MASTER_SW_EVENTS_DEVOFF		(1 << 0)
+
+/* Power transition */
+#define TWL4030_PM_MASTER_CFG_TRANSITION_STARTON_PWON	(1 << 0)
+#define TWL4030_PM_MASTER_CFG_TRANSITION_STARTON_CHG	(1 << 1)
+#define TWL4030_PM_MASTER_CFG_TRANSITION_STARTON_USB	(1 << 2)
+#define TWL4030_PM_MASTER_CFG_TRANSITION_STARTON_RTC	(1 << 3)
+#define TWL4030_PM_MASTER_CFG_TRANSITION_STARTON_VBAT	(1 << 4)
+#define TWL4030_PM_MASTER_CFG_TRANSITION_STARTON_VBUS	(1 << 5)
+#define TWL4030_PM_MASTER_CFG_TRANSITION_STARTON_SWBUG	(1 << 7)
+
+/* PWRANA2 */
+#define TWL4030_PM_MASTER_CFG_PWRANA2_LOJIT0_LOWV	(1 << 1)
+#define TWL4030_PM_MASTER_CFG_PWRANA2_LOJIT1_LOWV	(1 << 2)
+
 #define TOTAL_RESOURCES		28
 /*
  * Power Bus Message Format ... these can be sent individually by Linux,
@@ -645,6 +659,8 @@ static inline int twl4030_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
 
 /* For hardware resetting */
 void twl4030_power_reset_init(void);
+/* For power off */
+void twl4030_power_off(void);
 /* For setting device group and voltage */
 void twl4030_pmrecv_vsel_cfg(u8 vsel_reg, u8 vsel_val,
 			     u8 dev_grp, u8 dev_grp_sel);
Signature · 1 line
1.9.1
#2 lore raw

PATCH 1/12 power: twl4030: Power off support

Quoted 4 lines · Paul Kocialkowski

This adds support for powering off (the omap3 SoC) from the twl4030. This is especially useful when the kernel does not actually power off the device using this method but reboots and leaves it up to the bootloader to actually turn the power off.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150803/e7de4cf9/attachment.sig>
#3 lore raw

PATCH 1/12 power: twl4030: Power off support

Le lundi 03 ao?t 2015 ? 22:07 -0400, Tom Rini a ?crit :

Quoted 8 lines · Paul Kocialkowski
Quoted 5 lines

This adds support for powering off (the omap3 SoC) from the twl4030. This is especially useful when the kernel does not actually power off the device using this method but reboots and leaves it up to the bootloader to actually turn the power off.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150804/f6d9afd3/attachment.sig>

#4 lore raw

PATCH 1/12 power: twl4030: Power off support

In reply to Paul Kocialkowski
Quoted 5 lines · Paul Kocialkowski

This adds support for powering off (the omap3 SoC) from the twl4030. This is especially useful when the kernel does not actually power off the device using this method but reboots and leaves it up to the bootloader to actually turn the power off.
---

Signed-off-by tag is missing.

#5 lore raw

PATCH 1/12 power: twl4030: Power off support

In reply to Paul Kocialkowski

Hello Paul,

Quoted 9 lines · Paul Kocialkowski

This adds support for powering off (the omap3 SoC) from the twl4030. This is especially useful when the kernel does not actually power off the device using this method but reboots and leaves it up to the bootloader to actually turn the power off.

---
  drivers/power/twl4030.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++
  include/twl4030.h       | 32 +++++++++++++++++++-------
  2 files changed, 84 insertions(+), 8 deletions(-)

Best regards,

Signature · 4 lines
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
#6 lore raw

PATCH 1/12 power: twl4030: Power off support

In reply to Paul Kocialkowski
Quoted 7 lines · Paul Kocialkowski

This adds support for powering off (the omap3 SoC) from the twl4030. This is especially useful when the kernel does not actually power off the device using this method but reboots and leaves it up to the bootloader to actually turn the power off.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150813/c162fecd/attachment.sig>
#7 lore raw

PATCH 2/12 input: TWL4030 input support for power button, USB and charger

In reply to Paul Kocialkowski

This adds support for detecting a few inputs exported by the TWL4030. Currently-supported inputs are the power button, USB and charger presence.

---
 drivers/input/Makefile  |  1 +
 drivers/input/twl4030.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/twl4030.h       | 14 ++++++++++++++
 3 files changed, 64 insertions(+)
 create mode 100644 drivers/input/twl4030.c
drivers/input/Makefile +1 -0
index a8e9be2..24fec9b 100644
@@ -7,6 +7,7 @@
 
 obj-$(CONFIG_I8042_KBD) += i8042.o
 obj-$(CONFIG_TEGRA_KEYBOARD) += tegra-kbc.o
+obj-$(CONFIG_TWL4030_INPUT) += twl4030.o
 obj-$(CONFIG_CROS_EC_KEYB) += cros_ec_keyb.o
 ifdef CONFIG_PS2KBD
 obj-y += keyboard.o pc_keyb.o
drivers/input/twl4030.c new file +49 -0

49 lines not on this page · raw message

include/twl4030.h +14 -0
index 2d0ca18..a4d5fbd 100644
@@ -208,6 +208,12 @@
 #define TWL4030_PM_MASTER_SW_EVENTS_DEVSLP		(1 << 1)
 #define TWL4030_PM_MASTER_SW_EVENTS_DEVOFF		(1 << 0)
 
+/* HW conditions */
+#define TWL4030_PM_MASTER_STS_HW_CONDITIONS_PWON	(1 << 0)
+#define TWL4030_PM_MASTER_STS_HW_CONDITIONS_CHG		(1 << 1)
+#define TWL4030_PM_MASTER_STS_HW_CONDITIONS_USB		(1 << 2)
+#define TWL4030_PM_MASTER_STS_HW_CONDITIONS_VBUS	(1 << 7)
+
 /* Power transition */
 #define TWL4030_PM_MASTER_CFG_TRANSITION_STARTON_PWON	(1 << 0)
 #define TWL4030_PM_MASTER_CFG_TRANSITION_STARTON_CHG	(1 << 1)
@@ -670,6 +676,14 @@ void twl4030_power_init(void);
 void twl4030_power_mmc_init(int dev_index);
 
 /*
+ * Input
+ */
+
+int twl4030_input_power_button(void);
+int twl4030_input_charger(void);
+int twl4030_input_usb(void);
+
+/*
  * LED
  */
 void twl4030_led_init(unsigned char ledon_mask);
Signature · 1 line
1.9.1
#8 lore raw

PATCH 2/12 input: TWL4030 input support for power button, USB and charger

Quoted 2 lines · Paul Kocialkowski

This adds support for detecting a few inputs exported by the TWL4030. Currently-supported inputs are the power button, USB and charger presence.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150803/4ba347a3/attachment.sig>
#9 lore raw

PATCH 2/12 input: TWL4030 input support for power button, USB and charger

Le lundi 03 ao?t 2015 ? 22:07 -0400, Tom Rini a ?crit :

Quoted 6 lines · Paul Kocialkowski
Quoted 3 lines

This adds support for detecting a few inputs exported by the TWL4030. Currently-supported inputs are the power button, USB and charger presence.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150804/59f1629a/attachment.sig>

#10 lore raw

PATCH 2/12 input: TWL4030 input support for power button, USB and charger

In reply to Paul Kocialkowski
Quoted 4 lines · Paul Kocialkowski

This adds support for detecting a few inputs exported by the TWL4030. Currently-supported inputs are the power button, USB and charger presence.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150813/9916c901/attachment.sig>
#11 lore raw

PATCH 3/12 input: twl4030: Keypad scan and input

In reply to Paul Kocialkowski

This allows scanning the twl4030 keypad, storing the result in a 64-byte long matrix with the twl4030_keypad_scan function.

Detecting a key at a given column and row is made easier with the twl4030_keypad_key function.

---
 drivers/input/twl4030.c | 39 +++++++++++++++++++++++++++++++++++++++
 include/twl4030.h       |  3 +++
 2 files changed, 42 insertions(+)
drivers/input/twl4030.c +39 -0
index a5ded35..dc5868c 100644
@@ -47,3 +47,42 @@ int twl4030_input_usb(void)
 
 	return 0;
 }
+
+int twl4030_keypad_scan(unsigned char *matrix)
+{
+	u8 data;
+	u8 c, r;
+
+	twl4030_i2c_read_u8(TWL4030_CHIP_KEYPAD,
+			    TWL4030_KEYPAD_KEYP_CTRL_REG, &data);
+
+	data |= TWL4030_KEYPAD_CTRL_SOFT_NRST | TWL4030_KEYPAD_CTRL_KBD_ON;
+	data &= ~TWL4030_KEYPAD_CTRL_SOFTMODEN;
+
+	twl4030_i2c_write_u8(TWL4030_CHIP_KEYPAD,
+			     TWL4030_KEYPAD_KEYP_CTRL_REG, data);
+
+	for (c = 0; c < 8; c++) {
+		data = 0xff & ~(1 << c);
+		twl4030_i2c_write_u8(TWL4030_CHIP_KEYPAD,
+				     TWL4030_KEYPAD_KBC_REG, data);
+
+		data = 0xff;
+		twl4030_i2c_read_u8(TWL4030_CHIP_KEYPAD,
+				    TWL4030_KEYPAD_KBR_REG, &data);
+
+		for (r = 0; r < 8; r++)
+			matrix[c * 8 + r] = !(data & (1 << r));
+	}
+
+	data = 0xff & ~(TWL4030_KEYPAD_CTRL_SOFT_NRST);
+	twl4030_i2c_write_u8(TWL4030_CHIP_KEYPAD,
+			     TWL4030_KEYPAD_KEYP_CTRL_REG, data);
+
+	return 0;
+}
+
+int twl4030_keypad_key(unsigned char *matrix, u8 c, u8 r)
+{
+	return matrix[c * 8 + r];
+}
include/twl4030.h +3 -0
index a4d5fbd..1031373 100644
@@ -683,6 +683,9 @@ int twl4030_input_power_button(void);
 int twl4030_input_charger(void);
 int twl4030_input_usb(void);
 
+int twl4030_keypad_scan(unsigned char *matrix);
+int twl4030_keypad_key(unsigned char *matrix, u8 c, u8 r);
+
 /*
  * LED
  */
Signature · 1 line
1.9.1
#12 lore raw

PATCH 3/12 input: twl4030: Keypad scan and input

Quoted 7 lines · Paul Kocialkowski

This allows scanning the twl4030 keypad, storing the result in a 64-byte long matrix with the twl4030_keypad_scan function.

Detecting a key at a given column and row is made easier with the twl4030_keypad_key function.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150803/035f351a/attachment.sig>
#13 lore raw

PATCH 3/12 input: twl4030: Keypad scan and input

In reply to Paul Kocialkowski
Quoted 8 lines · Paul Kocialkowski

This allows scanning the twl4030 keypad, storing the result in a 64-byte long matrix with the twl4030_keypad_scan function.

Detecting a key at a given column and row is made easier with the twl4030_keypad_key function.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150813/ea87cf8b/attachment.sig>
#14 lore raw

PATCH 4/12 omap3: Reboot mode support

In reply to Paul Kocialkowski

Reboot mode is written in scratchpad memory before reboot in the form of a single char, that is the first letter of the reboot mode string as passed to the reboot function.

This mechanism is supported on OMAP3 both my the upstream kernel and by various TI kernels.

It is up to each board to make use of this mechanism or not.

---
 arch/arm/cpu/armv7/omap3/boot.c        | 38 ++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-omap3/omap.h |  7 +++++++
 2 files changed, 45 insertions(+)
arch/arm/cpu/armv7/omap3/boot.c +38 -0
index 66576b2..44d7c30 100644
@@ -56,3 +56,41 @@ u32 omap_sys_boot_device(void)
 
 	return boot_devices[sys_boot];
 }
+
+char omap_reboot_mode(void)
+{
+	u32 reboot_mode;
+	char c;
+
+	reboot_mode = readl((u32 *)(OMAP34XX_SCRATCHPAD + 4));
+
+	c = (reboot_mode >> 24) & 0xff;
+	if (c != 'B')
+		return -1;
+
+	c = (reboot_mode >> 16) & 0xff;
+	if (c != 'M')
+		return -1;
+
+	c = reboot_mode & 0xff;
+
+	return c;
+}
+
+int omap_reboot_mode_clear(void)
+{
+	writel(0, (u32 *)(OMAP34XX_SCRATCHPAD + 4));
+
+	return 0;
+}
+
+int omap_reboot_mode_store(char c)
+{
+	u32 reboot_mode;
+
+	reboot_mode = 'B' << 24 | 'M' << 16 | c;
+
+	writel(reboot_mode, (u32 *)(OMAP34XX_SCRATCHPAD + 4));
+
+	return 0;
+}
arch/arm/include/asm/arch-omap3/omap.h +7 -0
index 537d13b..2c94a81 100644
@@ -51,6 +51,9 @@ struct control_prog_io {
 /* Bit definition for CONTROL_PROG_IO1 */
 #define PRG_I2C2_PULLUPRESX		0x00000001
 
+/* Scratchpad memory */
+#define OMAP34XX_SCRATCHPAD		(OMAP34XX_CTRL_BASE + 0x910)
+
 /* UART */
 #define OMAP34XX_UART1			(OMAP34XX_L4_IO_BASE + 0x6a000)
 #define OMAP34XX_UART2			(OMAP34XX_L4_IO_BASE + 0x6c000)
@@ -256,6 +259,10 @@ struct omap_boot_parameters {
 	unsigned char ch_flags;
 	unsigned int boot_device_descriptor;
 };
+
+char omap_reboot_mode(void);
+int omap_reboot_mode_clear(void);
+int omap_reboot_mode_store(char c);
 #endif
 
 #endif
Signature · 1 line
1.9.1
#15 lore raw

PATCH 4/12 omap3: Reboot mode support

Quoted 10 lines · Paul Kocialkowski

Reboot mode is written in scratchpad memory before reboot in the form of a single char, that is the first letter of the reboot mode string as passed to the reboot function.

This mechanism is supported on OMAP3 both my the upstream kernel and by various TI kernels.

It is up to each board to make use of this mechanism or not.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150803/f156579a/attachment.sig>
#16 lore raw

PATCH 4/12 omap3: Reboot mode support

In reply to Paul Kocialkowski
Quoted 11 lines · Paul Kocialkowski

Reboot mode is written in scratchpad memory before reboot in the form of a single char, that is the first letter of the reboot mode string as passed to the reboot function.

This mechanism is supported on OMAP3 both my the upstream kernel and by various TI kernels.

It is up to each board to make use of this mechanism or not.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150813/c5685a6b/attachment.sig>
#17 lore raw

PATCH 5/12 LG Optimus Black (P970) codename sniper support

In reply to Paul Kocialkowski

The LG Optimus Black (P970) codename sniper is a smartphone that was designed and manufactured by LG Electronics (LGE) and released back in 2011.

It is using an OMAP3630 SoC GP version, which allows running U-Boot and the U-Boot SPL from the ground up. This port is aimed at running an Android version such as Replicant, the fully free Android distribution. However, support for upstream Linux with device-tree and common GNU/Linux distros boot commands could be added in the future.

For more information about the journey to freeing this device, please read the series of blog posts at:
http://code.paulk.fr/article20/a-hacker-s-journey-freeing-a-phone-from-the-ground-up-first-part

---
 arch/arm/cpu/armv7/omap3/Kconfig |   8 +
 board/lge/sniper/Kconfig         |  12 ++
 board/lge/sniper/MAINTAINERS     |   6 +
 board/lge/sniper/Makefile        |   9 +
 board/lge/sniper/sniper.c        |  85 +++++++++
 board/lge/sniper/sniper.h        | 365 +++++++++++++++++++++++++++++++++++++++
 configs/sniper_defconfig         |   7 +
 include/configs/sniper.h         | 265 ++++++++++++++++++++++++++++
 8 files changed, 757 insertions(+)
 create mode 100644 board/lge/sniper/Kconfig
 create mode 100644 board/lge/sniper/MAINTAINERS
 create mode 100644 board/lge/sniper/Makefile
 create mode 100644 board/lge/sniper/sniper.c
 create mode 100644 board/lge/sniper/sniper.h
 create mode 100644 configs/sniper_defconfig
 create mode 100644 include/configs/sniper.h
arch/arm/cpu/armv7/omap3/Kconfig +8 -0
index b32a6b0..f4fb6cb 100644
@@ -114,6 +114,13 @@ config TARGET_OMAP3_CAIRO
 	select DM_SERIAL
 	select DM_GPIO
 
+config TARGET_SNIPER
+	bool "Sniper"
+	select SUPPORT_SPL
+	select DM
+	select DM_SERIAL
+	select DM_GPIO
+
 endchoice
 
 config SYS_SOC
@@ -142,5 +149,6 @@ source "board/nokia/rx51/Kconfig"
 source "board/technexion/tao3530/Kconfig"
 source "board/technexion/twister/Kconfig"
 source "board/quipos/cairo/Kconfig"
+source "board/lge/sniper/Kconfig"
 
 endif
board/lge/sniper/Kconfig new file +12 -0
new file mode 100644
index 0000000..f7a682e
@@ -0,0 +1,12 @@
+if TARGET_SNIPER
+
+config SYS_BOARD
+	default "sniper"
+
+config SYS_VENDOR
+	default "lge"
+
+config SYS_CONFIG_NAME
+	default "sniper"
+
+endif
board/lge/sniper/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000..0e7baa5
@@ -0,0 +1,6 @@
+SNIPER BOARD
+M:	Paul Kocialkowski <[email protected]>
+S:	Maintained
+F:	board/lge/sniper/
+F:	include/configs/sniper.h
+F:	configs/sniper_defconfig
board/lge/sniper/Makefile new file +9 -0
new file mode 100644
index 0000000..2d216fc
@@ -0,0 +1,9 @@
+#
+# LG Optimus Black (P970) codename sniper board
+#
+# Copyright (C) 2015 Paul Kocialkowski <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y := sniper.o
board/lge/sniper/sniper.c new file +85 -0

85 lines not on this page · raw message

board/lge/sniper/sniper.h new file +365 -0

365 lines not on this page · raw message

configs/sniper_defconfig new file +7 -0
new file mode 100644
index 0000000..d2e10a9
@@ -0,0 +1,7 @@
+CONFIG_ARM=y
+CONFIG_OMAP34XX=y
+CONFIG_TARGET_SNIPER=y
+CONFIG_SPL=y
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_FPGA is not set
include/configs/sniper.h new file +265 -0

265 lines not on this page · raw message

Signature · 1 line
1.9.1
#18 lore raw

PATCH 5/12 LG Optimus Black (P970) codename sniper support

Quoted 9 lines · Paul Kocialkowski

The LG Optimus Black (P970) codename sniper is a smartphone that was designed and manufactured by LG Electronics (LGE) and released back in 2011.

It is using an OMAP3630 SoC GP version, which allows running U-Boot and the U-Boot SPL from the ground up. This port is aimed at running an Android version such as Replicant, the fully free Android distribution. However, support for upstream Linux with device-tree and common GNU/Linux distros boot commands could be added in the future.

Quoted 5 lines

For more information about the journey to freeing this device, please read the series of blog posts at:
http://code.paulk.fr/article20/a-hacker-s-journey-freeing-a-phone-from-the-ground-up-first-part

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150803/f4276b0d/attachment.sig>
#19 lore raw

PATCH 5/12 LG Optimus Black (P970) codename sniper support

In reply to Paul Kocialkowski
Quoted 9 lines · Paul Kocialkowski

The LG Optimus Black (P970) codename sniper is a smartphone that was designed and manufactured by LG Electronics (LGE) and released back in 2011.

It is using an OMAP3630 SoC GP version, which allows running U-Boot and the U-Boot SPL from the ground up. This port is aimed at running an Android version such as Replicant, the fully free Android distribution. However, support for upstream Linux with device-tree and common GNU/Linux distros boot commands could be added in the future.

Quoted 6 lines

For more information about the journey to freeing this device, please read the series of blog posts at:
http://code.paulk.fr/article20/a-hacker-s-journey-freeing-a-phone-from-the-ground-up-first-part

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150813/97683518/attachment.sig>
#20 lore raw

PATCH 6/12 sniper: OMAP3 reboot mode support

In reply to Paul Kocialkowski

This adds support for the omap3 reboot mode mechanism and exports the reboot mode via an environment variable, that is used in the boot command to make it possible to boot from the recovery partition.

---
 board/lge/sniper/sniper.c | 18 ++++++++++++++++++
 include/configs/sniper.h  |  3 +++
 2 files changed, 21 insertions(+)
board/lge/sniper/sniper.c +18 -0
index d5318c4..44d422d 100644
@@ -9,6 +9,7 @@
 #include <config.h>
 #include <common.h>
 #include <dm.h>
+#include <linux/ctype.h>
 #include <asm/arch/mmc_host_def.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mem.h>
@@ -67,6 +68,23 @@ int board_init(void)
 	return 0;
 }
 
+int misc_init_r(void)
+{
+	char reboot_mode[2] = { 0 };
+
+	/* Reboot mode */
+
+	reboot_mode[0] = omap_reboot_mode();
+	if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
+		if (!getenv("reboot-mode"))
+			setenv("reboot-mode", (char *)reboot_mode);
+
+		omap_reboot_mode_clear();
+	}
+
+	return 0;
+}
+
 void set_muxconf_regs(void)
 {
 	MUX_SNIPER();
include/configs/sniper.h +3 -0
index ef7a2bf..eb1252d 100644
@@ -35,6 +35,7 @@
  */
 
 #define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_MISC_INIT_R
 
 /*
  * Clocks
@@ -250,6 +251,8 @@
 
 #define CONFIG_BOOTCOMMAND \
 	"setenv boot_mmc_part ${kernel_mmc_part}; " \
+	"if test reboot-${reboot-mode} = reboot-r; then " \
+	"echo recovery; setenv boot_mmc_part ${recovery_mmc_part}; fi; " \
 	"part start mmc ${boot_mmc_dev} ${boot_mmc_part} boot_mmc_start; " \
 	"part size mmc ${boot_mmc_dev} ${boot_mmc_part} boot_mmc_size; " \
 	"mmc dev ${boot_mmc_dev}; " \
Signature · 1 line
1.9.1
#21 lore raw

PATCH 6/12 sniper: OMAP3 reboot mode support

Quoted 5 lines · Paul Kocialkowski

This adds support for the omap3 reboot mode mechanism and exports the reboot mode via an environment variable, that is used in the boot command to make it possible to boot from the recovery partition.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150803/8ed66a7a/attachment.sig>
#22 lore raw

PATCH 6/12 sniper: OMAP3 reboot mode support

In reply to Paul Kocialkowski
Quoted 6 lines · Paul Kocialkowski

This adds support for the omap3 reboot mode mechanism and exports the reboot mode via an environment variable, that is used in the boot command to make it possible to boot from the recovery partition.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150813/3f0560c7/attachment.sig>
#23 lore raw

PATCH 7/12 sniper: Serial number support, obtained from die ID

In reply to Paul Kocialkowski

The OMAP3 has some die-specific ID bits that we can use to give the device a (more or less) unique serial number. This is particularly useful for e.g. USB.

---
 board/lge/sniper/sniper.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
board/lge/sniper/sniper.c +13 -0
index 44d422d..f26855d 100644
@@ -70,7 +70,9 @@ int board_init(void)
 
 int misc_init_r(void)
 {
+	char serial_string[17] = { 0 };
 	char reboot_mode[2] = { 0 };
+	u32 dieid[4] = { 0 };
 
 	/* Reboot mode */
 
@@ -82,6 +84,17 @@ int misc_init_r(void)
 		omap_reboot_mode_clear();
 	}
 
+	/* Serial number */
+
+	get_dieid((u32 *)&dieid);
+
+	if (!getenv("serial#")) {
+		snprintf(serial_string, sizeof(serial_string),
+			"%08x%08x", dieid[0], dieid[3]);
+
+		setenv("serial#", serial_string);
+	}
+
 	return 0;
 }
 
Signature · 1 line
1.9.1
#24 lore raw

PATCH 7/12 sniper: Serial number support, obtained from die ID

Quoted 29 lines · Paul Kocialkowski

The OMAP3 has some die-specific ID bits that we can use to give the device a (more or less) unique serial number. This is particularly useful for e.g. USB.

---
 board/lge/sniper/sniper.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
board/lge/sniper/sniper.c +5 -0
index 44d422d..f26855d 100644
@@ -70,7 +70,9 @@ int board_init(void)
 
 int misc_init_r(void)
 {
+	char serial_string[17] = { 0 };
 	char reboot_mode[2] = { 0 };
+	u32 dieid[4] = { 0 };
 
 	/* Reboot mode */
 
@@ -82,6 +84,17 @@ int misc_init_r(void)
 		omap_reboot_mode_clear();
 	}
 
+	/* Serial number */
+
+	get_dieid((u32 *)&dieid);

board/lge/sniper/sniper.c int misc_init_r(void) · line 99

Quoted 10 lines
board/lge/sniper/sniper.c +8 -0
+
+	if (!getenv("serial#")) {
+		snprintf(serial_string, sizeof(serial_string),
+			"%08x%08x", dieid[0], dieid[3]);
+
+		setenv("serial#", serial_string);
+	}
+
 	return 0;
 }

Shouldn't this be in more generic code so everyone gets this set now? Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150803/975b70c6/attachment.sig>
#25 lore raw

PATCH 7/12 sniper: Serial number support, obtained from die ID

Le lundi 03 ao?t 2015 ? 22:08 -0400, Tom Rini a ?crit :

Quoted 28 lines · Paul Kocialkowski
Quoted 27 lines

The OMAP3 has some die-specific ID bits that we can use to give the device a (more or less) unique serial number. This is particularly useful for e.g. USB.

---
 board/lge/sniper/sniper.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
board/lge/sniper/sniper.c +2 -0
index 44d422d..f26855d 100644
@@ -70,7 +70,9 @@ int board_init(void)
 
 int misc_init_r(void)
 {
+	char serial_string[17] = { 0 };
 	char reboot_mode[2] = { 0 };
+	u32 dieid[4] = { 0 };
 
 	/* Reboot mode */
 
@@ -82,6 +84,17 @@ int misc_init_r(void)
 		omap_reboot_mode_clear();
 	}
 
Quoted 16 lines

board/lge/sniper/sniper.c int misc_init_r(void) · line 99

Quoted 13 lines
board/lge/sniper/sniper.c +11 -0
+	/* Serial number */
+
+	get_dieid((u32 *)&dieid);
+
+	if (!getenv("serial#")) {
+		snprintf(serial_string, sizeof(serial_string),
+			"%08x%08x", dieid[0], dieid[3]);
+
+		setenv("serial#", serial_string);
+	}
+
 	return 0;
 }

Shouldn't this be in more generic code so everyone gets this set now? Thanks!

Well, we had a similar discussion for sunxi, and the outcome was that serial number could be obtained from other places on other devices (e.g. EEPROM) or be calculated from the dieid bits in a different way, so I prefer to keep this board-specific instead of omap3-generic for now.

This merely matches what is done on Android OMAP devices, but one could do it another way, too.

What do you think?

Signature · 16 lines
Paul Kocialkowski, Replicant developer

Replicant is a fully free Android distribution running on several
devices, a free software mobile operating system putting the emphasis on
freedom and privacy/security.

Website: http://www.replicant.us/
Blog: http://blog.replicant.us/
Wiki/tracker/forums: http://redmine.replicant.us/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150804/dcbfc15c/attachment.sig>
#26 lore raw

PATCH 7/12 sniper: Serial number support, obtained from die ID

Quoted 51 lines · Paul Kocialkowski

Le lundi 03 ao?t 2015 ? 22:08 -0400, Tom Rini a ?crit :

Quoted 28 lines · Paul Kocialkowski
Quoted 27 lines

The OMAP3 has some die-specific ID bits that we can use to give the device a (more or less) unique serial number. This is particularly useful for e.g. USB.

---
 board/lge/sniper/sniper.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
board/lge/sniper/sniper.c +2 -0
index 44d422d..f26855d 100644
@@ -70,7 +70,9 @@ int board_init(void)
 
 int misc_init_r(void)
 {
+	char serial_string[17] = { 0 };
 	char reboot_mode[2] = { 0 };
+	u32 dieid[4] = { 0 };
 
 	/* Reboot mode */
 
@@ -82,6 +84,17 @@ int misc_init_r(void)
 		omap_reboot_mode_clear();
 	}
 
Quoted 16 lines

board/lge/sniper/sniper.c int misc_init_r(void) · line 99

Quoted 13 lines
board/lge/sniper/sniper.c +11 -0
+	/* Serial number */
+
+	get_dieid((u32 *)&dieid);
+
+	if (!getenv("serial#")) {
+		snprintf(serial_string, sizeof(serial_string),
+			"%08x%08x", dieid[0], dieid[3]);
+
+		setenv("serial#", serial_string);
+	}
+
 	return 0;
 }

Shouldn't this be in more generic code so everyone gets this set now? Thanks!

Well, we had a similar discussion for sunxi, and the outcome was that serial number could be obtained from other places on other devices (e.g. EEPROM) or be calculated from the dieid bits in a different way, so I prefer to keep this board-specific instead of omap3-generic for now.

Quoted 4 lines

This merely matches what is done on Android OMAP devices, but one could do it another way, too.

What do you think?

I think, ug, arch/arm/cpu/armv7/omap-common/utils.c::usb_set_serial_num_from_die_id() should be called set_serial_num_from_die_id() and we can use that for this board too even if it's not ideal.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150804/d83017e7/attachment.sig>
#27 lore raw

PATCH 7/12 sniper: Serial number support, obtained from die ID

Le mardi 04 ao?t 2015 ? 14:16 -0400, Tom Rini a ?crit :

Quoted 55 lines · Paul Kocialkowski
Quoted 54 lines

Le lundi 03 ao?t 2015 ? 22:08 -0400, Tom Rini a ?crit :

Quoted 28 lines · Paul Kocialkowski
Quoted 27 lines

The OMAP3 has some die-specific ID bits that we can use to give the device a (more or less) unique serial number. This is particularly useful for e.g. USB.

---
 board/lge/sniper/sniper.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
board/lge/sniper/sniper.c +2 -0
index 44d422d..f26855d 100644
@@ -70,7 +70,9 @@ int board_init(void)
 
 int misc_init_r(void)
 {
+	char serial_string[17] = { 0 };
 	char reboot_mode[2] = { 0 };
+	u32 dieid[4] = { 0 };
 
 	/* Reboot mode */
 
@@ -82,6 +84,17 @@ int misc_init_r(void)
 		omap_reboot_mode_clear();
 	}
 
Quoted 16 lines

board/lge/sniper/sniper.c int misc_init_r(void) · line 99

Quoted 13 lines
board/lge/sniper/sniper.c +11 -0
+	/* Serial number */
+
+	get_dieid((u32 *)&dieid);
+
+	if (!getenv("serial#")) {
+		snprintf(serial_string, sizeof(serial_string),
+			"%08x%08x", dieid[0], dieid[3]);
+
+		setenv("serial#", serial_string);
+	}
+
 	return 0;
 }

Shouldn't this be in more generic code so everyone gets this set now? Thanks!

Well, we had a similar discussion for sunxi, and the outcome was that serial number could be obtained from other places on other devices (e.g. EEPROM) or be calculated from the dieid bits in a different way, so I prefer to keep this board-specific instead of omap3-generic for now.

This merely matches what is done on Android OMAP devices, but one could do it another way, too.

Quoted 6 lines
Quoted 1 line

What do you think?

I think, ug, arch/arm/cpu/armv7/omap-common/utils.c::usb_set_serial_num_from_die_id() should be called set_serial_num_from_die_id() and we can use that for this board too even if it's not ideal.

Oh okay then, I don't have any problem with making this code common, especially if it's not called by every omap3 board then.

I agree with your proposal. Should I submit a v2 with a patch in that direction?

Signature · 16 lines
Paul Kocialkowski, Replicant developer

Replicant is a fully free Android distribution running on several
devices, a free software mobile operating system putting the emphasis on
freedom and privacy/security.

Website: http://www.replicant.us/
Blog: http://blog.replicant.us/
Wiki/tracker/forums: http://redmine.replicant.us/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150804/09e52cde/attachment.sig>
#28 lore raw

PATCH 7/12 sniper: Serial number support, obtained from die ID

Quoted 63 lines · Paul Kocialkowski

Le mardi 04 ao?t 2015 ? 14:16 -0400, Tom Rini a ?crit :

Quoted 55 lines · Paul Kocialkowski
Quoted 54 lines

Le lundi 03 ao?t 2015 ? 22:08 -0400, Tom Rini a ?crit :

Quoted 28 lines · Paul Kocialkowski
Quoted 27 lines

The OMAP3 has some die-specific ID bits that we can use to give the device a (more or less) unique serial number. This is particularly useful for e.g. USB.

---
 board/lge/sniper/sniper.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
board/lge/sniper/sniper.c +2 -0
index 44d422d..f26855d 100644
@@ -70,7 +70,9 @@ int board_init(void)
 
 int misc_init_r(void)
 {
+	char serial_string[17] = { 0 };
 	char reboot_mode[2] = { 0 };
+	u32 dieid[4] = { 0 };
 
 	/* Reboot mode */
 
@@ -82,6 +84,17 @@ int misc_init_r(void)
 		omap_reboot_mode_clear();
 	}
 
Quoted 16 lines

board/lge/sniper/sniper.c int misc_init_r(void) · line 99

Quoted 13 lines
board/lge/sniper/sniper.c +11 -0
+	/* Serial number */
+
+	get_dieid((u32 *)&dieid);
+
+	if (!getenv("serial#")) {
+		snprintf(serial_string, sizeof(serial_string),
+			"%08x%08x", dieid[0], dieid[3]);
+
+		setenv("serial#", serial_string);
+	}
+
 	return 0;
 }

Shouldn't this be in more generic code so everyone gets this set now? Thanks!

Well, we had a similar discussion for sunxi, and the outcome was that serial number could be obtained from other places on other devices (e.g. EEPROM) or be calculated from the dieid bits in a different way, so I prefer to keep this board-specific instead of omap3-generic for now.

This merely matches what is done on Android OMAP devices, but one could do it another way, too.

Quoted 6 lines
Quoted 1 line

What do you think?

I think, ug, arch/arm/cpu/armv7/omap-common/utils.c::usb_set_serial_num_from_die_id() should be called set_serial_num_from_die_id() and we can use that for this board too even if it's not ideal.

Quoted 5 lines

Oh okay then, I don't have any problem with making this code common, especially if it's not called by every omap3 board then.

I agree with your proposal. Should I submit a v2 with a patch in that direction?

Sounds good, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150804/a2bf6743/attachment.sig>
#29 lore raw

PATCH 7/12 sniper: Serial number support, obtained from die ID

Le mardi 04 ao?t 2015 ? 14:27 -0400, Tom Rini a ?crit :

Quoted 64 lines · Paul Kocialkowski
Quoted 63 lines

Le mardi 04 ao?t 2015 ? 14:16 -0400, Tom Rini a ?crit :

Quoted 61 lines · Paul Kocialkowski
Quoted 51 lines

Le lundi 03 ao?t 2015 ? 22:08 -0400, Tom Rini a ?crit :

Quoted 28 lines · Paul Kocialkowski
Quoted 27 lines

The OMAP3 has some die-specific ID bits that we can use to give the device a (more or less) unique serial number. This is particularly useful for e.g. USB.

---
 board/lge/sniper/sniper.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
board/lge/sniper/sniper.c +2 -0
index 44d422d..f26855d 100644
@@ -70,7 +70,9 @@ int board_init(void)
 
 int misc_init_r(void)
 {
+	char serial_string[17] = { 0 };
 	char reboot_mode[2] = { 0 };
+	u32 dieid[4] = { 0 };
 
 	/* Reboot mode */
 
@@ -82,6 +84,17 @@ int misc_init_r(void)
 		omap_reboot_mode_clear();
 	}
 
Quoted 16 lines

board/lge/sniper/sniper.c int misc_init_r(void) · line 99

Quoted 13 lines
board/lge/sniper/sniper.c +11 -0
+	/* Serial number */
+
+	get_dieid((u32 *)&dieid);
+
+	if (!getenv("serial#")) {
+		snprintf(serial_string, sizeof(serial_string),
+			"%08x%08x", dieid[0], dieid[3]);
+
+		setenv("serial#", serial_string);
+	}
+
 	return 0;
 }

Shouldn't this be in more generic code so everyone gets this set now? Thanks!

Well, we had a similar discussion for sunxi, and the outcome was that serial number could be obtained from other places on other devices (e.g. EEPROM) or be calculated from the dieid bits in a different way, so I prefer to keep this board-specific instead of omap3-generic for now.

Quoted 4 lines

This merely matches what is done on Android OMAP devices, but one could do it another way, too.

What do you think?

I think, ug, arch/arm/cpu/armv7/omap-common/utils.c::usb_set_serial_num_from_die_id() should be called set_serial_num_from_die_id() and we can use that for this board too even if it's not ideal.

Quoted 7 lines
Quoted 5 lines

Oh okay then, I don't have any problem with making this code common, especially if it's not called by every omap3 board then.

I agree with your proposal. Should I submit a v2 with a patch in that direction?

Sounds good, thanks!

Taking a closer look at things, it appears that various (non-omap3) boards are grabbing the Die ID bits on their own and then calling those functions (usb_fake_mac_from_die_id, usb_set_serial_num_from_die_id).

IMHO, we should have a common naming scheme for the function to get the dieid (omap_dieid), define that for each omap platform and have it called in omap-common code (with one function for the serial number and one for the fake mac), just like what I did with omap_sys_boot_device.

Then, each board would simply call those functions directly, without having to care about how to obtain the die id bits.

This seems like a series that would deserve to live on its own, so I suggest that you merge Optimus Black support as-is for now and I'll submit another series to implement that behaviour on top.

What do you think?

Signature · 16 lines
Paul Kocialkowski, Replicant developer

Replicant is a fully free Android distribution running on several
devices, a free software mobile operating system putting the emphasis on
freedom and privacy/security.

Website: http://www.replicant.us/
Blog: http://blog.replicant.us/
Wiki/tracker/forums: http://redmine.replicant.us/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150807/1f9bbc8a/attachment.sig>
#30 lore raw

PATCH 7/12 sniper: Serial number support, obtained from die ID

Quoted 82 lines · Paul Kocialkowski

Le mardi 04 ao?t 2015 ? 14:27 -0400, Tom Rini a ?crit :

Quoted 64 lines · Paul Kocialkowski
Quoted 63 lines

Le mardi 04 ao?t 2015 ? 14:16 -0400, Tom Rini a ?crit :

Quoted 61 lines · Paul Kocialkowski
Quoted 51 lines

Le lundi 03 ao?t 2015 ? 22:08 -0400, Tom Rini a ?crit :

Quoted 28 lines · Paul Kocialkowski
Quoted 27 lines

The OMAP3 has some die-specific ID bits that we can use to give the device a (more or less) unique serial number. This is particularly useful for e.g. USB.

---
 board/lge/sniper/sniper.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
board/lge/sniper/sniper.c +2 -0
index 44d422d..f26855d 100644
@@ -70,7 +70,9 @@ int board_init(void)
 
 int misc_init_r(void)
 {
+	char serial_string[17] = { 0 };
 	char reboot_mode[2] = { 0 };
+	u32 dieid[4] = { 0 };
 
 	/* Reboot mode */
 
@@ -82,6 +84,17 @@ int misc_init_r(void)
 		omap_reboot_mode_clear();
 	}
 
Quoted 16 lines

board/lge/sniper/sniper.c int misc_init_r(void) · line 99

Quoted 13 lines
board/lge/sniper/sniper.c +11 -0
+	/* Serial number */
+
+	get_dieid((u32 *)&dieid);
+
+	if (!getenv("serial#")) {
+		snprintf(serial_string, sizeof(serial_string),
+			"%08x%08x", dieid[0], dieid[3]);
+
+		setenv("serial#", serial_string);
+	}
+
 	return 0;
 }

Shouldn't this be in more generic code so everyone gets this set now? Thanks!

Well, we had a similar discussion for sunxi, and the outcome was that serial number could be obtained from other places on other devices (e.g. EEPROM) or be calculated from the dieid bits in a different way, so I prefer to keep this board-specific instead of omap3-generic for now.

Quoted 4 lines

This merely matches what is done on Android OMAP devices, but one could do it another way, too.

What do you think?

I think, ug, arch/arm/cpu/armv7/omap-common/utils.c::usb_set_serial_num_from_die_id() should be called set_serial_num_from_die_id() and we can use that for this board too even if it's not ideal.

Quoted 7 lines
Quoted 5 lines

Oh okay then, I don't have any problem with making this code common, especially if it's not called by every omap3 board then.

I agree with your proposal. Should I submit a v2 with a patch in that direction?

Sounds good, thanks!

Taking a closer look at things, it appears that various (non-omap3) boards are grabbing the Die ID bits on their own and then calling those functions (usb_fake_mac_from_die_id, usb_set_serial_num_from_die_id).

IMHO, we should have a common naming scheme for the function to get the dieid (omap_dieid), define that for each omap platform and have it called in omap-common code (with one function for the serial number and one for the fake mac), just like what I did with omap_sys_boot_device.

Quoted 8 lines

Then, each board would simply call those functions directly, without having to care about how to obtain the die id bits.

This seems like a series that would deserve to live on its own, so I suggest that you merge Optimus Black support as-is for now and I'll submit another series to implement that behaviour on top.

What do you think?

Yes, OK, follow-up series to clean-up that for everyone.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150813/0abb7cc3/attachment.sig>
#31 lore raw

PATCH 7/12 sniper: Serial number support, obtained from die ID

Le jeudi 13 ao?t 2015 ? 08:13 -0400, Tom Rini a ?crit :

Quoted 110 lines · Paul Kocialkowski
Quoted 109 lines

Le mardi 04 ao?t 2015 ? 14:27 -0400, Tom Rini a ?crit :

Quoted 84 lines
Quoted 82 lines · Paul Kocialkowski

Le mardi 04 ao?t 2015 ? 14:16 -0400, Tom Rini a ?crit :

Quoted 68 lines
Quoted 66 lines · Paul Kocialkowski

Le lundi 03 ao?t 2015 ? 22:08 -0400, Tom Rini a ?crit :

Quoted 43 lines
Quoted 40 lines · Paul Kocialkowski

The OMAP3 has some die-specific ID bits that we can use to give the device a
(more or less) unique serial number. This is particularly useful for e.g. USB.

---
 board/lge/sniper/sniper.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
board/lge/sniper/sniper.c +11 -0
index 44d422d..f26855d 100644
@@ -70,7 +70,9 @@ int board_init(void)
 
 int misc_init_r(void)
 {
+	char serial_string[17] = { 0 };
 	char reboot_mode[2] = { 0 };
+	u32 dieid[4] = { 0 };
 
 	/* Reboot mode */
 
@@ -82,6 +84,17 @@ int misc_init_r(void)
 		omap_reboot_mode_clear();
 	}
 
+	/* Serial number */
+
+	get_dieid((u32 *)&dieid);
+
+	if (!getenv("serial#")) {
+		snprintf(serial_string, 
 sizeof(serial_string),
+			"%08x%08x", dieid[0], 
 dieid[3]);
+
+		setenv("serial#", serial_string);
Quoted 8 lines
Quoted 4 lines
board/lge/sniper/sniper.c +2 -0
+	}
+
 	return 0;

}

Shouldn't this be in more generic code so everyone gets this set now?
Thanks!

Well, we had a similar discussion for sunxi, and the outcome was that
serial number could be obtained from other places on other devices (e.g.
EEPROM) or be calculated from the dieid bits in a different way, so I
prefer to keep this board-specific instead of omap3-generic for now.

This merely matches what is done on Android OMAP devices, but one could
do it another way, too.

Quoted 8 lines
Quoted 1 line

What do you think?

I think, ug,
arch/arm/cpu/armv7/omap -common/utils.c::usb_set_serial_num_from_die_id() should be called set_serial_num_from_die_id() and we can use that for
this board too even if it's not ideal.

Oh okay then, I don't have any problem with making this code common,
especially if it's not called by every omap3 board then.

Quoted 5 lines
Quoted 3 lines

I agree with your proposal. Should I submit a v2 with a patch in that
direction?

Sounds good, thanks!

Taking a closer look at things, it appears that various (non-omap3) boards are grabbing the Die ID bits on their own and then calling those
functions (usb_fake_mac_from_die_id, usb_set_serial_num_from_die_id).

IMHO, we should have a common naming scheme for the function to get the
dieid (omap_dieid), define that for each omap platform and have it called in omap-common code (with one function for the serial number and
one for the fake mac), just like what I did with omap_sys_boot_device.

Then, each board would simply call those functions directly, without
having to care about how to obtain the die id bits.

Quoted 8 lines
Quoted 6 lines

This seems like a series that would deserve to live on its own, so I
suggest that you merge Optimus Black support as-is for now and I'll submit another series to implement that behaviour on top.

What do you think?

Yes, OK, follow-up series to clean-up that for everyone.

Good, thanks for merging this, I'll get around producing that series sometime next week, I'm at CCCamp for now!

Signature · 12 lines
Paul Kocialkowski 

* Site web : http://www.paulk.fr/
* Blog : http://blog.paulk.fr/
* Dev blog : http://code.paulk.fr/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150816/90c8729b/attachment-0001.sig>
#32 lore raw

PATCH 7/12 sniper: Serial number support, obtained from die ID

In reply to Paul Kocialkowski
Quoted 4 lines · Paul Kocialkowski

The OMAP3 has some die-specific ID bits that we can use to give the device a (more or less) unique serial number. This is particularly useful for e.g. USB.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150813/ea6cec12/attachment.sig>
#33 lore raw

PATCH 8/12 sniper: Pass serial number through ATAG

In reply to Paul Kocialkowski

Now that the serial number is correctly defined, we can pass it to the kernel using the (legacy) ATAG method. It will be automatically passed via device-tree when enabled.

---
 board/lge/sniper/sniper.c | 18 ++++++++++++++++++
 include/configs/sniper.h  |  1 +
 2 files changed, 19 insertions(+)
board/lge/sniper/sniper.c +18 -0
index f26855d..b211528 100644
@@ -98,6 +98,24 @@ int misc_init_r(void)
 	return 0;
 }
 
+void get_board_serial(struct tag_serialnr *serialnr)
+{
+	char *serial_string;
+	unsigned long long serial;
+
+	serial_string = getenv("serial#");
+
+	if (serial_string) {
+		serial = simple_strtoull(serial_string, NULL, 16);
+
+		serialnr->high = (unsigned int) (serial >> 32);
+		serialnr->low = (unsigned int) (serial & 0xffffffff);
+	} else {
+		serialnr->high = 0;
+		serialnr->low = 0;
+	}
+}
+
 void set_muxconf_regs(void)
 {
 	MUX_SNIPER();
include/configs/sniper.h +1 -0
index eb1252d..159ed4c 100644
@@ -239,6 +239,7 @@
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_INITRD_TAG
 #define CONFIG_REVISION_TAG
+#define CONFIG_SERIAL_TAG
 
 /*
  * Boot
Signature · 1 line
1.9.1
#34 lore raw

PATCH 8/12 sniper: Pass serial number through ATAG

Quoted 5 lines · Paul Kocialkowski

Now that the serial number is correctly defined, we can pass it to the kernel using the (legacy) ATAG method. It will be automatically passed via device-tree when enabled.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150803/46711234/attachment.sig>
#35 lore raw

PATCH 8/12 sniper: Pass serial number through ATAG

In reply to Paul Kocialkowski
Quoted 6 lines · Paul Kocialkowski

Now that the serial number is correctly defined, we can pass it to the kernel using the (legacy) ATAG method. It will be automatically passed via device-tree when enabled.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150813/92f635f2/attachment.sig>
#36 lore raw

PATCH 9/12 sniper: Fastboot support

In reply to Paul Kocialkowski

This adds support for the fastboot USB gadget, including flashing to the internal MMC and reboot to bootloader or not.

---
 board/lge/sniper/sniper.c | 30 ++++++++++++++++++++++++++++++
 include/configs/sniper.h  | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)
board/lge/sniper/sniper.c +30 -0
index b211528..2bfc9c5 100644
@@ -10,6 +10,8 @@
 #include <common.h>
 #include <dm.h>
 #include <linux/ctype.h>
+#include <linux/usb/musb.h>
+#include <asm/omap_musb.h>
 #include <asm/arch/mmc_host_def.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mem.h>
@@ -37,6 +39,25 @@ U_BOOT_DEVICE(sniper_serial) = {
 	.platdata = &serial_omap_platdata
 };
 
+static struct musb_hdrc_config musb_config = {
+	.multipoint = 1,
+	.dyn_fifo = 1,
+	.num_eps = 16,
+	.ram_bits = 12
+};
+
+static struct omap_musb_board_data musb_board_data = {
+	.interface_type	= MUSB_INTERFACE_ULPI,
+};
+
+static struct musb_hdrc_platform_data musb_platform_data = {
+	.mode = MUSB_PERIPHERAL,
+	.config = &musb_config,
+	.power = 100,
+	.platform_ops = &omap2430_ops,
+	.board_data = &musb_board_data,
+};
+
 #ifdef CONFIG_SPL_BUILD
 void get_board_mem_timings(struct board_sdrc_timings *timings)
 {
@@ -95,6 +116,10 @@ int misc_init_r(void)
 		setenv("serial#", serial_string);
 	}
 
+	/* MUSB */
+
+	musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE);
+
 	return 0;
 }
 
@@ -116,6 +141,11 @@ void get_board_serial(struct tag_serialnr *serialnr)
 	}
 }
 
+int fb_set_reboot_flag(void)
+{
+	return omap_reboot_mode_store('b');
+}
+
 void set_muxconf_regs(void)
 {
 	MUX_SNIPER();
include/configs/sniper.h +39 -0
index 159ed4c..4b330bc 100644
@@ -216,6 +216,43 @@
 					  115200 }
 
 /*
+ * USB gadget
+ */
+
+#define CONFIG_MUSB_GADGET
+#define CONFIG_MUSB_PIO_ONLY
+#define CONFIG_USB_MUSB_OMAP2PLUS
+#define CONFIG_TWL4030_USB
+
+#define CONFIG_USB_GADGET
+#define CONFIG_USB_GADGET_DUALSPEED
+#define CONFIG_USB_GADGET_VBUS_DRAW	0
+
+/*
+ * Download
+ */
+
+#define CONFIG_USB_GADGET_DOWNLOAD
+
+#define CONFIG_G_DNL_VENDOR_NUM		0x0451
+#define CONFIG_G_DNL_PRODUCT_NUM	0xd022
+#define CONFIG_G_DNL_MANUFACTURER	"Texas Instruments"
+
+/*
+ * Fastboot
+ */
+
+#define CONFIG_USB_FUNCTION_FASTBOOT
+
+#define CONFIG_FASTBOOT_BUF_ADDR	CONFIG_SYS_LOAD_ADDR
+#define CONFIG_FASTBOOT_BUF_SIZE	0x2000000
+
+#define CONFIG_FASTBOOT_FLASH
+#define CONFIG_FASTBOOT_FLASH_MMC_DEV	0
+
+#define CONFIG_CMD_FASTBOOT
+
+/*
  * Environment
  */
 
@@ -254,6 +291,8 @@
 	"setenv boot_mmc_part ${kernel_mmc_part}; " \
 	"if test reboot-${reboot-mode} = reboot-r; then " \
 	"echo recovery; setenv boot_mmc_part ${recovery_mmc_part}; fi; " \
+	"if test reboot-${reboot-mode} = reboot-b; then " \
+	"echo fastboot; fastboot 0; fi; " \
 	"part start mmc ${boot_mmc_dev} ${boot_mmc_part} boot_mmc_start; " \
 	"part size mmc ${boot_mmc_dev} ${boot_mmc_part} boot_mmc_size; " \
 	"mmc dev ${boot_mmc_dev}; " \
Signature · 1 line
1.9.1
#37 lore raw

PATCH 9/12 sniper: Fastboot support

Quoted 4 lines · Paul Kocialkowski

This adds support for the fastboot USB gadget, including flashing to the internal MMC and reboot to bootloader or not.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150803/62ae6135/attachment.sig>
#38 lore raw

PATCH 9/12 sniper: Fastboot support

In reply to Paul Kocialkowski
Quoted 5 lines · Paul Kocialkowski

This adds support for the fastboot USB gadget, including flashing to the internal MMC and reboot to bootloader or not.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150813/0bf63011/attachment.sig>
#39 lore raw

PATCH 10/12 sniper: Power button reset support

In reply to Paul Kocialkowski

This adds support for resetting the device on a long press on the power button.

---
 board/lge/sniper/sniper.c | 4 ++++
 1 file changed, 4 insertions(+)
board/lge/sniper/sniper.c +4 -0
index 2bfc9c5..97c2ed0 100644
@@ -95,6 +95,10 @@ int misc_init_r(void)
 	char reboot_mode[2] = { 0 };
 	u32 dieid[4] = { 0 };
 
+	/* Power button reset init */
+
+	twl4030_power_reset_init();
+
 	/* Reboot mode */
 
 	reboot_mode[0] = omap_reboot_mode();
Signature · 1 line
1.9.1
#40 lore raw

PATCH 10/12 sniper: Power button reset support

Quoted 3 lines · Paul Kocialkowski

This adds support for resetting the device on a long press on the power button.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150803/0098b653/attachment.sig>
#41 lore raw

PATCH 10/12 sniper: Power button reset support

In reply to Paul Kocialkowski
Quoted 4 lines · Paul Kocialkowski

This adds support for resetting the device on a long press on the power button.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150813/11513f16/attachment.sig>
#42 lore raw

PATCH 11/12 sniper: Power off when the power on reason is not a valid one

In reply to Paul Kocialkowski

In most cases, userspace will attempt to power off the device with HALT instead of POWER_OFF, which triggers a reset instead of a proper power off from the TWL4030. Hence, it is up to the bootloader to actually turn the device off when there is no reason to turn it on.

A reboot identified with the OMAP reboot mode bits set is acceptable, as well as a power on reason from either the power button, USB or charger plug.

Other cases should trigger a power off. Note that for the U-Boot reset command to take effect, we have to fill-in the OMAP reboot bits.

---
 board/lge/sniper/sniper.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
board/lge/sniper/sniper.c +18 -0
index 97c2ed0..c94a3fa 100644
@@ -94,6 +94,7 @@ int misc_init_r(void)
 	char serial_string[17] = { 0 };
 	char reboot_mode[2] = { 0 };
 	u32 dieid[4] = { 0 };
+	unsigned char data = 0;
 
 	/* Power button reset init */
 
@@ -107,6 +108,18 @@ int misc_init_r(void)
 			setenv("reboot-mode", (char *)reboot_mode);
 
 		omap_reboot_mode_clear();
+	} else {
+		/*
+		 * When not rebooting, valid power on reasons are either the
+		 * power button, charger plug or USB plug.
+		 */
+
+		data |= twl4030_input_power_button();
+		data |= twl4030_input_charger();
+		data |= twl4030_input_usb();
+
+		if (!data)
+			twl4030_power_off();
 	}
 
 	/* Serial number */
@@ -145,6 +158,11 @@ void get_board_serial(struct tag_serialnr *serialnr)
 	}
 }
 
+void reset_misc(void)
+{
+	omap_reboot_mode_store('u');
+}
+
 int fb_set_reboot_flag(void)
 {
 	return omap_reboot_mode_store('b');
Signature · 1 line
1.9.1
#43 lore raw

PATCH 11/12 sniper: Power off when the power on reason is not a valid one

Quoted 5 lines · Paul Kocialkowski

In most cases, userspace will attempt to power off the device with HALT instead of POWER_OFF, which triggers a reset instead of a proper power off from the TWL4030. Hence, it is up to the bootloader to actually turn the device off when there is no reason to turn it on.

Quoted 7 lines

A reboot identified with the OMAP reboot mode bits set is acceptable, as well as a power on reason from either the power button, USB or charger plug.

Other cases should trigger a power off. Note that for the U-Boot reset command to take effect, we have to fill-in the OMAP reboot bits.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150803/b7323ea7/attachment.sig>
#44 lore raw

PATCH 11/12 sniper: Power off when the power on reason is not a valid one

In reply to Paul Kocialkowski
Quoted 5 lines · Paul Kocialkowski

In most cases, userspace will attempt to power off the device with HALT instead of POWER_OFF, which triggers a reset instead of a proper power off from the TWL4030. Hence, it is up to the bootloader to actually turn the device off when there is no reason to turn it on.

Quoted 8 lines

A reboot identified with the OMAP reboot mode bits set is acceptable, as well as a power on reason from either the power button, USB or charger plug.

Other cases should trigger a power off. Note that for the U-Boot reset command to take effect, we have to fill-in the OMAP reboot bits.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150813/cca82a5f/attachment.sig>
#45 lore raw

PATCH 12/12 sniper: Keypad support, with recovery and fastboot key combinations

In reply to Paul Kocialkowski

Using the twl4030 keypad allows booting directly into some special boot modes, such as recovery or fastboot. the VOL+ key will trigger a boot to recovery while the VOL- key will trigger a boot to fastboot.

The G (gesture) key remains unused at this point.

---
 board/lge/sniper/sniper.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
board/lge/sniper/sniper.c +16 -0
index c94a3fa..a43f640 100644
@@ -91,18 +91,34 @@ int board_init(void)
 
 int misc_init_r(void)
 {
+	unsigned char keypad_matrix[64] = { 0 };
 	char serial_string[17] = { 0 };
 	char reboot_mode[2] = { 0 };
 	u32 dieid[4] = { 0 };
+	unsigned char keys[3];
 	unsigned char data = 0;
 
 	/* Power button reset init */
 
 	twl4030_power_reset_init();
 
+	/* Keypad */
+
+	twl4030_keypad_scan((unsigned char *)&keypad_matrix);
+
+	keys[0] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 0);
+	keys[1] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 1);
+	keys[2] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 2);
+
 	/* Reboot mode */
 
 	reboot_mode[0] = omap_reboot_mode();
+
+	if (keys[0])
+		reboot_mode[0] = 'r';
+	else if (keys[1])
+		reboot_mode[0] = 'b';
+
 	if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
 		if (!getenv("reboot-mode"))
 			setenv("reboot-mode", (char *)reboot_mode);
Signature · 1 line
1.9.1
#46 lore raw

PATCH 12/12 sniper: Keypad support, with recovery and fastboot key combinations

Quoted 7 lines · Paul Kocialkowski

Using the twl4030 keypad allows booting directly into some special boot modes, such as recovery or fastboot. the VOL+ key will trigger a boot to recovery while the VOL- key will trigger a boot to fastboot.

The G (gesture) key remains unused at this point.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150803/1d64e9dd/attachment.sig>
#47 lore raw

PATCH 12/12 sniper: Keypad support, with recovery and fastboot key combinations

In reply to Paul Kocialkowski
Quoted 8 lines · Paul Kocialkowski

Using the twl4030 keypad allows booting directly into some special boot modes, such as recovery or fastboot. the VOL+ key will trigger a boot to recovery while the VOL- key will trigger a boot to fastboot.

The G (gesture) key remains unused at this point.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150813/7a736dfb/attachment.sig>
#48 lore raw

cover LG Optimus Black (P970) codename sniper support series (and driver-model issue)

In reply to Paul Kocialkowski

Le lundi 20 juillet 2015 ? 15:17 +0200, Paul Kocialkowski a ?crit :

Quoted 3 lines

This patch series adds support for the LG Optimus Black (P970) codename sniper, see the commit that introduces the board and config files for a short description of the device.

Any comment on this series? I would really like to get that new device merged before the merge window ends.

Thanks!

Quoted 32 lines

This should be applied on top of patches that I have submitted to the list but were not merged yet, especially:
* omap-common: Common boot code OMAP3 support and cleanup
* omap3: CONFIG_REVISION_TAG ifdef check for get_board_rev

At this point, support as submitted as this point is minimalistic. It is not ready for daily use, but introduces the basic elements that are needed to have a sane base upon which the rest of the device support will be introduced.

In particular, the device is currently headless, mainly because the display backlight is not enabled. Other important features such as the MUIC are not enabled, so USB will only work in U-Boot when the device boots with an USB cable already attached. In addition, the external MMC is not supported in U-Boot either, as it requires support for a separate PMIC.

A work in progress commit introduces support for (some of) those bits in a dirty and non-mergeable way is available at:
http://git.code.paulk.fr/gitweb/?p=u-boot.git;a=shortlog;h=refs/heads/sniper-next

Having those bits written correctly would require writing some drivers using the power framework. In the long run, those would have to use the driver model API, which would involve converting the I2C driver to DM as well. This is too much overhead for now, but it will be done eventually.

The main problem I see with doing that work now is that I2C DM seems to heavily rely on device-tree. Other parts of the OMAP platform support were converted to DM but use platform data defined in each board. That solution looks good to me, but doesn't work with I2C. Thus, we could either modify the I2C driver to cope with the lack of device-tree or make the use of device-tree a hard requirement for driver model, implying that each omap3 boards would have to provide a device-tree file as well.

Quoted 8 lines

Both solutions look good to me and I'll let experts decide what to do. Either way, I need to know what the right solution to this problem is to be able to move forward.

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150726/2bbf39cf/attachment.sig>