Skip to contentSkip to conversation

env: enable accessing the environment in an EXT4 partition

PATCH New Jorge Ramirez-Ortiz 1 participant 5 messages Jan 9, 2018

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

PATCH 1/5 env: enable accessing the environment in an EXT4 partition

From: Jorge Ramirez-Ortiz <[email protected]>

For example to store the environment in a file named "/uboot.env" in MMC "0", where partition "1" contains the EXT4 filesystem, the following configs should be added to the board's default config:

CONFIG_ENV_IS_IN_EXT4=y
CONFIG_ENV_EXT4_DEVICE_AND_PART="0:1"
CONFIG_ENV_EXT4_FILE="/uboot.env"
CONFIG_ENV_EXT4_INTERFACE="mmc"

---
 env/Kconfig | 39 +++++++++++++++++++++++++++++++++++++++
 env/env.c   |  2 ++
 env/ext4.c  | 20 ++++++++++----------
 3 files changed, 51 insertions(+), 10 deletions(-)
env/Kconfig +39 -0
index bef6e89..692f863 100644
@@ -81,6 +81,13 @@ config ENV_IS_IN_FAT
 	  - CONFIG_FAT_WRITE:
 	  This must be enabled. Otherwise it cannot save the environment file.
 
+config ENV_IS_IN_EXT4
+	bool "Environment is in a EXT4 filesystem"
+	depends on !CHAIN_OF_TRUST
+	select EXT4_WRITE
+	help
+	  Define this if you want to use the EXT4 file system for the environment.
+
 config ENV_IS_IN_FLASH
 	bool "Environment in flash memory"
 	depends on !CHAIN_OF_TRUST
@@ -396,6 +403,38 @@ config ENV_FAT_FILE
 	  It's a string of the FAT file name. This file use to store the
 	  environment.
 
+config ENV_EXT4_INTERFACE
+	string "Name of the block device for the environment"
+	depends on ENV_IS_IN_EXT4
+	help
+	  Define this to a string that is the name of the block device.
+
+config ENV_EXT4_DEVICE_AND_PART
+	string "Device and partition for where to store the environemt in EXT4"
+	depends on ENV_IS_IN_EXT4
+	help
+	  Define this to a string to specify the partition of the device. It can
+	  be as following:
+
+	    "D:P", "D:0", "D", "D:" or "D:auto" (D, P are integers. And P >= 1)
+	       - "D:P": device D partition P. Error occurs if device D has no
+	                partition table.
+	       - "D:0": device D.
+	       - "D" or "D:": device D partition 1 if device D has partition
+	                      table, or the whole device D if has no partition
+	                      table.
+	       - "D:auto": first partition in device D with bootable flag set.
+	                   If none, first valid partition in device D. If no
+	                   partition table then means device D.
+
+config ENV_EXT4_FILE
+	string "Name of the EXT4 file to use for the environemnt"
+	depends on ENV_IS_IN_EXT4
+	default "uboot.env"
+	help
+	  It's a string of the EXT4 file name. This file use to store the
+	  environment (explicit path to the file)
+
 if ARCH_SUNXI
 
 config ENV_OFFSET
env/env.c +2 -0
index 76a5608..7455632 100644
@@ -32,6 +32,8 @@ static enum env_location env_get_default_location(void)
 		return ENVL_EEPROM;
 	else if IS_ENABLED(CONFIG_ENV_IS_IN_FAT)
 		return ENVL_FAT;
+	else if IS_ENABLED(CONFIG_ENV_IS_IN_EXT4)
+		return ENVL_EXT4;
 	else if IS_ENABLED(CONFIG_ENV_IS_IN_FLASH)
 		return ENVL_FLASH;
 	else if IS_ENABLED(CONFIG_ENV_IS_IN_MMC)
env/ext4.c +10 -10
index 6520221..07fd061 100644
@@ -46,8 +46,8 @@ static int env_ext4_save(void)
 	if (err)
 		return err;
 
-	part = blk_get_device_part_str(EXT4_ENV_INTERFACE,
-					EXT4_ENV_DEVICE_AND_PART,
+	part = blk_get_device_part_str(CONFIG_ENV_EXT4_INTERFACE,
+					CONFIG_ENV_EXT4_DEVICE_AND_PART,
 					&dev_desc, &info, 1);
 	if (part < 0)
 		return 1;
@@ -57,16 +57,16 @@ static int env_ext4_save(void)
 
 	if (!ext4fs_mount(info.size)) {
 		printf("\n** Unable to use %s %s for saveenv **\n",
-		       EXT4_ENV_INTERFACE, EXT4_ENV_DEVICE_AND_PART);
+		       CONFIG_ENV_EXT4_INTERFACE, CONFIG_ENV_EXT4_DEVICE_AND_PART);
 		return 1;
 	}
 
-	err = ext4fs_write(EXT4_ENV_FILE, (void *)&env_new, sizeof(env_t));
+	err = ext4fs_write(CONFIG_ENV_EXT4_FILE, (void *)&env_new, sizeof(env_t));
 	ext4fs_close();
 
 	if (err == -1) {
 		printf("\n** Unable to write \"%s\" from %s%d:%d **\n",
-			EXT4_ENV_FILE, EXT4_ENV_INTERFACE, dev, part);
+			CONFIG_ENV_EXT4_FILE, CONFIG_ENV_EXT4_INTERFACE, dev, part);
 		return 1;
 	}
 
@@ -84,8 +84,8 @@ static int env_ext4_load(void)
 	int err;
 	loff_t off;
 
-	part = blk_get_device_part_str(EXT4_ENV_INTERFACE,
-					EXT4_ENV_DEVICE_AND_PART,
+	part = blk_get_device_part_str(CONFIG_ENV_EXT4_INTERFACE,
+					CONFIG_ENV_EXT4_DEVICE_AND_PART,
 					&dev_desc, &info, 1);
 	if (part < 0)
 		goto err_env_relocate;
@@ -95,16 +95,16 @@ static int env_ext4_load(void)
 
 	if (!ext4fs_mount(info.size)) {
 		printf("\n** Unable to use %s %s for loading the env **\n",
-		       EXT4_ENV_INTERFACE, EXT4_ENV_DEVICE_AND_PART);
+		       CONFIG_ENV_EXT4_INTERFACE, CONFIG_ENV_EXT4_DEVICE_AND_PART);
 		goto err_env_relocate;
 	}
 
-	err = ext4_read_file(EXT4_ENV_FILE, buf, 0, CONFIG_ENV_SIZE, &off);
+	err = ext4_read_file(CONFIG_ENV_EXT4_FILE, buf, 0, CONFIG_ENV_SIZE, &off);
 	ext4fs_close();
 
 	if (err == -1) {
 		printf("\n** Unable to read \"%s\" from %s%d:%d **\n",
-			EXT4_ENV_FILE, EXT4_ENV_INTERFACE, dev, part);
+			CONFIG_ENV_EXT4_FILE, CONFIG_ENV_EXT4_INTERFACE, dev, part);
 		goto err_env_relocate;
 	}
 
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/5 arm: mach-snapdragon: refactor clock driver

From: Jorge Ramirez-Ortiz <[email protected]>

In preparation to add support for the Dragonboard820c (APQ8096), refactor the current Snapdragon clock driver.

No new functionality has been added.

---
 arch/arm/mach-snapdragon/Makefile                  |   6 +-
 arch/arm/mach-snapdragon/clock-apq8016.c           | 181 ++-------------------
 arch/arm/mach-snapdragon/clock-snapdragon.c        | 134 +++++++++++++++
 arch/arm/mach-snapdragon/clock-snapdragon.h        |  40 +++++
 .../mach-snapdragon/include/mach/sysmap-apq8016.h  |  29 +++-
 5 files changed, 217 insertions(+), 173 deletions(-)
 create mode 100644 arch/arm/mach-snapdragon/clock-snapdragon.c
 create mode 100644 arch/arm/mach-snapdragon/clock-snapdragon.h
arch/arm/mach-snapdragon/Makefile +3 -2
index d82a04d..74f90dc 100644
@@ -4,5 +4,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-y += clock-apq8016.o
-obj-y += sysmap-apq8016.o
+obj-$(CONFIG_TARGET_DRAGONBOARD410C) += clock-apq8016.o
+obj-$(CONFIG_TARGET_DRAGONBOARD410C) += sysmap-apq8016.o
+obj-y += clock-snapdragon.o
arch/arm/mach-snapdragon/clock-apq8016.c +12 -169

219 lines not on this page · raw message

arch/arm/mach-snapdragon/clock-snapdragon.c new file +134 -0

134 lines not on this page · raw message

arch/arm/mach-snapdragon/clock-snapdragon.h new file +40 -0
new file mode 100644
index 0000000..c087eb9
@@ -0,0 +1,40 @@
+/*
+ * Qualcomm APQ8016, APQ8096
+ *
+ * (C) Copyright 2017 Jorge Ramirez-Ortiz <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef _CLOCK_SNAPDRAGON_H
+#define _CLOCK_SNAPDRAGON_H
+
+#define CFG_CLK_SRC_CXO   (0 << 8)
+#define CFG_CLK_SRC_GPLL0 (1 << 8)
+#define CFG_CLK_SRC_MASK  (7 << 8)
+
+struct gpll0_ctrl {
+	uintptr_t status;
+	int status_bit;
+	uintptr_t ena_vote;
+	int vote_bit;
+};
+
+struct bcr_regs {
+	uintptr_t cfg_rcgr;
+	uintptr_t cmd_rcgr;
+	uintptr_t M;
+	uintptr_t N;
+	uintptr_t D;
+};
+
+struct msm_clk_priv {
+	phys_addr_t base;
+};
+
+void clk_enable_gpll0(phys_addr_t base, const struct gpll0_ctrl *pll0);
+void clk_bcr_update(phys_addr_t apps_cmd_rgcr);
+void clk_enable_cbc(phys_addr_t cbcr);
+void clk_rcg_set_rate_mnd(phys_addr_t base, const struct bcr_regs *regs,
+				 int div, int m, int n, int source);
+
+#endif
arch/arm/mach-snapdragon/include/mach/sysmap-apq8016.h +27 -2
index cdbfad0..1094b14 100644
@@ -8,7 +8,32 @@
 #ifndef _MACH_SYSMAP_APQ8016_H
 #define _MACH_SYSMAP_APQ8016_H
 
-#define GICD_BASE 0x0b000000
-#define GICC_BASE 0x0a20c000
+#define GICD_BASE			(0x0b000000)
+#define GICC_BASE			(0x0a20c000)
+
+/* Clocks: (from CLK_CTL_BASE)  */
+#define GPLL0_STATUS			(0x2101C)
+#define APCS_GPLL_ENA_VOTE		(0x45000)
+
+#define SDCC_BCR(n)			((n * 0x1000) + 0x41000)
+#define SDCC_CMD_RCGR(n)		((n * 0x1000) + 0x41004)
+#define SDCC_CFG_RCGR(n)		((n * 0x1000) + 0x41008)
+#define SDCC_M(n)			((n * 0x1000) + 0x4100C)
+#define SDCC_N(n)			((n * 0x1000) + 0x41010)
+#define SDCC_D(n)			((n * 0x1000) + 0x41014)
+#define SDCC_APPS_CBCR(n)		((n * 0x1000) + 0x41018)
+#define SDCC_AHB_CBCR(n)		((n * 0x1000) + 0x4101C)
+
+/* BLSP1 AHB clock (root clock for BLSP) */
+#define BLSP1_AHB_CBCR			0x1008
+
+/* Uart clock control registers */
+#define BLSP1_UART2_BCR			(0x3028)
+#define BLSP1_UART2_APPS_CBCR		(0x302C)
+#define BLSP1_UART2_APPS_CMD_RCGR	(0x3034)
+#define BLSP1_UART2_APPS_CFG_RCGR	(0x3038)
+#define BLSP1_UART2_APPS_M		(0x303C)
+#define BLSP1_UART2_APPS_N		(0x3040)
+#define BLSP1_UART2_APPS_D		(0x3044)
 
 #endif
Signature · 1 line
2.7.4
#2 lore raw

PATCH 3/5 db820c: add qualcomm dragonboard 820C support

In reply to Jorge Ramirez-Ortiz

From: Jorge Ramirez-Ortiz <[email protected]>

This commit adds support for 96Boards Dragonboard820C.

The board is based on APQ8086 Qualcomm Soc, complying with the 96Boards specification.

Features
- 4x Kyro CPU (64 bit) up to 2.15GHz
- USB2.0
- USB3.0
- ISP
- Qualcomm Hexagon DSP
- SD 3.0 (UHS-I)
- UFS 2.0
- Qualcomm Adreno 530 GPU
- GPS
- BT 4.2
- Wi-Fi 2.4GHz, 5GHz (802.11ac)
- PCIe 2.0
- MIPI-CSI, MIPI-DSI
- I2S

U-Boot boots chained from LK (LK implements the fastboot protocol) in 64-bit mode.

For detailed build instructions see readme.txt in the board directory.

---
 arch/arm/dts/Makefile                              |   3 +-
 arch/arm/dts/dragonboard820c.dts                   |  65 +++
 arch/arm/mach-snapdragon/Kconfig                   |  10 +
 arch/arm/mach-snapdragon/Makefile                  |   2 +
 arch/arm/mach-snapdragon/clock-apq8096.c           |  62 +++
 .../mach-snapdragon/include/mach/sysmap-apq8096.h  |  29 ++
 arch/arm/mach-snapdragon/sysmap-apq8096.c          |  32 ++
 board/qualcomm/dragonboard820c/Kconfig             |  15 +
 board/qualcomm/dragonboard820c/MAINTAINERS         |   6 +
 board/qualcomm/dragonboard820c/Makefile            |   8 +
 board/qualcomm/dragonboard820c/dragonboard820c.c   | 128 ++++++
 board/qualcomm/dragonboard820c/head.S              |  34 ++
 board/qualcomm/dragonboard820c/readme.txt          | 463 +++++++++++++++++++++
 board/qualcomm/dragonboard820c/u-boot.lds          | 106 +++++
 configs/dragonboard820c_defconfig                  |  37 ++
 include/configs/dragonboard820c.h                  |  72 ++++
 16 files changed, 1071 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/dragonboard820c.dts
 create mode 100644 arch/arm/mach-snapdragon/clock-apq8096.c
 create mode 100644 arch/arm/mach-snapdragon/include/mach/sysmap-apq8096.h
 create mode 100644 arch/arm/mach-snapdragon/sysmap-apq8096.c
 create mode 100644 board/qualcomm/dragonboard820c/Kconfig
 create mode 100644 board/qualcomm/dragonboard820c/MAINTAINERS
 create mode 100644 board/qualcomm/dragonboard820c/Makefile
 create mode 100644 board/qualcomm/dragonboard820c/dragonboard820c.c
 create mode 100644 board/qualcomm/dragonboard820c/head.S
 create mode 100644 board/qualcomm/dragonboard820c/readme.txt
 create mode 100644 board/qualcomm/dragonboard820c/u-boot.lds
 create mode 100644 configs/dragonboard820c_defconfig
 create mode 100644 include/configs/dragonboard820c.h
arch/arm/dts/Makefile +2 -1
index a895c70..6d0587e 100644
@@ -211,7 +211,8 @@ dtb-$(CONFIG_FSL_LSCH2) += fsl-ls1043a-qds-duart.dtb \
 	fsl-ls1012a-rdb.dtb \
 	fsl-ls1012a-frdm.dtb
 
-dtb-$(CONFIG_ARCH_SNAPDRAGON) += dragonboard410c.dtb
+dtb-$(CONFIG_TARGET_DRAGONBOARD410C) += dragonboard410c.dtb
+dtb-$(CONFIG_TARGET_DRAGONBOARD820C) += dragonboard820c.dtb
 
 dtb-$(CONFIG_STM32F7) += stm32f746-disco.dtb \
 	stm32f769-disco.dtb
arch/arm/dts/dragonboard820c.dts new file +65 -0

65 lines not on this page · raw message

arch/arm/mach-snapdragon/Kconfig +10 -0
index dc7ba21..d55dc1a 100644
@@ -19,8 +19,18 @@ config TARGET_DRAGONBOARD410C
 	  - HDMI
 	  - 20-pin low speed and 40-pin high speed expanders, 4 LED, 3 buttons
 
+config TARGET_DRAGONBOARD820C
+	bool "96Boards Dragonboard 820C"
+	help
+	  Support for 96Boards Dragonboard 820C. This board complies with
+	  96Board Open Platform Specifications. Features:
+	  - Qualcomm Snapdragon 820C SoC - APQ8096 (4xKyro CPU)
+	  - 3GiB RAM
+	  - 32GiB UFS drive
+
 endchoice
 
 source "board/qualcomm/dragonboard410c/Kconfig"
+source "board/qualcomm/dragonboard820c/Kconfig"
 
 endif
arch/arm/mach-snapdragon/Makefile +2 -0
index 74f90dc..7f35c79 100644
@@ -4,6 +4,8 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
+obj-$(CONFIG_TARGET_DRAGONBOARD820C) += clock-apq8096.o
+obj-$(CONFIG_TARGET_DRAGONBOARD820C) += sysmap-apq8096.o
 obj-$(CONFIG_TARGET_DRAGONBOARD410C) += clock-apq8016.o
 obj-$(CONFIG_TARGET_DRAGONBOARD410C) += sysmap-apq8016.o
 obj-y += clock-snapdragon.o
arch/arm/mach-snapdragon/clock-apq8096.c new file +62 -0

62 lines not on this page · raw message

arch/arm/mach-snapdragon/include/mach/sysmap-apq8096.h new file +29 -0
new file mode 100644
index 0000000..fb89de2
@@ -0,0 +1,29 @@
+/*
+ * Qualcomm APQ8096 sysmap
+ *
+ * (C) Copyright 2017 Jorge Ramirez-Ortiz <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef _MACH_SYSMAP_APQ8096_H
+#define _MACH_SYSMAP_APQ8096_H
+
+#define TLMM_BASE_ADDR			(0x1010000)
+
+/* Strength (sdc1) */
+#define SDC1_HDRV_PULL_CTL_REG		(TLMM_BASE_ADDR + 0x0012D000)
+
+/* Clocks: (from CLK_CTL_BASE)  */
+#define GPLL0_STATUS			(0x0000)
+#define APCS_GPLL_ENA_VOTE		(0x52000)
+
+#define SDCC2_BCR			(0x14000) /* block reset */
+#define SDCC2_APPS_CBCR			(0x14004) /* branch control */
+#define SDCC2_AHB_CBCR			(0x14008)
+#define SDCC2_CMD_RCGR			(0x14010)
+#define SDCC2_CFG_RCGR			(0x14014)
+#define SDCC2_M				(0x14018)
+#define SDCC2_N				(0x1401C)
+#define SDCC2_D				(0x14020)
+
+#endif
arch/arm/mach-snapdragon/sysmap-apq8096.c new file +32 -0
new file mode 100644
index 0000000..cb6d1e4
@@ -0,0 +1,32 @@
+/*
+ * Qualcomm APQ8096 memory map
+ *
+ * (C) Copyright 2017 Jorge Ramirez Ortiz <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/armv8/mmu.h>
+
+static struct mm_region apq8096_mem_map[] = {
+	{
+		.virt = 0x0UL, /* Peripheral block */
+		.phys = 0x0UL, /* Peripheral block */
+		.size = 0x10000000UL,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+			 PTE_BLOCK_NON_SHARE |
+			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	}, {
+		.virt = 0x80000000UL, /* DDR */
+		.phys = 0x80000000UL, /* DDR */
+		.size = 0xC0000000UL,
+		.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+			 PTE_BLOCK_INNER_SHARE
+	}, {
+		/* List terminator */
+		0,
+	}
+};
+
+struct mm_region *mem_map = apq8096_mem_map;
board/qualcomm/dragonboard820c/Kconfig new file +15 -0
new file mode 100644
index 0000000..aff9af5
@@ -0,0 +1,15 @@
+if TARGET_DRAGONBOARD820C
+
+config SYS_BOARD
+	default "dragonboard820c"
+
+config SYS_VENDOR
+	default "qualcomm"
+
+config SYS_SOC
+	default "apq8096"
+
+config SYS_CONFIG_NAME
+	default "dragonboard820c"
+
+endif
board/qualcomm/dragonboard820c/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000..a157033
@@ -0,0 +1,6 @@
+DRAGONBOARD820C BOARD
+M:	Jorge Ramirez-Ortiz <[email protected]>
+S:	Maintained
+F:	board/qualcomm/dragonboard820c/
+F:	include/configs/dragonboard820c.h
+F:	configs/dragonboard820c_defconfig
board/qualcomm/dragonboard820c/Makefile new file +8 -0
new file mode 100644
index 0000000..a1ce4b2
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2017 Jorge Ramirez-Ortiz <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y	:= dragonboard820c.o
+extra-y += head.o
board/qualcomm/dragonboard820c/dragonboard820c.c new file +128 -0

128 lines not on this page · raw message

board/qualcomm/dragonboard820c/head.S new file +34 -0
new file mode 100644
index 0000000..06d82d5
@@ -0,0 +1,34 @@
+/*
+ * ARM64 header for proper chain-loading with Little Kernel.
+ *
+ * Little Kernel shipped with Dragonboard820C boots standard Linux images for
+ * ARM64. This file adds header that is required to boot U-Boot properly.
+ *
+ * For details see:
+ * https://www.kernel.org/doc/Documentation/arm64/booting.txt
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <config.h>
+
+/*
+ *   per document in linux/Doc/arm64/booting.text
+ */
+.global _arm64_header
+_arm64_header:
+	b _start
+	.word 0
+	.quad   CONFIG_SYS_TEXT_BASE-PHYS_SDRAM_1 /* Image load offset, LE */
+	.quad   0    /* Effective size of kernel image, little-endian */
+	.quad   0    /* kernel flags, little-endian */
+	.quad   0    /* reserved */
+	.quad   0    /* reserved */
+	.quad   0    /* reserved */
+	.byte   0x41 /* Magic number, "ARM\x64" */
+	.byte   0x52
+	.byte   0x4d
+	.byte   0x64
+	.word   0    /* reserved (used for PE COFF offset) */
board/qualcomm/dragonboard820c/readme.txt new file +459 -0

459 lines not on this page · raw message

board/qualcomm/dragonboard820c/u-boot.lds new file +106 -0

106 lines not on this page · raw message

configs/dragonboard820c_defconfig new file +36 -0
new file mode 100644
index 0000000..788ff28
@@ -0,0 +1,36 @@
+CONFIG_ARM=y
+CONFIG_ARM_SMCCC=y
+CONFIG_ARCH_SNAPDRAGON=y
+CONFIG_TARGET_DRAGONBOARD820C=y
+CONFIG_IDENT_STRING="\nQualcomm-DragonBoard 820C"
+CONFIG_DEFAULT_DEVICE_TREE="dragonboard820c"
+CONFIG_USE_BOOTARGS=y
+# CONFIG_DISPLAY_CPUINFO is not set
+# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_BOOTARGS="console=ttyMSM0,115200n8"
+CONFIG_SYS_PROMPT="dragonboard820c => "
+CONFIG_HUSH_PARSER=y
+CONFIG_CMD_BOOTEFI=y
+CONFIG_EFI_LOADER=y
+CONFIG_CMD_BOOTEFI_HELLO=y
+CONFIG_CMD_PXE=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_MD5SUM=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_PART=y
+CONFIG_CMD_TIMER=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_MMC=y
+CONFIG_OF_CONTROL=y
+CONFIG_MSM_SERIAL=y
+CONFIG_MMC_SDHCI_MSM=y
+CONFIG_MMC_SDHCI=y
+CONFIG_DM_MMC=y
+CONFIG_CLK=y
+CONFIG_PSCI_RESET=y
+CONFIG_ENV_IS_IN_EXT4=y
+CONFIG_ENV_EXT4_INTERFACE="mmc"
+CONFIG_ENV_EXT4_DEVICE_AND_PART="0:1"
+CONFIG_ENV_EXT4_FILE="/uboot.env"
include/configs/dragonboard820c.h new file +72 -0

72 lines not on this page · raw message

--
2.7.4

#3 lore raw

PATCH 4/5 db820c: enable pmic gpios for pm8994

In reply to Jorge Ramirez-Ortiz

From: Jorge Ramirez-Ortiz <[email protected]>

---
 arch/arm/dts/dragonboard820c.dts  | 43 +++++++++++++++++++++++++++++++++++++++
 configs/dragonboard820c_defconfig |  7 +++++++
 drivers/gpio/pm8916_gpio.c        |  7 +++++--
 3 files changed, 55 insertions(+), 2 deletions(-)
arch/arm/dts/dragonboard820c.dts +43 -0
index bad5a1e..3086d60 100644
@@ -61,5 +61,48 @@
 			 clock = <&gcc 0>;
 			clock-frequency = <200000000>;
 		 };
+
+		spmi at 400f000 {
+			compatible = "qcom,spmi-pmic-arb";
+			reg = <0x400f800 0x200>,
+			      <0x4400000 0x400000>,
+			      <0x4c00000 0x400000>;
+			#address-cells = <0x1>;
+			#size-cells = <0x1>;
+
+			pmic0: pm8994 at 0 {
+				compatible = "qcom,spmi-pmic";
+				reg = <0x0 0x1>;
+				#address-cells = <0x1>;
+				#size-cells = <0x1>;
+
+				pm8994_pon: pm8994_pon at 800 {
+					compatible = "qcom,pm8994-pwrkey";
+					reg = <0x800 0x96>;
+					#gpio-cells = <2>;
+					gpio-controller;
+					gpio-bank-name="pm8994_key.";
+				};
+
+				pm8994_gpios: pm8994_gpios at c000 {
+					compatible = "qcom,pm8994-gpio";
+					reg = <0xc000 0x400>;
+					gpio-controller;
+					gpio-count = <24>;
+					#gpio-cells = <2>;
+					gpio-bank-name="pm8994.";
+				};
+			};
+
+			pmic1: pm8994 at 1 {
+				compatible = "qcom,spmi-pmic";
+				reg = <0x1 0x1>;
+				#address-cells = <0x1>;
+				#size-cells = <0x1>;
+			};
+		};
 	};
+
 };
+
+#include "dragonboard820c-uboot.dtsi"
configs/dragonboard820c_defconfig +7 -0
index 788ff28..5e25e2e 100644
@@ -23,11 +23,18 @@ CONFIG_CMD_TIMER=y
 CONFIG_CMD_EXT4=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_PMIC=y
 CONFIG_OF_CONTROL=y
 CONFIG_MSM_SERIAL=y
+CONFIG_SPMI_MSM=y
 CONFIG_MMC_SDHCI_MSM=y
 CONFIG_MMC_SDHCI=y
 CONFIG_DM_MMC=y
+CONFIG_DM_GPIO=y
+CONFIG_DM_PMIC=y
+CONFIG_PMIC_PM8916=y
+CONFIG_PM8916_GPIO=y
 CONFIG_CLK=y
 CONFIG_PSCI_RESET=y
 CONFIG_ENV_IS_IN_EXT4=y
drivers/gpio/pm8916_gpio.c +5 -2
index 9ec2a24..056b982 100644
@@ -29,7 +29,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define REG_STATUS_VAL_MASK    0x1
 
 /* MODE_CTL */
-#define REG_CTL           0x40
+#define REG_CTL           	0x40
 #define REG_CTL_MODE_MASK       0x70
 #define REG_CTL_MODE_INPUT      0x00
 #define REG_CTL_MODE_INOUT      0x20
@@ -183,7 +183,7 @@ static int pm8916_gpio_probe(struct udevice *dev)
 		return -ENODEV;
 
 	reg = pmic_reg_read(dev->parent, priv->pid + REG_SUBTYPE);
-	if (reg != 0x5)
+	if (reg != 0x5 && reg != 0x1)
 		return -ENODEV;
 
 	return 0;
@@ -203,6 +203,7 @@ static int pm8916_gpio_ofdata_to_platdata(struct udevice *dev)
 
 static const struct udevice_id pm8916_gpio_ids[] = {
 	{ .compatible = "qcom,pm8916-gpio" },
+	{ .compatible = "qcom,pm8994-gpio" },	/* 22 GPIO's */
 	{ }
 };
 
@@ -278,6 +279,7 @@ static int pm8941_pwrkey_ofdata_to_platdata(struct udevice *dev)
 	struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
 
 	uc_priv->gpio_count = 2;
+	uc_priv->bank_name = dev_read_string(dev, "gpio-bank-name");
 	if (uc_priv->bank_name == NULL)
 		uc_priv->bank_name = "pm8916_key";
 
@@ -286,6 +288,7 @@ static int pm8941_pwrkey_ofdata_to_platdata(struct udevice *dev)
 
 static const struct udevice_id pm8941_pwrkey_ids[] = {
 	{ .compatible = "qcom,pm8916-pwrkey" },
+	{ .compatible = "qcom,pm8994-pwrkey" },
 	{ }
 };
 
Signature · 1 line
2.7.4
#4 lore raw

PATCH 5/5 db820c: stop autoboot when vol- pressed

In reply to Jorge Ramirez-Ortiz

From: Jorge Ramirez-Ortiz <[email protected]>

---
 arch/arm/dts/dragonboard820c-uboot.dtsi          | 19 ++++++++++++
 board/qualcomm/dragonboard820c/dragonboard820c.c | 37 +++++++++++++++++++++++-
 include/configs/dragonboard820c.h                |  2 ++
 3 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/dragonboard820c-uboot.dtsi
arch/arm/dts/dragonboard820c-uboot.dtsi new file +19 -0
new file mode 100644
index 0000000..167e72c
@@ -0,0 +1,19 @@
+/*
+ * U-Boot addition to handle Dragonboard 820c pins
+ *
+ * (C) Copyright 2017 Jorge Ramirez-Ortiz <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+&pm8994_pon {
+	key_vol_down {
+		gpios = <&pm8994_pon 1 0>;
+		label = "key_vol_down";
+	};
+
+	key_power {
+		gpios = <&pm8994_pon 0 0>;
+		label = "key_power";
+	};
+};
board/qualcomm/dragonboard820c/dragonboard820c.c +36 -1
index 8f40ba4..d4a20d2 100644
@@ -1,7 +1,7 @@
 /*
  * Board init file for Dragonboard 820C
  *
- * (C) Copyright 2017 Jorge Ramirez-Ortiz <[email protected]>	
+ * (C) Copyright 2017 Jorge Ramirez-Ortiz <[email protected]>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -14,6 +14,7 @@
 #include <asm/io.h>
 #include <linux/bitops.h>
 #include <asm/psci.h>
+#include <asm/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -126,3 +127,37 @@ void reset_cpu(ulong addr)
 {
 	psci_system_reset();
 }
+
+/* Check for vol- button - if pressed - stop autoboot */
+int misc_init_r(void)
+{
+	struct udevice *pon;
+	struct gpio_desc resin;
+	int node, ret;
+
+	ret = uclass_get_device_by_name(UCLASS_GPIO, "pm8994_pon at 800", &pon);
+	if (ret < 0) {
+		printf("Failed to find PMIC pon node. Check device tree\n");
+		return 0;
+	}
+
+	node = fdt_subnode_offset(gd->fdt_blob, dev_of_offset(pon),
+				  "key_vol_down");
+	if (node < 0) {
+		printf("Failed to find key_vol_down node. Check device tree\n");
+		return 0;
+	}
+
+	if (gpio_request_by_name_nodev(offset_to_ofnode(node), "gpios", 0,
+				       &resin, 0)) {
+		printf("Failed to request key_vol_down button.\n");
+		return 0;
+	}
+
+	if (dm_gpio_get_value(&resin)) {
+		env_set("bootdelay", "-1");
+		printf("Power button pressed - dropping to console.\n");
+	}
+
+	return 0;
+}
include/configs/dragonboard820c.h +2 -0
index 76bcaf8..e0c3c0c 100644
@@ -12,6 +12,8 @@
 #include <linux/sizes.h>
 #include <asm/arch/sysmap-apq8096.h>
 
+#define CONFIG_MISC_INIT_R /* To stop autoboot */
+
 /* Physical Memory Map */
 #define CONFIG_NR_DRAM_BANKS		2
 
Signature · 1 line
2.7.4