Skip to contentSkip to conversation

Add support for 96boards Dragonboard410C board

PATCH Superseded Mateusz Kulikowski 6 participants 38 messages Feb 7, 2016 – Mar 13, 2016

Subsystems (9)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add support for 96boards Dragonboard410C board

Hi All,

This is (hopefully) last version of Dragonboard410c series.

As always - for "simplicity" this series is available on my github:
https://github.com/hallor/u-boot/tree/dragonboard-for-mainline-v3

There are almost no changes (none that should break anything):
- Updated dragonboard readme.txt with info on how to stop @ fastboot
- Added SPMI entries into test.dts (so automatic DM tests would not fail)
- Added Tested-by and Reviewed-by Simon (from v2 comments)
- Rebased to recent master

@Simon: Thanks for the tests!

Regards,
Mateusz

V2 cover contents:

This is updated series. 99% of review changes are applied, specific changes are (as always) include in each patch.

You can find this series on my github (if anyone just want to try it - that branch has also wait_for_bit applied):
https://github.com/hallor/u-boot/tree/dragonboard-for-mainline-v2

I did target tests on Dragonboard410c, and build tested platforms that may be affected by ULPI changes.

@Simon:
I decided not to rewrite pm8916_gpio for now, but for sake of "cleannes" moved offending bindings to separate file (and they are now properly childs of pm8916_gpio).
I will update it during rework of SoC gpio driver (I will have to create proper pinmux/pinctrl drivers to get rid of Little Kernel eventually).

This series still needs wait_for_bit series that is not included (yet).

V1 cover contents:

I finally managed to cleanup RFC for submission. I've included changes in each patch, there is a bit of them, but all are needed :)

This series requires wait_for_bit patch that I send few days ago:
https://patchwork.ozlabs.org/patch/561185/

RFC cover contents:
http://lists.denx.de/pipermail/u-boot/2015-December/237365.html

Changes in v3:
- Updated test.dts to include SPMI like sandbox.dts does
- readme: Added info on how to enter fastboot mode and that dtbTool is also part of skales

Changes in v2:
- Added newline before return... (globally)
- Renamed p to priv (priv data) - it required some rewrapping
- Added Reviewed-by
- Reordered includes (again)
- Added newlines between returns
- Fixed error handling in msm_gpio_probe
- Added reviewed-by
- Add reviewed-by
- Add Reviewed-by (sjg)
- Add better (any) descriptions for Kconfig items.
- New patch, independent of the rest
- Should compile cleanly on all affected platforms
- Is orthogonal to series (i.e. if get's NAK will not break rest of series)
- Add acked-by
- Add reviewed-by
- Add Acked-by
- Use PORT_... macro to write to portsc
- Remove extra whitespace in probe()
- Add acked-by
- Use proper entry order in Kconfig
- Rename CONFIG_DM_SPMI -> CONFIG_SPMI
- Fix header ordering
- Add reviewed-by
- Rename CONFIG_DM_SPMI -> CONFIG_SPMI
- Rename r -> regs, p -> priv
- Add reviewed-by
- Update binding doc (drop unused bindig)
- Rename DM_SPMI -> SPMI
- Rename p -> priv (in write/read)
- Fix header ordering (again)
- Add reviewed-by
- Add reviewed-by
- Reordered Kconfig & Makefile (to keep alphabetical ordering)
- Added link to dt binding @ help
- Add Reviewed-by
- Rename DM_SPMI -> SPMI
- Make MND divider comments more compact :)
- p -> priv
- Add reviewed-by
- Reordered Kconfig to keep alphabetical order
- Renamed reset_sandbox -> msm_reset (typo in reset.c)
- Renamed CONFIG_DM_SPMI -> CONFIG_SPMI
- Removed extra enter in dragonboard file
- Added ULPI* to defconfig
- Added MAINTAINERS to board
- Cleaned up config file - use distro defaults/environment:
- Dropped multiple CONFIG_CMD* and other CONFIG_*
- Added distro env/config
- Dropped old boot commands
- Split dts - pm8916_gpio entries are taken directly from
Linux Dragonboard dts; Add handles for u-boot in -uboot.dtsi; They will be removed once gpio drivers are converted to pinctrl.
- Renamed some pmic nodes, fixed dragonboard.c to find them properly.
- Added header and converted comments to c98-style in head.S
- Print error if pmic gpio node is not found.
- New patch

Changes in v1:
- Added (better) help to KConfig
- Added dt binding documentation
- Fixed include ordering
- Reworked msm_serial_getc
- Added error handling to msm_uart_clk_init (that is ignored later for now)
- Dropped unneeded DM_FLAG_PRE_RELOC
- Added dt binding documentation
- Added help to KConfig
- Use clrsetbits() to switch direction
- Fixed include order
- Added #defines for registers/register fields
- Added secondary compatible string
- Added commit message
- Added DT binding documentation
- Added Kconfig help
- Reordered includes
- Dropped redundant fields from msm_sdhc
- Cleaned up clock init code (+ added error handling)
- Dropped mdelay - use wait_for_bit instead in reset code
- Added missing newline after declarations
- Added error handling if "reg" is missing
- Converted base address to pointer
- No changes, just added Acked-by, Reviewed-by
- Reordered header files
- Removed braces around constant
- Added more verbose help to KConfig
- Added ULPI dependency to Kconfig
- Drop register #defines - use ehci-ci.h instead
- Create fixed ulpi viewport for device
- Use setbits/clearbits where possible
- Use wait_for_bit to reset controller
- Add dt binding documents
- Reorder includes
- Add read/write arguments documentation
- add binding documentation and better Kconfig help
- Changed a bit mapping
- Change include order
- Use clrsetbits* where possible
- Add one more supported dts id
- Handle missing fields in dt properly
- Added dt bindings
- Reoder includes
- Replaced extract_* macros with ordinary shift/mask
- Added error checking and whitespaces in probe
- Add binding doc
- Fixed inlcude ordering
- Merged direction_input and direction_output functions
- gpio_get: use switch instead of stacked if
- use pmic_clrsetbits
- add possibility to change prwkey bank name
- Handle invalid bindings
- Sanity HW check (i.e. check type/subtype registers)
- Fix include order
- Cleanup defines (added spaces for readibility)
- Base address is integer to avoid casting
- Use setbits_* family where possible
- Drop unneded comments, added newlines where needed
- Check return value of dev_get_addr
- Add binding for apq8016
- Cleaned up divider calculation
- Drop most of gpio.h (only empty file is needed)
- Add better help for dragonboard
- Move static structures to board_prepare_usb
- Add DM_SPMI to defconfig

Mateusz Kulikowski (18):
serial: Add support for Qualcomm serial port
gpio: Add support for Qualcomm gpio controller
mmc: Add support for Qualcomm SDHCI controller
ehci-hcd: Add init_after_reset
usb: ulpi: Add Kconfig options for ULPI Migrate CONFIG_ULPI* to Kconfig
usb: Rename ehci-fsl.h to ehci-ci.h
usb: ehci-ci: Add missing registers. ehci-ci.h: drop generic USBCMD fields
ehci: Add support for Qualcomm EHCI
drivers: Add SPMI bus uclass
spmi: Add sandbox test driver
drivers: spmi: Add support for Qualcomm SPMI bus driver
pmic: Add support for Qualcomm PM8916 PMIC
gpio: Add support for Qualcomm PM8916 gpios
arm: Add support for Qualcomm Snapdragon family
board: Add Qualcomm Dragonboard 410C support Add myself as Snapdragon and SPMI maintainer

 MAINTAINERS                                        |  11 +
 arch/arm/Kconfig                                   |  12 +
 arch/arm/Makefile                                  |   1 +
 arch/arm/dts/Makefile                              |   2 +
 arch/arm/dts/dragonboard410c-uboot.dtsi            |  28 ++
 arch/arm/dts/dragonboard410c.dts                   | 148 ++++++++++
 arch/arm/mach-snapdragon/Kconfig                   |  26 ++
 arch/arm/mach-snapdragon/Makefile                  |   8 +
 arch/arm/mach-snapdragon/clock-apq8016.c           | 262 ++++++++++++++++++
 arch/arm/mach-snapdragon/include/mach/gpio.h       |   9 +
 .../mach-snapdragon/include/mach/sysmap-apq8016.h  |  14 +
 arch/arm/mach-snapdragon/reset.c                   |  40 +++
 arch/sandbox/dts/sandbox.dts                       |  20 ++
 arch/sandbox/dts/test.dts                          |  20 ++
 board/qualcomm/dragonboard410c/Kconfig             |  15 +
 board/qualcomm/dragonboard410c/MAINTAINERS         |   6 +
 board/qualcomm/dragonboard410c/Makefile            |   8 +
 board/qualcomm/dragonboard410c/dragonboard410c.c   | 131 +++++++++
 board/qualcomm/dragonboard410c/head.S              |  28 ++
 board/qualcomm/dragonboard410c/readme.txt          |  43 +++
 board/qualcomm/dragonboard410c/u-boot.lds          |  90 ++++++
 configs/colibri_t20_defconfig                      |   2 +
 configs/dragonboard410c_defconfig                  |  31 +++
 configs/harmony_defconfig                          |   2 +
 configs/mcx_defconfig                              |   3 +
 configs/mt_ventoux_defconfig                       |   3 +
 configs/sandbox_defconfig                          |   4 +
 configs/twister_defconfig                          |   3 +
 configs/zynq_picozed_defconfig                     |   3 +
 configs/zynq_zc702_defconfig                       |   3 +
 configs/zynq_zc706_defconfig                       |   3 +
 configs/zynq_zed_defconfig                         |   3 +
 configs/zynq_zybo_defconfig                        |   3 +
 doc/device-tree-bindings/gpio/gpio-msm.txt         |  22 ++
 doc/device-tree-bindings/gpio/pm8916_gpio.txt      |  48 ++++
 doc/device-tree-bindings/mmc/msm_sdhci.txt         |  25 ++
 doc/device-tree-bindings/pmic/pm8916.txt           |  18 ++
 doc/device-tree-bindings/serial/msm-serial.txt     |   6 +
 doc/device-tree-bindings/spmi/spmi-msm.txt         |  26 ++
 doc/device-tree-bindings/spmi/spmi-sandbox.txt     |  31 +++
 doc/device-tree-bindings/usb/ehci-msm.txt          |  10 +
 doc/git-mailrc                                     |   3 +
 drivers/Kconfig                                    |   2 +
 drivers/Makefile                                   |   1 +
 drivers/gpio/Kconfig                               |  24 ++
 drivers/gpio/Makefile                              |   2 +
 drivers/gpio/msm_gpio.c                            | 135 +++++++++
 drivers/gpio/pm8916_gpio.c                         | 302 +++++++++++++++++++++
 drivers/mmc/Kconfig                                |   9 +
 drivers/mmc/Makefile                               |   1 +
 drivers/mmc/msm_sdhci.c                            | 180 ++++++++++++
 drivers/power/pmic/Kconfig                         |  16 ++
 drivers/power/pmic/Makefile                        |   1 +
 drivers/power/pmic/pm8916.c                        |  96 +++++++
 drivers/serial/Kconfig                             |   8 +
 drivers/serial/Makefile                            |   1 +
 drivers/serial/serial_msm.c                        | 212 +++++++++++++++
 drivers/spmi/Kconfig                               |  23 ++
 drivers/spmi/Makefile                              |   9 +
 drivers/spmi/spmi-msm.c                            | 189 +++++++++++++
 drivers/spmi/spmi-sandbox.c                        | 157 +++++++++++
 drivers/spmi/spmi-uclass.c                         |  48 ++++
 drivers/usb/Kconfig                                |   2 +
 drivers/usb/host/Kconfig                           |  11 +
 drivers/usb/host/Makefile                          |   1 +
 drivers/usb/host/ehci-fsl.c                        |   2 +-
 drivers/usb/host/ehci-hcd.c                        |   6 +
 drivers/usb/host/ehci-mpc512x.c                    |   6 +-
 drivers/usb/host/ehci-msm.c                        | 178 ++++++++++++
 drivers/usb/host/ehci-mx5.c                        |   2 +-
 drivers/usb/host/ehci-mx6.c                        |   2 +-
 drivers/usb/host/ehci-mxc.c                        |   2 +-
 drivers/usb/host/ehci-vf.c                         |   2 +-
 drivers/usb/host/ehci-zynq.c                       |   2 +-
 drivers/usb/host/ehci.h                            |   1 +
 drivers/usb/ulpi/Kconfig                           |  33 +++
 include/configs/colibri_t20.h                      |   2 -
 include/configs/dragonboard410c.h                  | 153 +++++++++++
 include/configs/harmony.h                          |   2 -
 include/configs/mcx.h                              |   2 -
 include/configs/tam3517-common.h                   |   2 -
 include/configs/zynq-common.h                      |   2 -
 include/dm/uclass-id.h                             |   1 +
 include/spmi/spmi.h                                |  47 ++++
 include/usb/{ehci-fsl.h => ehci-ci.h}              |  16 +-
 test/dm/Makefile                                   |   1 +
 test/dm/spmi.c                                     | 115 ++++++++
 87 files changed, 3156 insertions(+), 27 deletions(-)
 create mode 100644 arch/arm/dts/dragonboard410c-uboot.dtsi
 create mode 100644 arch/arm/dts/dragonboard410c.dts
 create mode 100644 arch/arm/mach-snapdragon/Kconfig
 create mode 100644 arch/arm/mach-snapdragon/Makefile
 create mode 100644 arch/arm/mach-snapdragon/clock-apq8016.c
 create mode 100644 arch/arm/mach-snapdragon/include/mach/gpio.h
 create mode 100644 arch/arm/mach-snapdragon/include/mach/sysmap-apq8016.h
 create mode 100644 arch/arm/mach-snapdragon/reset.c
 create mode 100644 board/qualcomm/dragonboard410c/Kconfig
 create mode 100644 board/qualcomm/dragonboard410c/MAINTAINERS
 create mode 100644 board/qualcomm/dragonboard410c/Makefile
 create mode 100644 board/qualcomm/dragonboard410c/dragonboard410c.c
 create mode 100644 board/qualcomm/dragonboard410c/head.S
 create mode 100644 board/qualcomm/dragonboard410c/readme.txt
 create mode 100644 board/qualcomm/dragonboard410c/u-boot.lds
 create mode 100644 configs/dragonboard410c_defconfig
 create mode 100644 doc/device-tree-bindings/gpio/gpio-msm.txt
 create mode 100644 doc/device-tree-bindings/gpio/pm8916_gpio.txt
 create mode 100644 doc/device-tree-bindings/mmc/msm_sdhci.txt
 create mode 100644 doc/device-tree-bindings/pmic/pm8916.txt
 create mode 100644 doc/device-tree-bindings/serial/msm-serial.txt
 create mode 100644 doc/device-tree-bindings/spmi/spmi-msm.txt
 create mode 100644 doc/device-tree-bindings/spmi/spmi-sandbox.txt
 create mode 100644 doc/device-tree-bindings/usb/ehci-msm.txt
 create mode 100644 drivers/gpio/msm_gpio.c
 create mode 100644 drivers/gpio/pm8916_gpio.c
 create mode 100644 drivers/mmc/msm_sdhci.c
 create mode 100644 drivers/power/pmic/pm8916.c
 create mode 100644 drivers/serial/serial_msm.c
 create mode 100644 drivers/spmi/Kconfig
 create mode 100644 drivers/spmi/Makefile
 create mode 100644 drivers/spmi/spmi-msm.c
 create mode 100644 drivers/spmi/spmi-sandbox.c
 create mode 100644 drivers/spmi/spmi-uclass.c
 create mode 100644 drivers/usb/host/ehci-msm.c
 create mode 100644 drivers/usb/ulpi/Kconfig
 create mode 100644 include/configs/dragonboard410c.h
 create mode 100644 include/spmi/spmi.h
 rename include/usb/{ehci-fsl.h => ehci-ci.h} (96%)
 create mode 100644 test/dm/spmi.c
Signature · 1 line
2.5.0
#1 lore raw

PATCH v2 1/18 serial: Add support for Qualcomm serial port

This driver works in "new" Data Mover UART mode, so will be compatible with modern Qualcomm chips only.

---

Changes in v3: None
Changes in v2:
- Added newline before return... (globally)
- Renamed p to priv (priv data) - it required some rewrapping
- Added Reviewed-by

Changes in v1:
- Added (better) help to KConfig
- Added dt binding documentation
- Fixed include ordering
- Reworked msm_serial_getc
- Added error handling to msm_uart_clk_init (that is ignored later for now)
- Dropped unneeded DM_FLAG_PRE_RELOC

 doc/device-tree-bindings/serial/msm-serial.txt |   6 +
 drivers/serial/Kconfig                         |   8 +
 drivers/serial/Makefile                        |   1 +
 drivers/serial/serial_msm.c                    | 212 +++++++++++++++++++++++++
 4 files changed, 227 insertions(+)
 create mode 100644 doc/device-tree-bindings/serial/msm-serial.txt
 create mode 100644 drivers/serial/serial_msm.c
doc/device-tree-bindings/serial/msm-serial.txt new file +6 -0
new file mode 100644
index 0000000..48b8428
@@ -0,0 +1,6 @@
+Qualcomm UART (Data Mover mode)
+
+Required properties:
+- compatible: must be "qcom,msm-uartdm-v1.4"
+- reg: start address and size of the registers
+- clock: interface clock (must accept baudrate as a frequency)
drivers/serial/Kconfig +8 -0
index fac3176..14c0d0c 100644
@@ -300,4 +300,12 @@ config XILINX_UARTLITE
 	  If you have a Xilinx based board and want to use the uartlite
 	  serial ports, say Y to this option. If unsure, say N.
 
+config MSM_SERIAL
+	bool "Qualcomm on-chip UART"
+	depends on DM_SERIAL
+	help
+	  Support Data Mover UART used on Qualcomm Snapdragon SoCs.
+	  It should support all Qualcomm devices with UARTDM version 1.4,
+	  for example APQ8016 and MSM8916.
+	  Single baudrate is supported in current implementation (115200).
 endmenu
drivers/serial/Makefile +1 -0
index 57cd38b..d5d2ec9 100644
@@ -42,6 +42,7 @@ obj-$(CONFIG_ARC_SERIAL) += serial_arc.o
 obj-$(CONFIG_UNIPHIER_SERIAL) += serial_uniphier.o
 obj-$(CONFIG_STM32_SERIAL) += serial_stm32.o
 obj-$(CONFIG_PIC32_SERIAL) += serial_pic32.o
+obj-$(CONFIG_MSM_SERIAL) += serial_msm.o
 
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_USB_TTY) += usbtty.o
drivers/serial/serial_msm.c new file +212 -0

212 lines not on this page · raw message

Signature · 1 line
2.5.0
#2 lore raw

PATCH v2 2/18 gpio: Add support for Qualcomm gpio controller

In reply to Mateusz Kulikowski

Add support for gpio controllers on Qualcomm Snapdragon devices. This devices are usually called Top Level Mode Multiplexing in Qualcomm documentation.

---

Changes in v3: None
Changes in v2:
- Reordered includes (again)
- Added newlines between returns
- Fixed error handling in msm_gpio_probe
- Added reviewed-by

Changes in v1:
- Added dt binding documentation
- Added help to KConfig
- Use clrsetbits() to switch direction
- Fixed include order
- Added #defines for registers/register fields
- Added secondary compatible string

 doc/device-tree-bindings/gpio/gpio-msm.txt |  22 +++++
 drivers/gpio/Kconfig                       |  14 +++
 drivers/gpio/Makefile                      |   1 +
 drivers/gpio/msm_gpio.c                    | 135 +++++++++++++++++++++++++++++
 4 files changed, 172 insertions(+)
 create mode 100644 doc/device-tree-bindings/gpio/gpio-msm.txt
 create mode 100644 drivers/gpio/msm_gpio.c
doc/device-tree-bindings/gpio/gpio-msm.txt new file +22 -0
new file mode 100644
index 0000000..966ce0a
@@ -0,0 +1,22 @@
+Qualcomm Snapdragon GPIO controller
+
+Required properties:
+- compatible : "qcom,msm8916-pinctrl" or "qcom,apq8016-pinctrl"
+- reg : Physical base address and length of the controller's registers.
+	This controller is called "Top Level Mode Multiplexing" in
+	Qualcomm documentation.
+- #gpio-cells : Should be one (pin number).
+- gpio-controller : Marks the device node as a GPIO controller.
+- gpio-count: Number of GPIO pins.
+- gpio-bank-name: (optional) name of gpio bank. As default "soc" is used.
+
+Example:
+
+soc_gpios: pinctrl at 1000000 {
+	compatible = "qcom,msm8916-pinctrl";
+	reg = <0x1000000 0x300000>;
+	gpio-controller;
+	gpio-count = <122>;
+	gpio-bank-name="soc";
+	#gpio-cells = <1>;
+};
drivers/gpio/Kconfig +14 -0
index 845dc72..a5e8182 100644
@@ -46,6 +46,20 @@ config LPC32XX_GPIO
 	help
 	  Support for the LPC32XX GPIO driver.
 
+config MSM_GPIO
+	bool "Qualcomm GPIO driver"
+	depends on DM_GPIO
+	default n
+	help
+	  Support GPIO controllers on Qualcomm Snapdragon family of SoCs.
+	  This controller have single bank (default name "soc"), every
+	  gpio has it's own set of registers.
+	  Only simple GPIO operations are supported (get/set, change of
+	  direction and checking pin function).
+	  Supported devices:
+	  - APQ8016
+	  - MSM8916
+
 config ROCKCHIP_GPIO
 	bool "Rockchip GPIO driver"
 	depends on DM_GPIO
drivers/gpio/Makefile +1 -0
index 845a6d4..6083c4a 100644
@@ -47,3 +47,4 @@ obj-$(CONFIG_ZYNQ_GPIO)		+= zynq_gpio.o
 obj-$(CONFIG_VYBRID_GPIO)	+= vybrid_gpio.o
 obj-$(CONFIG_HIKEY_GPIO)	+= hi6220_gpio.o
 obj-$(CONFIG_PIC32_GPIO)	+= pic32_gpio.o
+obj-$(CONFIG_MSM_GPIO)		+= msm_gpio.o
drivers/gpio/msm_gpio.c new file +135 -0

135 lines not on this page · raw message

Signature · 1 line
2.5.0
#3 lore raw

PATCH v2 2/18 gpio: Add support for Qualcomm gpio controller

Quoted 44 lines · Mateusz Kulikowski

Add support for gpio controllers on Qualcomm Snapdragon devices. This devices are usually called Top Level Mode Multiplexing in Qualcomm documentation.

---

Changes in v3: None
Changes in v2:
- Reordered includes (again)
- Added newlines between returns
- Fixed error handling in msm_gpio_probe
- Added reviewed-by

Changes in v1:
- Added dt binding documentation
- Added help to KConfig
- Use clrsetbits() to switch direction
- Fixed include order
- Added #defines for registers/register fields
- Added secondary compatible string

 doc/device-tree-bindings/gpio/gpio-msm.txt |  22 +++++
 drivers/gpio/Kconfig                       |  14 +++
 drivers/gpio/Makefile                      |   1 +
 drivers/gpio/msm_gpio.c                    | 135 +++++++++++++++++++++++++++++
 4 files changed, 172 insertions(+)
 create mode 100644 doc/device-tree-bindings/gpio/gpio-msm.txt
 create mode 100644 drivers/gpio/msm_gpio.c
doc/device-tree-bindings/gpio/gpio-msm.txt new file +6 -0
new file mode 100644
index 0000000..966ce0a
@@ -0,0 +1,22 @@
+Qualcomm Snapdragon GPIO controller
+
+Required properties:
+- compatible : "qcom,msm8916-pinctrl" or "qcom,apq8016-pinctrl"
+- reg : Physical base address and length of the controller's registers.
+       This controller is called "Top Level Mode Multiplexing" in

doc/device-tree-bindings/gpio/gpio-msm.txt line 16

Quoted 10 lines
doc/device-tree-bindings/gpio/gpio-msm.txt new file +10 -0
+       Qualcomm documentation.
+- #gpio-cells : Should be one (pin number).
+- gpio-controller : Marks the device node as a GPIO controller.
+- gpio-count: Number of GPIO pins.
+- gpio-bank-name: (optional) name of gpio bank. As default "soc" is used.
+
+Example:
+
+soc_gpios: pinctrl at 1000000 {
+       compatible = "qcom,msm8916-pinctrl";

Can't this driver goes into pinctrl (I mean gpio handling pincontrol), because Linux handle these gpio msm8916-pinctrl through pinctrl subsystem as per as I know, let me know in case if I miss anything here.

Quoted 188 lines
doc/device-tree-bindings/gpio/gpio-msm.txt new file +6 -0
+       reg = <0x1000000 0x300000>;
+       gpio-controller;
+       gpio-count = <122>;
+       gpio-bank-name="soc";
+       #gpio-cells = <1>;
+};
drivers/gpio/Kconfig +14 -0
index 845dc72..a5e8182 100644
@@ -46,6 +46,20 @@ config LPC32XX_GPIO
        help
          Support for the LPC32XX GPIO driver.
 
+config MSM_GPIO
+       bool "Qualcomm GPIO driver"
+       depends on DM_GPIO
+       default n
+       help
+         Support GPIO controllers on Qualcomm Snapdragon family of SoCs.
+         This controller have single bank (default name "soc"), every
+         gpio has it's own set of registers.
+         Only simple GPIO operations are supported (get/set, change of
+         direction and checking pin function).
+         Supported devices:
+         - APQ8016
+         - MSM8916
+
 config ROCKCHIP_GPIO
        bool "Rockchip GPIO driver"
        depends on DM_GPIO
drivers/gpio/Makefile +1 -0
index 845a6d4..6083c4a 100644
@@ -47,3 +47,4 @@ obj-$(CONFIG_ZYNQ_GPIO)               += zynq_gpio.o
 obj-$(CONFIG_VYBRID_GPIO)      += vybrid_gpio.o
 obj-$(CONFIG_HIKEY_GPIO)       += hi6220_gpio.o
 obj-$(CONFIG_PIC32_GPIO)       += pic32_gpio.o
+obj-$(CONFIG_MSM_GPIO)         += msm_gpio.o
drivers/gpio/msm_gpio.c new file +135 -1
new file mode 100644
index 0000000..950f309
@@ -0,0 +1,135 @@
+/*
+ * Qualcomm GPIO driver
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/gpio.h>
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* Register offsets */
+#define GPIO_CONFIG_OFF(no)         ((no) * 0x1000)
+#define GPIO_IN_OUT_OFF(no)         ((no) * 0x1000 + 0x4)
+
+/* OE */
+#define GPIO_OE_DISABLE  (0x0 << 9)
+#define GPIO_OE_ENABLE   (0x1 << 9)
+#define GPIO_OE_MASK     (0x1 << 9)
+
+/* GPIO_IN_OUT register shifts. */
+#define GPIO_IN          0
+#define GPIO_OUT         1
+
+struct msm_gpio_bank {
+       phys_addr_t base;
+};
+
+static int msm_gpio_direction_input(struct udevice *dev, unsigned int gpio)
+{
+       struct msm_gpio_bank *priv = dev_get_priv(dev);
+       phys_addr_t reg = priv->base + GPIO_CONFIG_OFF(gpio);
+
+       /* Disable OE bit */
+       clrsetbits_le32(reg, GPIO_OE_MASK, GPIO_OE_DISABLE);
+
+       return 0;
+}
+
+static int msm_gpio_set_value(struct udevice *dev, unsigned gpio, int value)
+{
+       struct msm_gpio_bank *priv = dev_get_priv(dev);
+
+       value = !!value;
+       /* set value */
+       writel(value << GPIO_OUT, priv->base + GPIO_IN_OUT_OFF(gpio));
+
+       return 0;
+}
+
+static int msm_gpio_direction_output(struct udevice *dev, unsigned gpio,
+                                    int value)
+{
+       struct msm_gpio_bank *priv = dev_get_priv(dev);
+       phys_addr_t reg = priv->base + GPIO_CONFIG_OFF(gpio);
+
+       value = !!value;
+       /* set value */
+       writel(value << GPIO_OUT, priv->base + GPIO_IN_OUT_OFF(gpio));
+       /* switch direction */
+       clrsetbits_le32(reg, GPIO_OE_MASK, GPIO_OE_ENABLE);
+
+       return 0;
+}
+
+static int msm_gpio_get_value(struct udevice *dev, unsigned gpio)
+{
+       struct msm_gpio_bank *priv = dev_get_priv(dev);
+
+       return !!(readl(priv->base + GPIO_IN_OUT_OFF(gpio)) >> GPIO_IN);
+}
+
+static int msm_gpio_get_function(struct udevice *dev, unsigned offset)
+{
+       struct msm_gpio_bank *priv = dev_get_priv(dev);
+
+       if (readl(priv->base + GPIO_CONFIG_OFF(offset)) & GPIO_OE_ENABLE)
+               return GPIOF_OUTPUT;
+
+       return GPIOF_INPUT;
+}
+
+static const struct dm_gpio_ops gpio_msm_ops = {
+       .direction_input        = msm_gpio_direction_input,
+       .direction_output       = msm_gpio_direction_output,
+       .get_value              = msm_gpio_get_value,
+       .set_value              = msm_gpio_set_value,
+       .get_function           = msm_gpio_get_function,
+};
+
+static int msm_gpio_probe(struct udevice *dev)
+{
+       struct msm_gpio_bank *priv = dev_get_priv(dev);
+
+       priv->base = dev_get_addr(dev);
+
+       return priv->base == FDT_ADDR_T_NONE ? -EINVAL : 0;
+}
+
+static int msm_gpio_ofdata_to_platdata(struct udevice *dev)
+{
+       struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
+
+       uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+                                            "gpio-count", 0);
+       uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
+                                        "gpio-bank-name", NULL);
+       if (uc_priv->bank_name == NULL)
+               uc_priv->bank_name = "soc";
+
+       return 0;
+}
+
+static const struct udevice_id msm_gpio_ids[] = {
+       { .compatible = "qcom,msm8916-pinctrl" },
+       { .compatible = "qcom,apq8016-pinctrl" },
+       { }
+};
+
+U_BOOT_DRIVER(gpio_msm) = {
+       .name   = "gpio_msm",
+       .id     = UCLASS_GPIO,
+       .of_match = msm_gpio_ids,
+       .ofdata_to_platdata = msm_gpio_ofdata_to_platdata,
+       .probe  = msm_gpio_probe,
+       .ops    = &gpio_msm_ops,
+       .priv_auto_alloc_size = sizeof(struct msm_gpio_bank),
+};
+
+
--

2.5.0

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

Signature · 1 line
Jagan.
#4 lore raw

PATCH v2 2/18 gpio: Add support for Qualcomm gpio controller

Hi,

Quoted 53 lines · Jagan Teki
Quoted 51 lines · Mateusz Kulikowski

Add support for gpio controllers on Qualcomm Snapdragon devices. This devices are usually called Top Level Mode Multiplexing in Qualcomm documentation.

---

Changes in v3: None
Changes in v2:
- Reordered includes (again)
- Added newlines between returns
- Fixed error handling in msm_gpio_probe
- Added reviewed-by

Changes in v1:
- Added dt binding documentation
- Added help to KConfig
- Use clrsetbits() to switch direction
- Fixed include order
- Added #defines for registers/register fields
- Added secondary compatible string

 doc/device-tree-bindings/gpio/gpio-msm.txt |  22 +++++
 drivers/gpio/Kconfig                       |  14 +++
 drivers/gpio/Makefile                      |   1 +
 drivers/gpio/msm_gpio.c                    | 135 +++++++++++++++++++++++++++++
 4 files changed, 172 insertions(+)
 create mode 100644 doc/device-tree-bindings/gpio/gpio-msm.txt
 create mode 100644 drivers/gpio/msm_gpio.c
doc/device-tree-bindings/gpio/gpio-msm.txt new file +13 -0
new file mode 100644
index 0000000..966ce0a
@@ -0,0 +1,22 @@
+Qualcomm Snapdragon GPIO controller
+
+Required properties:
+- compatible : "qcom,msm8916-pinctrl" or "qcom,apq8016-pinctrl"
+- reg : Physical base address and length of the controller's registers.
+       This controller is called "Top Level Mode Multiplexing" in
+       Qualcomm documentation.
+- #gpio-cells : Should be one (pin number).
+- gpio-controller : Marks the device node as a GPIO controller.
+- gpio-count: Number of GPIO pins.
+- gpio-bank-name: (optional) name of gpio bank. As default "soc" is used.
+
+Example:
Quoted 8 lines

doc/device-tree-bindings/gpio/gpio-msm.txt line 16

Quoted 3 lines
doc/device-tree-bindings/gpio/gpio-msm.txt new file +3 -0
+
+soc_gpios: pinctrl at 1000000 {
+       compatible = "qcom,msm8916-pinctrl";

Can't this driver goes into pinctrl (I mean gpio handling pincontrol), because Linux handle these gpio msm8916-pinctrl through pinctrl subsystem as per as I know, let me know in case if I miss anything here.

I think Mateusz is planning to add this later. It would be good to get this in as a starting point for this platform.

Regards,
Simon

#5 lore raw

PATCH v2 2/18 gpio: Add support for Qualcomm gpio controller

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi All,

Sorry for long delay :)

Quoted 5 lines · Simon Glass

Hi,

Quoted 2 lines · Jagan Teki

On 8 February 2016 at 02:27, Mateusz Kulikowski
<[email protected]> wrote:

[...]

Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
doc/device-tree-bindings/gpio/gpio-msm.txt new file +12 -0
+
+Required properties:
+- compatible : "qcom,msm8916-pinctrl" or "qcom,apq8016-pinctrl"
+- reg : Physical base address and length of the controller's registers.
+       This controller is called "Top Level Mode Multiplexing" in
+       Qualcomm documentation.
+- #gpio-cells : Should be one (pin number).
+- gpio-controller : Marks the device node as a GPIO controller.
+- gpio-count: Number of GPIO pins.
+- gpio-bank-name: (optional) name of gpio bank. As default "soc" is used.
+
+Example:
Quoted 8 lines

doc/device-tree-bindings/gpio/gpio-msm.txt line 16

Quoted 3 lines
doc/device-tree-bindings/gpio/gpio-msm.txt new file +3 -0
+
+soc_gpios: pinctrl at 1000000 {
+       compatible = "qcom,msm8916-pinctrl";

Can't this driver goes into pinctrl (I mean gpio handling pincontrol), because Linux handle these gpio msm8916-pinctrl through pinctrl subsystem as per as I know, let me know in case if I miss anything here.

Quoted 2 lines

I think Mateusz is planning to add this later. It would be good to get this in as a starting point for this platform.

It was exactly my plan. Is it OK with you Jagan?

Regards,
Mateusz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJWxxmqAAoJELvtohmVtQzBGZ0H/jK2ePYiO0MtTVRyCYEqRxSd 24uomfbFjkTnI2a3ZexLYLCgNfWnhrzMgGk9BQ2nKY7NfWaIAgEGO4oDHhZzIijp 8w0LR4QS4VGWj96ylWBbygLCqCg4AfbXNlfDtEbKvQAl+3TwW40DDVKuJe2dq2mZ j0S3+za3CustCP7mkN3hYQ0ujQidA+LXeUYYKegvNPWA4sl6clZpUX8bTXXzWU6S Erbcl33zm4m5FwgGnTIwPFSjIAWsetwFg65CBG3kqKlzazCeFnIxmvPP4EwLayHF mYIKfvL4PWMYNRunIUHvYAsOnRc7exSUTksmcqbdUFqU8fi0RzwKDIG0qiKAlVY= =JKsS
-----END PGP SIGNATURE-----

#6 lore raw

PATCH v2 3/18 mmc: Add support for Qualcomm SDHCI controller

In reply to Mateusz Kulikowski

Add support for SD/eMMC controller present on some Qualcomm Snapdragon devices. This controller implements SDHCI 2.0 interface but requires vendor-specific initialization.
Driver works in PIO mode as ADMA is not supported by U-Boot (yet).

---

Changes in v3: None
Changes in v2:
- Add reviewed-by

Changes in v1:
- Added commit message
- Added DT binding documentation
- Added Kconfig help
- Reordered includes
- Dropped redundant fields from msm_sdhc
- Cleaned up clock init code (+ added error handling)
- Dropped mdelay - use wait_for_bit instead in reset code
- Added missing newline after declarations
- Added error handling if "reg" is missing
- Converted base address to pointer

 doc/device-tree-bindings/mmc/msm_sdhci.txt |  25 ++++
 drivers/mmc/Kconfig                        |   9 ++
 drivers/mmc/Makefile                       |   1 +
 drivers/mmc/msm_sdhci.c                    | 180 +++++++++++++++++++++++++++++
 4 files changed, 215 insertions(+)
 create mode 100644 doc/device-tree-bindings/mmc/msm_sdhci.txt
 create mode 100644 drivers/mmc/msm_sdhci.c
doc/device-tree-bindings/mmc/msm_sdhci.txt new file +25 -0
new file mode 100644
index 0000000..08a290c
@@ -0,0 +1,25 @@
+Qualcomm Snapdragon SDHCI controller
+
+Required properties:
+- compatible : "qcom,sdhci-msm-v4"
+- reg: Base address and length of registers:
+	- Host controller registers (SDHCI)
+	- SD Core registers
+- clock: interface clock (must accept SD bus clock as a frequency)
+
+Optional properties:
+- index: If there is more than one controller - controller index (required
+	by generic SDHCI code).
+- bus_width: Width of SD/eMMC bus (default 4)
+- clock-frequency: Frequency of SD/eMMC bus (default 400 kHz)
+
+Example:
+
+sdhci at 07864000 {
+	compatible = "qcom,sdhci-msm-v4";
+	reg = <0x7864900 0x11c 0x7864000 0x800>;
+	index = <0x1>;
+	bus-width = <0x4>;
+	clock = <&clkc 1>;
+	clock-frequency = <200000000>;
+};
drivers/mmc/Kconfig +9 -0
index 9f4b766..e178935 100644
@@ -16,6 +16,15 @@ config DM_MMC
 	  appear as block devices in U-Boot and can support filesystems such
 	  as EXT4 and FAT.
 
+config MSM_SDHCI
+	bool "Qualcomm SDHCI controller"
+	depends on DM_MMC
+	help
+	  Enables support for SDHCI 2.0 controller present on some Qualcomm
+          Snapdragon devices. This device is compatible with eMMC v4.5 and
+          SD 3.0 specifications. Both SD and eMMC devices are supported.
+	  Card-detect gpios are not supported.
+
 config ROCKCHIP_DWMMC
 	bool "Rockchip SD/MMC controller support"
 	depends on DM_MMC && OF_CONTROL
drivers/mmc/Makefile +1 -0
index c9c3e3e..3df92f6 100644
@@ -49,3 +49,4 @@ else
 obj-$(CONFIG_GENERIC_MMC) += mmc_write.o
 endif
 obj-$(CONFIG_PIC32_SDHCI) += pic32_sdhci.o
+obj-$(CONFIG_MSM_SDHCI) += msm_sdhci.o
drivers/mmc/msm_sdhci.c new file +180 -0

180 lines not on this page · raw message

Signature · 1 line
2.5.0
#7 lore raw

PATCH v2 3/18 mmc: Add support for Qualcomm SDHCI controller

Quoted 127 lines · Mateusz Kulikowski

Add support for SD/eMMC controller present on some Qualcomm Snapdragon devices. This controller implements SDHCI 2.0 interface but requires vendor-specific initialization.
Driver works in PIO mode as ADMA is not supported by U-Boot (yet).

---

Changes in v3: None
Changes in v2:
- Add reviewed-by

Changes in v1:
- Added commit message
- Added DT binding documentation
- Added Kconfig help
- Reordered includes
- Dropped redundant fields from msm_sdhc
- Cleaned up clock init code (+ added error handling)
- Dropped mdelay - use wait_for_bit instead in reset code
- Added missing newline after declarations
- Added error handling if "reg" is missing
- Converted base address to pointer

 doc/device-tree-bindings/mmc/msm_sdhci.txt |  25 ++++
 drivers/mmc/Kconfig                        |   9 ++
 drivers/mmc/Makefile                       |   1 +
 drivers/mmc/msm_sdhci.c                    | 180 +++++++++++++++++++++++++++++
 4 files changed, 215 insertions(+)
 create mode 100644 doc/device-tree-bindings/mmc/msm_sdhci.txt
 create mode 100644 drivers/mmc/msm_sdhci.c
doc/device-tree-bindings/mmc/msm_sdhci.txt new file +25 -0
new file mode 100644
index 0000000..08a290c
@@ -0,0 +1,25 @@
+Qualcomm Snapdragon SDHCI controller
+
+Required properties:
+- compatible : "qcom,sdhci-msm-v4"
+- reg: Base address and length of registers:
+       - Host controller registers (SDHCI)
+       - SD Core registers
+- clock: interface clock (must accept SD bus clock as a frequency)
+
+Optional properties:
+- index: If there is more than one controller - controller index (required
+       by generic SDHCI code).
+- bus_width: Width of SD/eMMC bus (default 4)
+- clock-frequency: Frequency of SD/eMMC bus (default 400 kHz)
+
+Example:
+
+sdhci at 07864000 {
+       compatible = "qcom,sdhci-msm-v4";
+       reg = <0x7864900 0x11c 0x7864000 0x800>;
+       index = <0x1>;
+       bus-width = <0x4>;
+       clock = <&clkc 1>;
+       clock-frequency = <200000000>;
+};
drivers/mmc/Kconfig +9 -0
index 9f4b766..e178935 100644
@@ -16,6 +16,15 @@ config DM_MMC
          appear as block devices in U-Boot and can support filesystems such
          as EXT4 and FAT.
 
+config MSM_SDHCI
+       bool "Qualcomm SDHCI controller"
+       depends on DM_MMC
+       help
+         Enables support for SDHCI 2.0 controller present on some Qualcomm
+          Snapdragon devices. This device is compatible with eMMC v4.5 and
+          SD 3.0 specifications. Both SD and eMMC devices are supported.
+         Card-detect gpios are not supported.
+
 config ROCKCHIP_DWMMC
        bool "Rockchip SD/MMC controller support"
        depends on DM_MMC && OF_CONTROL
drivers/mmc/Makefile +1 -0
index c9c3e3e..3df92f6 100644
@@ -49,3 +49,4 @@ else
 obj-$(CONFIG_GENERIC_MMC) += mmc_write.o
 endif
 obj-$(CONFIG_PIC32_SDHCI) += pic32_sdhci.o
+obj-$(CONFIG_MSM_SDHCI) += msm_sdhci.o
drivers/mmc/msm_sdhci.c new file +27 -0
new file mode 100644
index 0000000..1e2a29b
@@ -0,0 +1,180 @@
+/*
+ * Qualcomm SDHCI driver - SD/eMMC controller
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+ *
+ * Based on Linux driver
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <sdhci.h>
+#include <wait_bit.h>
+#include <asm/io.h>
+#include <linux/bitops.h>
+
+/* Non-standard registers needed for SDHCI startup */
+#define SDCC_MCI_POWER   0x0
+#define SDCC_MCI_POWER_SW_RST BIT(7)
+
+/* This is undocumented register */
+#define SDCC_MCI_VERSION             0x50
+#define SDCC_MCI_VERSION_MAJOR_SHIFT 28
+#define SDCC_MCI_VERSION_MAJOR_MASK  (0xf << SDCC_MCI_VERSION_MAJOR_SHIFT)
+#define SDCC_MCI_VERSION_MINOR_MASK  0xff

drivers/mmc/msm_sdhci.c line 37

Quoted 10 lines
drivers/mmc/msm_sdhci.c new file +10 -0
+
+#define SDCC_MCI_STATUS2 0x6C
+#define SDCC_MCI_STATUS2_MCI_ACT 0x1
+#define SDCC_MCI_HC_MODE 0x78
+
+/* Offset to SDHCI registers */
+#define SDCC_SDHCI_OFFSET 0x900
+
+/* Non standard (?) SDHCI register */
+#define SDHCI_VENDOR_SPEC_CAPABILITIES0  0x11c

IMHO, since this is based on Linux please use similar macro's to make easy changes in future.

Quoted 125 lines
drivers/mmc/msm_sdhci.c new file +125 -0
+
+struct msm_sdhc {
+       struct sdhci_host host;
+       void *base;
+};
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int msm_sdc_clk_init(struct udevice *dev)
+{
+       uint clk_rate = fdtdec_get_uint(gd->fdt_blob, dev->of_offset,
+                                       "clock-frequency", 400000);
+       uint clkd[2]; /* clk_id and clk_no */
+       int clk_offset;
+       struct udevice *clk;
+       int ret;
+
+       ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, "clock", clkd,
+                                  2);
+       if (ret)
+               return ret;
+
+       clk_offset = fdt_node_offset_by_phandle(gd->fdt_blob, clkd[0]);
+       if (clk_offset < 0)
+               return clk_offset;
+
+       ret = uclass_get_device_by_of_offset(UCLASS_CLK, clk_offset, &clk);
+       if (ret)
+               return ret;
+
+       ret = clk_set_periph_rate(clk, clkd[1], clk_rate);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static int msm_sdc_probe(struct udevice *dev)
+{
+       struct msm_sdhc *prv = dev_get_priv(dev);
+       struct sdhci_host *host = &prv->host;
+       u32 core_version, core_minor, core_major;
+       int ret;
+
+       host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_BROKEN_R1B;
+
+       /* Init clocks */
+       ret = msm_sdc_clk_init(dev);
+       if (ret)
+               return ret;
+
+       /* Reset the core and Enable SDHC mode */
+       writel(readl(prv->base + SDCC_MCI_POWER) | SDCC_MCI_POWER_SW_RST,
+              prv->base + SDCC_MCI_POWER);
+
+
+       /* Wait for reset to be written to register */
+       if (wait_for_bit(__func__, prv->base + SDCC_MCI_STATUS2,
+                        SDCC_MCI_STATUS2_MCI_ACT, false, 10, false)) {
+               printf("msm_sdhci: reset request failed\n");
+               return -EIO;
+       }
+
+       /* SW reset can take upto 10HCLK + 15MCLK cycles. (min 40us) */
+       if (wait_for_bit(__func__, prv->base + SDCC_MCI_POWER,
+                        SDCC_MCI_POWER_SW_RST, false, 2, false)) {
+               printf("msm_sdhci: stuck in reset\n");
+               return -ETIMEDOUT;
+       }
+
+       /* Enable host-controller mode */
+       writel(1, prv->base + SDCC_MCI_HC_MODE);
+
+       core_version = readl(prv->base + SDCC_MCI_VERSION);
+
+       core_major = (core_version & SDCC_MCI_VERSION_MAJOR_MASK);
+       core_major >>= SDCC_MCI_VERSION_MAJOR_SHIFT;
+
+       core_minor = core_version & SDCC_MCI_VERSION_MINOR_MASK;
+
+       /*
+        * Support for some capabilities is not advertised by newer
+        * controller versions and must be explicitly enabled.
+        */
+       if (core_major >= 1 && core_minor != 0x11 && core_minor != 0x12) {
+               u32 caps = readl(host->ioaddr + SDHCI_CAPABILITIES);
+               caps |= SDHCI_CAN_VDD_300 | SDHCI_CAN_DO_8BIT;
+               writel(caps, host->ioaddr + SDHCI_VENDOR_SPEC_CAPABILITIES0);
+       }
+
+       /* Set host controller version */
+       host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
+
+       /* automatically detect max and min speed */
+       return add_sdhci(host, 0, 0);
+}
+
+static int msm_sdc_remove(struct udevice *dev)
+{
+       struct msm_sdhc *priv = dev_get_priv(dev);
+
+        /* Disable host-controller mode */
+       writel(0, priv->base + SDCC_MCI_HC_MODE);
+
+       return 0;
+}
+
+static int msm_ofdata_to_platdata(struct udevice *dev)
+{
+       struct udevice *parent = dev->parent;
+       struct msm_sdhc *priv = dev_get_priv(dev);
+       struct sdhci_host *host = &priv->host;
+
+       host->name = strdup(dev->name);
+       host->ioaddr = (void *)dev_get_addr(dev);
+       host->bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+                                        "bus-width", 4);
+       host->index = fdtdec_get_uint(gd->fdt_blob, dev->of_offset, "index", 0);
+       priv->base = (void *)fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
+                                                             parent->of_offset,
+                                                             dev->of_offset,
+                                                             "reg", 1, NULL);
+       if (priv->base == (void *)FDT_ADDR_T_NONE ||
+           host->ioaddr == (void *)FDT_ADDR_T_NONE)
+               return -EINVAL;

drivers/mmc/msm_sdhci.c line 172

Quoted 10 lines
drivers/mmc/msm_sdhci.c new file +10 -0
+
+       return 0;
+}
+
+static const struct udevice_id msm_mmc_ids[] = {
+       { .compatible = "qcom,sdhci-msm-v4" },
+       { }
+};
+
+U_BOOT_DRIVER(msm_sdc_drv) = {

Same as above - msm_sdhci_drv looks more readable and with below driver attributes as well.

Quoted 11 lines
drivers/mmc/msm_sdhci.c new file +8 -1
+       .name           = "msm_sdc",
+       .id             = UCLASS_MMC,
+       .of_match       = msm_mmc_ids,
+       .ofdata_to_platdata = msm_ofdata_to_platdata,
+       .probe          = msm_sdc_probe,
+       .remove         = msm_sdc_remove,
+       .priv_auto_alloc_size = sizeof(struct msm_sdhc),
+};
--

2.5.0

thanks!

Signature · 1 line
Jagan.
#8 lore raw

PATCH v2 3/18 mmc: Add support for Qualcomm SDHCI controller

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi,

Ouch - I missed this one - sorry for late reply.

Quoted 2 lines · Jagan Teki

On 8 February 2016 at 02:27, Mateusz Kulikowski
<[email protected]> wrote:

[...]

Quoted 14 lines
Quoted 14 lines
drivers/mmc/msm_sdhci.c new file +14 -0
+/* Non-standard registers needed for SDHCI startup */
+#define SDCC_MCI_POWER   0x0
+#define SDCC_MCI_POWER_SW_RST BIT(7)
+
+/* This is undocumented register */
+#define SDCC_MCI_VERSION             0x50
+#define SDCC_MCI_VERSION_MAJOR_SHIFT 28
+#define SDCC_MCI_VERSION_MAJOR_MASK  (0xf << SDCC_MCI_VERSION_MAJOR_SHIFT)
+#define SDCC_MCI_VERSION_MINOR_MASK  0xff
+
+#define SDCC_MCI_STATUS2 0x6C
+#define SDCC_MCI_STATUS2_MCI_ACT 0x1
+#define SDCC_MCI_HC_MODE 0x78
+
Quoted 8 lines

drivers/mmc/msm_sdhci.c line 37

Quoted 5 lines
drivers/mmc/msm_sdhci.c new file +5 -0
+/* Offset to SDHCI registers */
+#define SDCC_SDHCI_OFFSET 0x900
+
+/* Non standard (?) SDHCI register */
+#define SDHCI_VENDOR_SPEC_CAPABILITIES0  0x11c

IMHO, since this is based on Linux please use similar macro's to make easy changes in future.

I disagree (and I don't like names used on Linux on this particular driver);

"My" names are taken from Qualcomm documentation (HRD to be specific) except for VERSION that was named like that for coherency.

IMHO it's less confusing and allows faster documentation lookups.

Unless Linux names are from some (public) IP Core documentation - then please point me to it and I will do the rename (and add reference to it in the driver).

Quoted 1 line

[...]

Quoted 10 lines

drivers/mmc/msm_sdhci.c line 172

Quoted 7 lines
drivers/mmc/msm_sdhci.c new file +7 -0
+
+static const struct udevice_id msm_mmc_ids[] = {
+       { .compatible = "qcom,sdhci-msm-v4" },
+       { }
+};
+
+U_BOOT_DRIVER(msm_sdc_drv) = {

Same as above - msm_sdhci_drv looks more readable and with below driver attributes as well.

Ok, Agree - this will be more coherent with DT bindings / file names.

Regards,
Mateusz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJWzjJGAAoJELvtohmVtQzBAlQIAIpXDp744j4xWUQYpq/wNhIO MOmq3HlX+PBgTNPBKm9ub6XCTKa1K5DtGQ/VNKNDx/bv3fYyW7yTAoO4PP1/9eB5 NyM69NYfiQL8euw2y/LGHPqO3jL+T5FG+Y/PSx2GxtFUusGrlMXQG+f+IyhEvY0A 7F5hBK+OixzKlUvm8ZgP4dLzc3dLKI/BaZu7Hz7nzj3BaA2d0MpHUqYISfZU4TB+ mO+iHiFgWsu0yC+KhIxqZmxoVsCWvbVOmEdj37h5IAsxWgRRqQF8UhxTTGZpT7nk U3G3oNPOwTZtsDtfqP2ia3phB2T6ZP6tys8AhNkRuAHEh9d5J7hylkxYwm0eE48= =SXjw
-----END PGP SIGNATURE-----

#9 lore raw

PATCH v2 4/18 ehci-hcd: Add init_after_reset

In reply to Mateusz Kulikowski

Some host controllers need addidional initialization after ehci_reset() In non-dm implementation it is possible to use CONFIG_EHCI_HCD_INIT_AFTER_RESET. This patch adds similar option to ehci drivers using dm.

---

Changes in v3: None
Changes in v2:
- Add Reviewed-by (sjg)

Changes in v1:
- No changes, just added Acked-by, Reviewed-by

 drivers/usb/host/ehci-hcd.c | 6 ++++++
 drivers/usb/host/ehci.h     | 1 +
 2 files changed, 7 insertions(+)
drivers/usb/host/ehci-hcd.c +6 -0
index c664b16..a4635ef 100644
@@ -1614,6 +1614,12 @@ int ehci_register(struct udevice *dev, struct ehci_hccr *hccr,
 	if (ret)
 		goto err;
 
+	if (ops->init_after_reset) {
+		ret = ops->init_after_reset(ctrl);
+		if (ret)
+			goto err;
+	}
+
 	ret = ehci_common_init(ctrl, tweaks);
 	if (ret)
 		goto err;
drivers/usb/host/ehci.h +1 -0
index b41c04a..ed567fc 100644
@@ -239,6 +239,7 @@ struct ehci_ops {
 	void (*powerup_fixup)(struct ehci_ctrl *ctrl, uint32_t *status_reg,
 			      uint32_t *reg);
 	uint32_t *(*get_portsc_register)(struct ehci_ctrl *ctrl, int port);
+	int (*init_after_reset)(struct ehci_ctrl *ctrl);
 };
 
 struct ehci_ctrl {
Signature · 1 line
2.5.0
#10 lore raw

PATCH v2 5/18 usb: ulpi: Add Kconfig options for ULPI

In reply to Mateusz Kulikowski

The following options can be now enabled via defconfig:
- CONFIG_USB_ULPI
- CONFIG_USB_ULPI_VIEWPORT
- CONFIG_USB_ULPI_VIEWPORT_OMAP

---

Changes in v3: None
Changes in v2:
- Add better (any) descriptions for Kconfig items.

Changes in v1: None

 drivers/usb/Kconfig      |  2 ++
 drivers/usb/ulpi/Kconfig | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
 create mode 100644 drivers/usb/ulpi/Kconfig
drivers/usb/Kconfig +2 -0
index abb06fc..57b99f2 100644
@@ -53,6 +53,8 @@ source "drivers/usb/musb-new/Kconfig"
 
 source "drivers/usb/emul/Kconfig"
 
+source "drivers/usb/ulpi/Kconfig"
+
 comment "USB peripherals"
 
 config USB_STORAGE
drivers/usb/ulpi/Kconfig new file +33 -0
new file mode 100644
index 0000000..329d2df
@@ -0,0 +1,33 @@
+comment "ULPI drivers"
+
+choice
+	prompt "ULPI Viewport type"
+	optional
+	default n
+	help
+	  Select ULPI viewport (SoC-side interface to ULPI) implementation
+	  appropriate for the device if you want to communicate with
+	  UTMI (USB PHY) via ULPI interface.
+
+config USB_ULPI_VIEWPORT
+	bool "Generic ULPI Viewport"
+	help
+	  Support generic ULPI Viewport implementation that is used on
+	  some Tegra and Snapdragon devices.
+
+config USB_ULPI_VIEWPORT_OMAP
+	bool "OMAP ULPI Viewport"
+	help
+	  Support ULPI Viewport implementation that is used on OMAP devices.
+
+endchoice
+
+config USB_ULPI
+	bool "ULPI support"
+	depends on (USB_ULPI_VIEWPORT || USB_ULPI_VIEWPORT_OMAP)
+	help
+	  Select to commnicate with USB PHY via ULPI interface.
+	  ULPI is wrapper on UTMI+ core that is used as
+	  PHY Transreceiver for USB controllers.
+
+	  This driver uses ULPI viewports that are specific for each SoC.
Signature · 1 line
2.5.0
#12 lore raw

PATCH v2 6/18 Migrate CONFIG_ULPI* to Kconfig

In reply to Mateusz Kulikowski

Move CONFIG_USB_ULPI* from headers to defconfigs for boards that use it. Also - add CONFIG_USB where necesarry - all boards use it, but some are not defining it explicitly.

Affected boards:
colibri_t20, harmony, mcx, mt_ventoux, twister,
zynq_(picozed, zc702, zc706, zed, zybo)

---

Changes in v3: None
Changes in v2:
- New patch, independent of the rest
- Should compile cleanly on all affected platforms
- Is orthogonal to series (i.e. if get's NAK will not break rest of series)

Changes in v1: None

 configs/colibri_t20_defconfig    | 2 ++
 configs/harmony_defconfig        | 2 ++
 configs/mcx_defconfig            | 3 +++
 configs/mt_ventoux_defconfig     | 3 +++
 configs/twister_defconfig        | 3 +++
 configs/zynq_picozed_defconfig   | 3 +++
 configs/zynq_zc702_defconfig     | 3 +++
 configs/zynq_zc706_defconfig     | 3 +++
 configs/zynq_zed_defconfig       | 3 +++
 configs/zynq_zybo_defconfig      | 3 +++
 include/configs/colibri_t20.h    | 2 --
 include/configs/harmony.h        | 2 --
 include/configs/mcx.h            | 2 --
 include/configs/tam3517-common.h | 2 --
 include/configs/zynq-common.h    | 2 --
 15 files changed, 28 insertions(+), 10 deletions(-)
configs/colibri_t20_defconfig +2 -0
index 982cee4..143d33a 100644
@@ -14,4 +14,6 @@ CONFIG_CMD_GPIO=y
 CONFIG_SYS_NS16550=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
+CONFIG_USB_ULPI=y
+CONFIG_USB_ULPI_VIEWPORT=y
 CONFIG_USE_PRIVATE_LIBGCC=y
configs/harmony_defconfig +2 -0
index a3f73cc..1a301f8 100644
@@ -15,4 +15,6 @@ CONFIG_CMD_GPIO=y
 CONFIG_SYS_NS16550=y
 CONFIG_USB=y
 CONFIG_DM_USB=y
+CONFIG_USB_ULPI=y
+CONFIG_USB_ULPI_VIEWPORT=y
 CONFIG_USE_PRIVATE_LIBGCC=y
configs/mcx_defconfig +3 -0
index 1e204d5..612bf66 100644
@@ -10,3 +10,6 @@ CONFIG_SYS_PROMPT="mcx # "
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_SYS_NS16550=y
+CONFIG_USB=y
+CONFIG_USB_ULPI=y
+CONFIG_USB_ULPI_VIEWPORT_OMAP=y
configs/mt_ventoux_defconfig +3 -0
index a0153e4..8b3298b 100644
@@ -8,3 +8,6 @@ CONFIG_SYS_PROMPT="mt_ventoux => "
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_SYS_NS16550=y
+CONFIG_USB=y
+CONFIG_USB_ULPI=y
+CONFIG_USB_ULPI_VIEWPORT_OMAP=y
configs/twister_defconfig +3 -0
index e721edb..a1abbe1 100644
@@ -8,3 +8,6 @@ CONFIG_SYS_PROMPT="twister => "
 CONFIG_CMD_GPIO=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_SYS_NS16550=y
+CONFIG_USB=y
+CONFIG_USB_ULPI=y
+CONFIG_USB_ULPI_VIEWPORT_OMAP=y
configs/zynq_picozed_defconfig +3 -0
index fbc603f..33f9d3b 100644
@@ -11,3 +11,6 @@ CONFIG_CMD_GPIO=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_ZYNQ_GEM=y
+CONFIG_USB=y
+CONFIG_USB_ULPI=y
+CONFIG_USB_ULPI_VIEWPORT=y
configs/zynq_zc702_defconfig +3 -0
index 3540653..3a2341a 100644
@@ -23,3 +23,6 @@ CONFIG_DEBUG_UART_ZYNQ=y
 CONFIG_DEBUG_UART_BASE=0xe0001000
 CONFIG_DEBUG_UART_CLOCK=50000000
 CONFIG_ZYNQ_QSPI=y
+CONFIG_USB=y
+CONFIG_USB_ULPI=y
+CONFIG_USB_ULPI_VIEWPORT=y
configs/zynq_zc706_defconfig +3 -0
index f333b7a..e85d5f9 100644
@@ -20,3 +20,6 @@ CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_ZYNQ_GEM=y
 CONFIG_ZYNQ_QSPI=y
+CONFIG_USB=y
+CONFIG_USB_ULPI=y
+CONFIG_USB_ULPI_VIEWPORT=y
configs/zynq_zed_defconfig +3 -0
index 5868012..fd62966 100644
@@ -20,3 +20,6 @@ CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_ZYNQ_GEM=y
 CONFIG_ZYNQ_QSPI=y
+CONFIG_USB=y
+CONFIG_USB_ULPI=y
+CONFIG_USB_ULPI_VIEWPORT=y
configs/zynq_zybo_defconfig +3 -0
index ebaae49..a87c167 100644
@@ -21,3 +21,6 @@ CONFIG_DEBUG_UART_ZYNQ=y
 CONFIG_DEBUG_UART_BASE=0xe0001000
 CONFIG_DEBUG_UART_CLOCK=50000000
 CONFIG_ZYNQ_QSPI=y
+CONFIG_USB=y
+CONFIG_USB_ULPI=y
+CONFIG_USB_ULPI_VIEWPORT=y
include/configs/colibri_t20.h +0 -2
index 7611fc5..270eb1d 100644
@@ -36,8 +36,6 @@
 /* USB host support */
 #define CONFIG_USB_EHCI
 #define CONFIG_USB_EHCI_TEGRA
-#define CONFIG_USB_ULPI
-#define CONFIG_USB_ULPI_VIEWPORT
 #define CONFIG_USB_MAX_CONTROLLER_COUNT	3
 #define CONFIG_USB_STORAGE
 #define CONFIG_CMD_USB
include/configs/harmony.h +0 -2
index e0bc7c0..d842ceb 100644
@@ -45,8 +45,6 @@
 #define CONFIG_USB_MAX_CONTROLLER_COUNT 3
 #define CONFIG_USB_EHCI
 #define CONFIG_USB_EHCI_TEGRA
-#define CONFIG_USB_ULPI
-#define CONFIG_USB_ULPI_VIEWPORT
 #define CONFIG_USB_STORAGE
 #define CONFIG_CMD_USB
 
include/configs/mcx.h +0 -2
index 4eea06d..7987b2c 100644
@@ -105,8 +105,6 @@
 #define CONFIG_OMAP3_GPIO_5
 #define CONFIG_USB_EHCI
 #define CONFIG_USB_EHCI_OMAP
-#define CONFIG_USB_ULPI
-#define CONFIG_USB_ULPI_VIEWPORT_OMAP
 #define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO	57
 #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3
 #define	CONFIG_USB_HOST_ETHER
include/configs/tam3517-common.h +0 -2
index 2d941ca..0a4d3fa 100644
@@ -91,8 +91,6 @@
 #define CONFIG_OMAP3_GPIO_5
 #define CONFIG_USB_EHCI
 #define CONFIG_USB_EHCI_OMAP
-#define CONFIG_USB_ULPI
-#define CONFIG_USB_ULPI_VIEWPORT_OMAP
 #define CONFIG_OMAP_EHCI_PHY1_RESET_GPIO	25
 #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3
 #define CONFIG_USB_STORAGE
include/configs/zynq-common.h +0 -2
index e8c3ef0..6f00ba5 100644
@@ -100,8 +100,6 @@
 # define CONFIG_CMD_USB
 # define CONFIG_USB_STORAGE
 # define CONFIG_USB_EHCI_ZYNQ
-# define CONFIG_USB_ULPI_VIEWPORT
-# define CONFIG_USB_ULPI
 # define CONFIG_EHCI_IS_TDI
 # define CONFIG_USB_MAX_CONTROLLER_COUNT	2
 
Signature · 1 line
2.5.0
#13 lore raw

PATCH v2 6/18 Migrate CONFIG_ULPI* to Kconfig

Quoted 10 lines · Mateusz Kulikowski

Move CONFIG_USB_ULPI* from headers to defconfigs for boards that use it. Also - add CONFIG_USB where necesarry - all boards use it, but some are not defining it explicitly.

Affected boards:
colibri_t20, harmony, mcx, mt_ventoux, twister,
zynq_(picozed, zc702, zc706, zed, zybo)

Best regards,
Marek Vasut

#14 lore raw

PATCH v2 7/18 usb: Rename ehci-fsl.h to ehci-ci.h

In reply to Mateusz Kulikowski

Most of ehci-fsl header describe USB controller designed by Chipidea and used by various SoC vendors.

This patch renames it to a generic header: ehci-ci.h Contents of file are not changed (so it contains several references to freescale SoCs).

---

Changes in v3: None
Changes in v2:
- Add acked-by

Changes in v1: None

 drivers/usb/host/ehci-fsl.c           | 2 +-
 drivers/usb/host/ehci-mpc512x.c       | 2 +-
 drivers/usb/host/ehci-mx5.c           | 2 +-
 drivers/usb/host/ehci-mx6.c           | 2 +-
 drivers/usb/host/ehci-mxc.c           | 2 +-
 drivers/usb/host/ehci-vf.c            | 2 +-
 drivers/usb/host/ehci-zynq.c          | 2 +-
 include/usb/{ehci-fsl.h => ehci-ci.h} | 6 +++---
 8 files changed, 10 insertions(+), 10 deletions(-)
 rename include/usb/{ehci-fsl.h => ehci-ci.h} (99%)
drivers/usb/host/ehci-fsl.c +1 -1
index 97b7f14..4bcea9d 100644
@@ -12,7 +12,7 @@
 #include <pci.h>
 #include <usb.h>
 #include <asm/io.h>
-#include <usb/ehci-fsl.h>
+#include <usb/ehci-ci.h>
 #include <hwconfig.h>
 #include <fsl_usb.h>
 #include <fdt_support.h>
drivers/usb/host/ehci-mpc512x.c +1 -1
index b320c4a..4b50ac8 100644
@@ -17,7 +17,7 @@
 #include <pci.h>
 #include <usb.h>
 #include <asm/io.h>
-#include <usb/ehci-fsl.h>
+#include <usb/ehci-ci.h>
 
 #include "ehci.h"
 
drivers/usb/host/ehci-mx5.c +1 -1
index d319962..2b36ceb 100644
@@ -9,7 +9,7 @@
 #include <usb.h>
 #include <errno.h>
 #include <linux/compiler.h>
-#include <usb/ehci-fsl.h>
+#include <usb/ehci-ci.h>
 #include <asm/io.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/clock.h>
drivers/usb/host/ehci-mx6.c +1 -1
index e1c67f7..a981b50 100644
@@ -10,7 +10,7 @@
 #include <errno.h>
 #include <wait_bit.h>
 #include <linux/compiler.h>
-#include <usb/ehci-fsl.h>
+#include <usb/ehci-ci.h>
 #include <asm/io.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/clock.h>
drivers/usb/host/ehci-mxc.c +1 -1
index f09c75a..f8324ee 100644
@@ -9,7 +9,7 @@
 #include <usb.h>
 #include <asm/io.h>
 #include <asm/arch/imx-regs.h>
-#include <usb/ehci-fsl.h>
+#include <usb/ehci-ci.h>
 #include <errno.h>
 
 #include "ehci.h"
drivers/usb/host/ehci-vf.c +1 -1
index 335e303..61789dd 100644
@@ -17,7 +17,7 @@
 #include <asm/arch/crm_regs.h>
 #include <asm/imx-common/iomux-v3.h>
 #include <asm/imx-common/regs-usbphy.h>
-#include <usb/ehci-fsl.h>
+#include <usb/ehci-ci.h>
 
 #include "ehci.h"
 
drivers/usb/host/ehci-zynq.c +1 -1
index 7770d05..37a7935 100644
@@ -11,7 +11,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/io.h>
 #include <usb.h>
-#include <usb/ehci-fsl.h>
+#include <usb/ehci-ci.h>
 #include <usb/ulpi.h>
 
 #include "ehci.h"
include/usb/ehci-ci.h renamed from include/usb/ehci-fsl.h +3 -3
similarity index 99%
rename from include/usb/ehci-fsl.h
rename to include/usb/ehci-ci.h
index e9349b5..725aec5 100644
@@ -6,8 +6,8 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#ifndef _EHCI_FSL_H
-#define _EHCI_FSL_H
+#ifndef _EHCI_CI_H
+#define _EHCI_CI_H
 
 #include <asm/processor.h>
 
@@ -285,4 +285,4 @@ int usb_phy_mode(int port);
 int board_ehci_hcd_init(int port);
 int board_usb_phy_mode(int port);
 
-#endif /* _EHCI_FSL_H */
+#endif /* _EHCI_CI_H */
Signature · 1 line
2.5.0
#15 lore raw

PATCH v2 7/18 usb: Rename ehci-fsl.h to ehci-ci.h

Quoted 10 lines · Mateusz Kulikowski

Most of ehci-fsl header describe USB controller designed by Chipidea and used by various SoC vendors.

This patch renames it to a generic header: ehci-ci.h Contents of file are not changed (so it contains several references to freescale SoCs).

Please note that there are more instances of usb/ehci-fsl.h that need to be caught and renamed. 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/20160225/f7eec258/attachment.sig>
#16 lore raw

PATCH v2 8/18 usb: ehci-ci: Add missing registers.

In reply to Mateusz Kulikowski

Some registers of usb_ehci were marked as reserved.
This may be true for some variants of Chipidea USB core, but they have meaning on other devices.

The following registers were added:
sbusstatus/sbusmode: AHB-related registers genconfig*: Auxiluary IP core configuration registers.

---

Changes in v3: None
Changes in v2:
- Add reviewed-by

Changes in v1: None

 include/usb/ehci-ci.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
include/usb/ehci-ci.h +5 -1
index 725aec5..305b180 100644
@@ -191,7 +191,11 @@ struct usb_ehci {
 	u32     gptimer1_ld;	/* 0x088 - General Purpose Timer 1 load value */
 	u32     gptimer1_ctrl;	/* 0x08C - General Purpose Timer 1 control */
 	u32	sbuscfg;	/* 0x090 - System Bus Interface Control */
-	u8	res2[0x6C];
+	u32	sbusstatus;	/* 0x094 - System Bus Interface Status */
+	u32	sbusmode;	/* 0x098 - System Bus Interface Mode */
+	u32	genconfig;	/* 0x09C - USB Core Configuration */
+	u32	genconfig2;	/* 0x0A0 - USB Core Configuration 2 */
+	u8	res2[0x5c];
 	u8	caplength;	/* 0x100 - Capability Register Length */
 	u8	res3[0x1];
 	u16	hciversion;	/* 0x102 - Host Interface Version */
Signature · 1 line
2.5.0
#17 lore raw

PATCH v2 9/18 ehci-ci.h: drop generic USBCMD fields

In reply to Mateusz Kulikowski

Use definitions from ehci.h instead.

---

Changes in v3: None
Changes in v2:
- Add Acked-by

Changes in v1: None

 drivers/usb/host/ehci-mpc512x.c | 4 ++--
 include/usb/ehci-ci.h           | 4 ----
 2 files changed, 2 insertions(+), 6 deletions(-)
drivers/usb/host/ehci-mpc512x.c +2 -2
index 4b50ac8..bb4f461 100644
@@ -93,7 +93,7 @@ static int reset_usb_controller(volatile struct usb_ehci *ehci)
 	unsigned int i;
 
 	/* Command a reset of the USB Controller */
-	out_be32(&(ehci->usbcmd), EHCI_FSL_USBCMD_RST);
+	out_be32(&(ehci->usbcmd), CMD_RESET);
 
 	/* Wait for the reset process to finish */
 	for (i = 65535 ; i > 0 ; i--) {
@@ -101,7 +101,7 @@ static int reset_usb_controller(volatile struct usb_ehci *ehci)
 		 * The host will set this bit to zero once the
 		 * reset process is complete
 		 */
-		if ((in_be32(&(ehci->usbcmd)) & EHCI_FSL_USBCMD_RST) == 0)
+		if ((in_be32(&(ehci->usbcmd)) & CMD_RESET) == 0)
 			return 0;
 	}
 
include/usb/ehci-ci.h +0 -4
index 305b180..586d32a 100644
@@ -97,10 +97,6 @@
 #define INTR_DATA_PULSING_EN	(0x1<<30)
 #define INTSTS_MASK		(0x00ff0000)
 
-/* USBCMD Bits of interest */
-#define EHCI_FSL_USBCMD_RST	(1 <<  1)
-#define EHCI_FSL_USBCMD_RS	(1 <<  0)
-
 #define  INTERRUPT_ENABLE_BITS_MASK  \
 		(INTR_USB_ID_EN		| \
 		INTR_1MS_TIMER_EN	| \
Signature · 1 line
2.5.0
#18 lore raw

PATCH v2 10/18 ehci: Add support for Qualcomm EHCI

In reply to Mateusz Kulikowski

This driver is able to reconfigure OTG controller into HOST mode. Board can add board-specific initialization as board_prepare_usb(). It requires USB_ULPI_VIEWPORT enabled in board configuration.

---

Changes in v3: None
Changes in v2:
- Use PORT_... macro to write to portsc
- Remove extra whitespace in probe()
- Add acked-by

Changes in v1:
- Reordered header files
- Removed braces around constant
- Added more verbose help to KConfig
- Added ULPI dependency to Kconfig
- Drop register #defines - use ehci-ci.h instead
- Create fixed ulpi viewport for device
- Use setbits/clearbits where possible
- Use wait_for_bit to reset controller
- Add dt binding documents

 doc/device-tree-bindings/usb/ehci-msm.txt |  10 ++
 drivers/usb/host/Kconfig                  |  11 ++
 drivers/usb/host/Makefile                 |   1 +
 drivers/usb/host/ehci-msm.c               | 178 ++++++++++++++++++++++++++++++
 4 files changed, 200 insertions(+)
 create mode 100644 doc/device-tree-bindings/usb/ehci-msm.txt
 create mode 100644 drivers/usb/host/ehci-msm.c
doc/device-tree-bindings/usb/ehci-msm.txt new file +10 -0
new file mode 100644
index 0000000..205bb07
@@ -0,0 +1,10 @@
+Chipidea EHCI controller (part of OTG controller) used on Qualcomm devices.
+
+Required properties:
+- compatible: must be "qcom,ehci-host"
+- reg: start address and size of the registers
+
+ehci at 78d9000 {
+	compatible = "qcom,ehci-host";
+	reg = <0x78d9000 0x400>;
+};
drivers/usb/host/Kconfig +11 -0
index 39f7185..ff5e843 100644
@@ -74,6 +74,17 @@ config USB_EHCI_MX6
 	---help---
 	  Enables support for the on-chip EHCI controller on i.MX6 SoCs.
 
+config USB_EHCI_MSM
+	bool "Support for Qualcomm on-chip EHCI USB controller"
+	depends on DM_USB
+	select USB_ULPI_VIEWPORT
+	default n
+	---help---
+	  Enables support for the on-chip EHCI controller on Qualcomm
+	  Snapdragon SoCs.
+	  This driver supports combination of Chipidea USB controller
+	  and Synapsys USB PHY in host mode only.
+
 config USB_EHCI_UNIPHIER
 	bool "Support for UniPhier on-chip EHCI USB controller"
 	depends on ARCH_UNIPHIER && OF_CONTROL
drivers/usb/host/Makefile +1 -0
index 6183b80..426b066 100644
@@ -43,6 +43,7 @@ obj-$(CONFIG_USB_EHCI_MX7) += ehci-mx6.o
 obj-$(CONFIG_USB_EHCI_OMAP) += ehci-omap.o
 obj-$(CONFIG_USB_EHCI_PPC4XX) += ehci-ppc4xx.o
 obj-$(CONFIG_USB_EHCI_MARVELL) += ehci-marvell.o
+obj-$(CONFIG_USB_EHCI_MSM) += ehci-msm.o
 obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o
 obj-$(CONFIG_USB_EHCI_SPEAR) += ehci-spear.o
 obj-$(CONFIG_USB_EHCI_SUNXI) += ehci-sunxi.o
drivers/usb/host/ehci-msm.c new file +178 -0

178 lines not on this page · raw message

Signature · 1 line
2.5.0
#19 lore raw

PATCH v2 11/18 drivers: Add SPMI bus uclass

In reply to Mateusz Kulikowski

Qualcom processors use proprietary bus to talk with PMIC devices - SPMI (System Power Management Interface).
On wiring level it is similar to I2C, but on protocol level, it's multi-master and has simple autodetection capabilities. This commit adds simple uclass that provides bus read/write interface.

---

Changes in v3: None
Changes in v2:
- Use proper entry order in Kconfig
- Rename CONFIG_DM_SPMI -> CONFIG_SPMI
- Fix header ordering
- Add reviewed-by

Changes in v1:
- Reorder includes
- Add read/write arguments documentation

 drivers/Kconfig            |  2 ++
 drivers/Makefile           |  1 +
 drivers/spmi/Kconfig       | 10 ++++++++++
 drivers/spmi/Makefile      |  7 +++++++
 drivers/spmi/spmi-uclass.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h     |  1 +
 include/spmi/spmi.h        | 47 +++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 116 insertions(+)
 create mode 100644 drivers/spmi/Kconfig
 create mode 100644 drivers/spmi/Makefile
 create mode 100644 drivers/spmi/spmi-uclass.c
 create mode 100644 include/spmi/spmi.h
drivers/Kconfig +2 -0
index 70993fd..c82a94b 100644
@@ -60,6 +60,8 @@ source "drivers/sound/Kconfig"
 
 source "drivers/spi/Kconfig"
 
+source "drivers/spmi/Kconfig"
+
 source "drivers/thermal/Kconfig"
 
 source "drivers/timer/Kconfig"
drivers/Makefile +1 -0
index e7eab66..6900097 100644
@@ -54,6 +54,7 @@ obj-y += dfu/
 obj-$(CONFIG_X86) += pch/
 obj-y += rtc/
 obj-y += sound/
+obj-y += spmi/
 obj-y += timer/
 obj-y += tpm/
 obj-y += twserial/
drivers/spmi/Kconfig new file +10 -0
new file mode 100644
index 0000000..0b9bd31
@@ -0,0 +1,10 @@
+menu "SPMI support"
+
+config SPMI
+	bool "Enable SPMI bus support"
+	depends on DM
+	---help---
+	  Select this to enable to support SPMI bus.
+	  SPMI (System Power Management Interface) bus is used
+	  to connect PMIC devices on various SoCs.
+endmenu
drivers/spmi/Makefile new file +7 -0
new file mode 100644
index 0000000..99092eb
@@ -0,0 +1,7 @@
+#
+# (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-$(CONFIG_SPMI)  += spmi-uclass.o
drivers/spmi/spmi-uclass.c new file +48 -0

48 lines not on this page · raw message

include/dm/uclass-id.h +1 -0
index 73cd3ac..956b63f 100644
@@ -64,6 +64,7 @@ enum uclass_id {
 	UCLASS_RTC,		/* Real time clock device */
 	UCLASS_SERIAL,		/* Serial UART */
 	UCLASS_SPI,		/* SPI bus */
+	UCLASS_SPMI,		/* System Power Management Interface bus */
 	UCLASS_SPI_FLASH,	/* SPI flash */
 	UCLASS_SPI_GENERIC,	/* Generic SPI flash target */
 	UCLASS_SYSCON,		/* System configuration device */
include/spmi/spmi.h new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
2.5.0
#20 lore raw

PATCH v2 12/18 spmi: Add sandbox test driver

In reply to Mateusz Kulikowski

This patch adds emulated spmi bus controller with part of pm8916 pmic on it to sandbox and tests validating SPMI uclass.

---

Changes in v3:
- Updated test.dts to include SPMI like sandbox.dts does

Changes in v2:
- Rename CONFIG_DM_SPMI -> CONFIG_SPMI
- Rename r -> regs, p -> priv
- Add reviewed-by
- Update binding doc (drop unused bindig)

Changes in v1: None

 arch/sandbox/dts/sandbox.dts                   |  20 ++++
 arch/sandbox/dts/test.dts                      |  20 ++++
 configs/sandbox_defconfig                      |   4 +
 doc/device-tree-bindings/spmi/spmi-sandbox.txt |  31 +++++
 drivers/spmi/Kconfig                           |   8 ++
 drivers/spmi/Makefile                          |   1 +
 drivers/spmi/spmi-sandbox.c                    | 157 +++++++++++++++++++++++++
 test/dm/Makefile                               |   1 +
 test/dm/spmi.c                                 | 115 ++++++++++++++++++
 9 files changed, 357 insertions(+)
 create mode 100644 doc/device-tree-bindings/spmi/spmi-sandbox.txt
 create mode 100644 drivers/spmi/spmi-sandbox.c
 create mode 100644 test/dm/spmi.c
arch/sandbox/dts/sandbox.dts +20 -0
index e3f02bf..2ae4014 100644
@@ -240,6 +240,26 @@
 		status = "disabled";
 	};
 
+	spmi: spmi at 0 {
+		compatible = "sandbox,spmi";
+		#address-cells = <0x1>;
+		#size-cells = <0x1>;
+		pm8916 at 0 {
+			compatible = "qcom,spmi-pmic";
+			reg = <0x0 0x1>;
+			#address-cells = <0x1>;
+			#size-cells = <0x1>;
+
+			spmi_gpios: gpios at c000 {
+				compatible = "qcom,pm8916-gpio";
+				reg = <0xc000 0x400>;
+				gpio-controller;
+				gpio-count = <4>;
+				#gpio-cells = <2>;
+				gpio-bank-name="spmi";
+			};
+		};
+	};
 };
 
 #include "cros-ec-keyboard.dtsi"
arch/sandbox/dts/test.dts +20 -0
index 9b8d658..8930009 100644
@@ -351,6 +351,26 @@
 		status = "disabled";
 	};
 
+	spmi: spmi at 0 {
+		compatible = "sandbox,spmi";
+		#address-cells = <0x1>;
+		#size-cells = <0x1>;
+		pm8916 at 0 {
+			compatible = "qcom,spmi-pmic";
+			reg = <0x0 0x1>;
+			#address-cells = <0x1>;
+			#size-cells = <0x1>;
+
+			spmi_gpios: gpios at c000 {
+				compatible = "qcom,pm8916-gpio";
+				reg = <0xc000 0x400>;
+				gpio-controller;
+				gpio-count = <4>;
+				#gpio-cells = <2>;
+				gpio-bank-name="spmi";
+			};
+		};
+	};
 };
 
 #include "sandbox_pmic.dtsi"
configs/sandbox_defconfig +4 -0
index b5b81ca..e349234 100644
@@ -31,6 +31,7 @@ CONFIG_ADC=y
 CONFIG_ADC_SANDBOX=y
 CONFIG_CLK=y
 CONFIG_SANDBOX_GPIO=y
+CONFIG_PM8916_GPIO=y
 CONFIG_SYS_I2C_SANDBOX=y
 CONFIG_CROS_EC_KEYB=y
 CONFIG_LED=y
@@ -58,6 +59,9 @@ CONFIG_PINCONF=y
 CONFIG_PINCTRL_SANDBOX=y
 CONFIG_DM_PMIC=y
 CONFIG_DM_PMIC_SANDBOX=y
+CONFIG_PMIC_PM8916=y
+CONFIG_SPMI=y
+CONFIG_SPMI_SANDBOX=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_SANDBOX=y
 CONFIG_RAM=y
doc/device-tree-bindings/spmi/spmi-sandbox.txt new file +31 -0
new file mode 100644
index 0000000..8569a1a
@@ -0,0 +1,31 @@
+Sandbox SPMI emulated arbiter.
+
+This is bus driver for Sandbox. It includes part of emulated pm8916 pmic.
+
+Required properties:
+- compatible: "sandbox,spmi"
+- #address-cells: 0x1 - childs slave ID address
+- #size-cells: 0x1
+
+Example:
+
+spmi: spmi at 0 {
+	compatible = "sandbox,spmi";
+	#address-cells = <0x1>;
+	#size-cells = <0x1>;
+	pm8916 at 0 {
+		compatible = "qcom,spmi-pmic";
+		reg = <0x0 0x1>;
+		#address-cells = <0x1>;
+		#size-cells = <0x1>;
+
+		spmi_gpios: gpios at c000 {
+			compatible = "qcom,pm8916-gpio";
+			reg = <0xc000 0x400>;
+			gpio-controller;
+			gpio-count = <4>;
+			#gpio-cells = <2>;
+			gpio-bank-name="spmi";
+		};
+	};
+};
drivers/spmi/Kconfig +8 -0
index 0b9bd31..c70d675 100644
@@ -7,4 +7,12 @@ config SPMI
 	  Select this to enable to support SPMI bus.
 	  SPMI (System Power Management Interface) bus is used
 	  to connect PMIC devices on various SoCs.
+
+config SPMI_SANDBOX
+	boolean "Support for Sandbox SPMI bus"
+	depends on SPMI
+	---help---
+	  Demo SPMI bus implementation. Emulates part of PM8916 as single
+          slave (0) on bus. It has 4 GPIO peripherals, pid 0xC0-0xC3.
+
 endmenu
drivers/spmi/Makefile +1 -0
index 99092eb..4ca65a9 100644
@@ -5,3 +5,4 @@
 #
 
 obj-$(CONFIG_SPMI)  += spmi-uclass.o
+obj-$(CONFIG_SPMI_SANDBOX) += spmi-sandbox.o
drivers/spmi/spmi-sandbox.c new file +157 -0

157 lines not on this page · raw message

test/dm/Makefile +1 -0
index d4f3f22..16e71fc 100644
@@ -36,4 +36,5 @@ obj-$(CONFIG_DM_REGULATOR) += regulator.o
 obj-$(CONFIG_TIMER) += timer.o
 obj-$(CONFIG_DM_VIDEO) += video.o
 obj-$(CONFIG_ADC) += adc.o
+obj-$(CONFIG_SPMI) += spmi.o
 endif
test/dm/spmi.c new file +115 -0

115 lines not on this page · raw message

Signature · 1 line
2.5.0
#21 lore raw

PATCH v2 13/18 drivers: spmi: Add support for Qualcomm SPMI bus driver

In reply to Mateusz Kulikowski

Support SPMI arbiter on Qualcomm Snapdragon devices.

---

Changes in v3: None
Changes in v2:
- Rename DM_SPMI -> SPMI
- Rename p -> priv (in write/read)
- Fix header ordering (again)
- Add reviewed-by

Changes in v1:
- add binding documentation and better Kconfig help
- Changed a bit mapping
- Change include order
- Use clrsetbits* where possible
- Add one more supported dts id
- Handle missing fields in dt properly

 doc/device-tree-bindings/spmi/spmi-msm.txt |  26 ++++
 drivers/spmi/Kconfig                       |   7 +-
 drivers/spmi/Makefile                      |   1 +
 drivers/spmi/spmi-msm.c                    | 189 +++++++++++++++++++++++++++++
 4 files changed, 222 insertions(+), 1 deletion(-)
 create mode 100644 doc/device-tree-bindings/spmi/spmi-msm.txt
 create mode 100644 drivers/spmi/spmi-msm.c
doc/device-tree-bindings/spmi/spmi-msm.txt new file +26 -0
new file mode 100644
index 0000000..ae47673
@@ -0,0 +1,26 @@
+Qualcomm SPMI arbiter/bus driver
+
+This is bus driver for Qualcomm chips that use SPMI to communicate with PMICs.
+
+Required properties:
+- compatible: "qcom,spmi-pmic-arb"
+- reg: Register block adresses and sizes for various parts of device:
+   1) PMIC arbiter channel mapping base (PMIC_ARB_REG_CHNLn)
+   2) SPMI write command (master) registers (PMIC_ARB_CORE_SW_DEC_CHANNELS)
+   3) SPMI read command (observer) registers (PMIC_ARB_CORE_REGISTERS_OBS)
+
+Optional properties (if not set by parent):
+- #address-cells: 0x1 - childs slave ID address
+- #size-cells: 0x1
+
+All PMICs should be placed as a child nodes of bus arbiter.
+Automatic detection of childs is currently not supported.
+
+Example:
+
+spmi at 200f000 {
+	compatible = "qcom,spmi-pmic-arb";
+	reg = <0x200f800 0x200 0x2400000 0x400000 0x2c00000 0x400000>;
+	#address-cells = <0x1>;
+	#size-cells = <0x1>;
+};
drivers/spmi/Kconfig +6 -1
index c70d675..8d25b45 100644
@@ -8,11 +8,16 @@ config SPMI
 	  SPMI (System Power Management Interface) bus is used
 	  to connect PMIC devices on various SoCs.
 
+config SPMI_MSM
+	boolean "Support Qualcomm SPMI bus"
+	depends on SPMI
+	---help---
+	  Support SPMI bus implementation found on Qualcomm Snapdragon SoCs.
+
 config SPMI_SANDBOX
 	boolean "Support for Sandbox SPMI bus"
 	depends on SPMI
 	---help---
 	  Demo SPMI bus implementation. Emulates part of PM8916 as single
           slave (0) on bus. It has 4 GPIO peripherals, pid 0xC0-0xC3.
-
 endmenu
drivers/spmi/Makefile +1 -0
index 4ca65a9..c0b1220 100644
@@ -5,4 +5,5 @@
 #
 
 obj-$(CONFIG_SPMI)  += spmi-uclass.o
+obj-$(CONFIG_SPMI_MSM) += spmi-msm.o
 obj-$(CONFIG_SPMI_SANDBOX) += spmi-sandbox.o
drivers/spmi/spmi-msm.c new file +189 -0

189 lines not on this page · raw message

Signature · 1 line
2.5.0
#22 lore raw

PATCH v2 13/18 drivers: spmi: Add support for Qualcomm SPMI bus driver

Quoted 22 lines · Mateusz Kulikowski

Support SPMI arbiter on Qualcomm Snapdragon devices.

---

Changes in v3: None
Changes in v2:
- Rename DM_SPMI -> SPMI
- Rename p -> priv (in write/read)
- Fix header ordering (again)
- Add reviewed-by

Changes in v1:
- add binding documentation and better Kconfig help
- Changed a bit mapping
- Change include order
- Use clrsetbits* where possible
- Add one more supported dts id
- Handle missing fields in dt properly

Quoted 4 lines
 doc/device-tree-bindings/spmi/spmi-msm.txt |  26 ++++
 drivers/spmi/Kconfig                       |   7 +-
 drivers/spmi/Makefile                      |   1 +
 drivers/spmi/spmi-msm.c                    | 189

spmi-pmic-arb.c looks fine along with binding file name as well.

+++++++++++++++++++++++++++++

Quoted 270 lines
 4 files changed, 222 insertions(+), 1 deletion(-)
 create mode 100644 doc/device-tree-bindings/spmi/spmi-msm.txt
 create mode 100644 drivers/spmi/spmi-msm.c
doc/device-tree-bindings/spmi/spmi-msm.txt new file +26 -0
new file mode 100644
index 0000000..ae47673
@@ -0,0 +1,26 @@
+Qualcomm SPMI arbiter/bus driver
+
+This is bus driver for Qualcomm chips that use SPMI to communicate with PMICs.
+
+Required properties:
+- compatible: "qcom,spmi-pmic-arb"
+- reg: Register block adresses and sizes for various parts of device:
+   1) PMIC arbiter channel mapping base (PMIC_ARB_REG_CHNLn)
+   2) SPMI write command (master) registers (PMIC_ARB_CORE_SW_DEC_CHANNELS)
+   3) SPMI read command (observer) registers (PMIC_ARB_CORE_REGISTERS_OBS)
+
+Optional properties (if not set by parent):
+- #address-cells: 0x1 - childs slave ID address
+- #size-cells: 0x1
+
+All PMICs should be placed as a child nodes of bus arbiter.
+Automatic detection of childs is currently not supported.
+
+Example:
+
+spmi at 200f000 {
+       compatible = "qcom,spmi-pmic-arb";
+       reg = <0x200f800 0x200 0x2400000 0x400000 0x2c00000 0x400000>;
+       #address-cells = <0x1>;
+       #size-cells = <0x1>;
+};
drivers/spmi/Kconfig +6 -1
index c70d675..8d25b45 100644
@@ -8,11 +8,16 @@ config SPMI
          SPMI (System Power Management Interface) bus is used
          to connect PMIC devices on various SoCs.
 
+config SPMI_MSM
+       boolean "Support Qualcomm SPMI bus"
+       depends on SPMI
+       ---help---
+         Support SPMI bus implementation found on Qualcomm Snapdragon SoCs.
+
 config SPMI_SANDBOX
        boolean "Support for Sandbox SPMI bus"
        depends on SPMI
        ---help---
          Demo SPMI bus implementation. Emulates part of PM8916 as single
           slave (0) on bus. It has 4 GPIO peripherals, pid 0xC0-0xC3.
-
 endmenu
drivers/spmi/Makefile +1 -0
index 4ca65a9..c0b1220 100644
@@ -5,4 +5,5 @@
 #
 
 obj-$(CONFIG_SPMI)  += spmi-uclass.o
+obj-$(CONFIG_SPMI_MSM) += spmi-msm.o
 obj-$(CONFIG_SPMI_SANDBOX) += spmi-sandbox.o
drivers/spmi/spmi-msm.c new file +189 -1
new file mode 100644
index 0000000..0cef505
@@ -0,0 +1,189 @@
+/*
+ * Qualcomm SPMI bus driver
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+ *
+ * Loosely based on Little Kernel driver
+ *
+ * SPDX-License-Identifier:    BSD-3-Clause
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <asm/io.h>
+#include <spmi/spmi.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define ARB_CHANNEL_OFFSET(n)          (0x4 * (n))
+#define SPMI_CH_OFFSET(chnl)           ((chnl) * 0x8000)
+
+#define SPMI_REG_CMD0                  0x0
+#define SPMI_REG_CONFIG                        0x4
+#define SPMI_REG_STATUS                        0x8
+#define SPMI_REG_WDATA                 0x10
+#define SPMI_REG_RDATA                 0x18
+
+#define SPMI_CMD_OPCODE_SHIFT          27
+#define SPMI_CMD_SLAVE_ID_SHIFT                20
+#define SPMI_CMD_ADDR_SHIFT            12
+#define SPMI_CMD_ADDR_OFFSET_SHIFT     4
+#define SPMI_CMD_BYTE_CNT_SHIFT                0
+
+#define SPMI_CMD_EXT_REG_WRITE_LONG    0x00
+#define SPMI_CMD_EXT_REG_READ_LONG     0x01
+
+#define SPMI_STATUS_DONE               0x1
+
+#define SPMI_MAX_CHANNELS      128
+#define SPMI_MAX_SLAVES                16
+#define SPMI_MAX_PERIPH                256
+
+struct msm_spmi_priv {
+       phys_addr_t arb_chnl; /* ARB channel mapping base */
+       phys_addr_t spmi_core; /* SPMI core */
+       phys_addr_t spmi_obs; /* SPMI observer */
+       /* SPMI channel map */
+       uint8_t channel_map[SPMI_MAX_SLAVES][SPMI_MAX_PERIPH];
+};
+
+static int msm_spmi_write(struct udevice *dev, int usid, int pid, int off,
+                         uint8_t val)
+{
+       struct msm_spmi_priv *priv = dev_get_priv(dev);
+       unsigned channel;
+       uint32_t reg = 0;
+
+       if (usid >= SPMI_MAX_SLAVES)
+               return -EIO;
+       if (pid >= SPMI_MAX_PERIPH)
+               return -EIO;
+
+       channel = priv->channel_map[usid][pid];
+
+       /* Disable IRQ mode for the current channel*/
+       writel(0x0, priv->spmi_core + SPMI_CH_OFFSET(channel) +
+              SPMI_REG_CONFIG);
+
+       /* Write single byte */
+       writel(val, priv->spmi_core + SPMI_CH_OFFSET(channel) + SPMI_REG_WDATA);
+
+       /* Prepare write command */
+       reg |= SPMI_CMD_EXT_REG_WRITE_LONG << SPMI_CMD_OPCODE_SHIFT;
+       reg |= (usid << SPMI_CMD_SLAVE_ID_SHIFT);
+       reg |= (pid << SPMI_CMD_ADDR_SHIFT);
+       reg |= (off << SPMI_CMD_ADDR_OFFSET_SHIFT);
+       reg |= 1; /* byte count */
+
+       /* Send write command */
+       writel(reg, priv->spmi_core + SPMI_CH_OFFSET(channel) + SPMI_REG_CMD0);
+
+       /* Wait till CMD DONE status */
+       reg = 0;
+       while (!reg) {
+               reg = readl(priv->spmi_core + SPMI_CH_OFFSET(channel) +
+                           SPMI_REG_STATUS);
+       }
+
+       if (reg ^ SPMI_STATUS_DONE) {
+               printf("SPMI write failure.\n");
+               return -EIO;
+       }
+
+       return 0;
+}
+
+static int msm_spmi_read(struct udevice *dev, int usid, int pid, int off)
+{
+       struct msm_spmi_priv *priv = dev_get_priv(dev);
+       unsigned channel;
+       uint32_t reg = 0;
+
+       if (usid >= SPMI_MAX_SLAVES)
+               return -EIO;
+       if (pid >= SPMI_MAX_PERIPH)
+               return -EIO;
+
+       channel = priv->channel_map[usid][pid];
+
+       /* Disable IRQ mode for the current channel*/
+       writel(0x0, priv->spmi_obs + SPMI_CH_OFFSET(channel) + SPMI_REG_CONFIG);
+
+       /* Prepare read command */
+       reg |= SPMI_CMD_EXT_REG_READ_LONG << SPMI_CMD_OPCODE_SHIFT;
+       reg |= (usid << SPMI_CMD_SLAVE_ID_SHIFT);
+       reg |= (pid << SPMI_CMD_ADDR_SHIFT);
+       reg |= (off << SPMI_CMD_ADDR_OFFSET_SHIFT);
+       reg |= 1; /* byte count */
+
+       /* Request read */
+       writel(reg, priv->spmi_obs + SPMI_CH_OFFSET(channel) + SPMI_REG_CMD0);
+
+       /* Wait till CMD DONE status */
+       reg = 0;
+       while (!reg) {
+               reg = readl(priv->spmi_obs + SPMI_CH_OFFSET(channel) +
+                           SPMI_REG_STATUS);
+       }
+
+       if (reg ^ SPMI_STATUS_DONE) {
+               printf("SPMI read failure.\n");
+               return -EIO;
+       }
+
+       /* Read the data */
+       return readl(priv->spmi_obs + SPMI_CH_OFFSET(channel) +
+                    SPMI_REG_RDATA) & 0xFF;
+}
+
+static struct dm_spmi_ops msm_spmi_ops = {
+       .read = msm_spmi_read,
+       .write = msm_spmi_write,
+};
+
+static int msm_spmi_probe(struct udevice *dev)
+{
+       struct udevice *parent = dev->parent;
+       struct msm_spmi_priv *priv = dev_get_priv(dev);
+       int i;
+
+       priv->arb_chnl = dev_get_addr(dev);
+       priv->spmi_core = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
+                                                          parent->of_offset,
+                                                          dev->of_offset,
+                                                          "reg", 1, NULL);
+       priv->spmi_obs = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
+                                                         parent->of_offset,
+                                                         dev->of_offset, "reg",
+                                                         2, NULL);
+       if (priv->arb_chnl == FDT_ADDR_T_NONE ||
+           priv->spmi_core == FDT_ADDR_T_NONE ||
+           priv->spmi_obs == FDT_ADDR_T_NONE)
+               return -EINVAL;
+
+       /* Scan peripherals connected to each SPMI channel */
+       for (i = 0; i < SPMI_MAX_CHANNELS ; i++) {
+               uint32_t periph = readl(priv->arb_chnl + ARB_CHANNEL_OFFSET(i));
+               uint8_t slave_id = (periph & 0xf0000) >> 16;
+               uint8_t pid = (periph & 0xff00) >> 8;
+
+               priv->channel_map[slave_id][pid] = i;
+       }
+       return 0;
+}
+
+static const struct udevice_id msm_spmi_ids[] = {
+       { .compatible = "qcom,spmi-pmic-arb" },
+       { }
+};
+
+U_BOOT_DRIVER(msm_spmi) = {
+       .name = "msm_spmi",
+       .id = UCLASS_SPMI,
+       .of_match = msm_spmi_ids,
+       .ops = &msm_spmi_ops,
+       .probe = msm_spmi_probe,
+       .priv_auto_alloc_size = sizeof(struct msm_spmi_priv),
+};
--

2.5.0

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

Signature · 1 line
Jagan.
#23 lore raw

PATCH v2 13/18 drivers: spmi: Add support for Qualcomm SPMI bus driver

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi,

Quoted 2 lines · Jagan Teki

On 8 February 2016 at 02:27, Mateusz Kulikowski
<[email protected]> wrote:

[..]

Quoted 6 lines
Quoted 4 lines
 doc/device-tree-bindings/spmi/spmi-msm.txt |  26 ++++
 drivers/spmi/Kconfig                       |   7 +-
 drivers/spmi/Makefile                      |   1 +
 drivers/spmi/spmi-msm.c                    | 189

spmi-pmic-arb.c looks fine along with binding file name as well.

To be honest it's bus driver, not (only) arbiter driver.

And it's nice to have vendor name there - as some other company may implemented their own SPMI arbiter.

I would prefer to keep it as is.

Regards,
Mateusz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJWx4L1AAoJELvtohmVtQzBX88H/A6iAEM/XanbhKtnMdxLnMrm nA3mMoXZlQ/jqiWXxuzh5MhdPUnzqS8r3R8eVVLy/+/NyYblWSyBJqIjCfQNTWct jhHahHrcLRdje5cU2C8R0DuVqL02mLzcvDHbFKJojS0fGlVqhcWJPCLBkmdjkmpH gjE73dUVBhdTXkuvuj+La15wHr0a0G33oNKDFMhCUnXXHTWJ+ngYBqOrIeOJHmQ8 ykiBRO1qvgRtPwAGd2gpAIUCFZxcMRZvbMm6u+NdTKjCcJsNiE86OiWK7o/xMEZZ Fak1Hs9xHKoStrxgOziZ4CAg4F7odhJr96s7XOC2VFXcf7ropM341vQ14Awjxf8= =vJOo
-----END PGP SIGNATURE-----

#24 lore raw

PATCH v2 14/18 pmic: Add support for Qualcomm PM8916 PMIC

In reply to Mateusz Kulikowski

This PMIC is connected on SPMI bus so needs SPMI support enabled.

---

Changes in v3: None
Changes in v2:
- Add reviewed-by
- Reordered Kconfig & Makefile (to keep alphabetical ordering)
- Added link to dt binding @ help

Changes in v1:
- Added dt bindings
- Reoder includes
- Replaced extract_* macros with ordinary shift/mask
- Added error checking and whitespaces in probe

 doc/device-tree-bindings/pmic/pm8916.txt | 18 ++++++
 drivers/power/pmic/Kconfig               | 16 ++++++
 drivers/power/pmic/Makefile              |  1 +
 drivers/power/pmic/pm8916.c              | 96 ++++++++++++++++++++++++++++++++
 4 files changed, 131 insertions(+)
 create mode 100644 doc/device-tree-bindings/pmic/pm8916.txt
 create mode 100644 drivers/power/pmic/pm8916.c
doc/device-tree-bindings/pmic/pm8916.txt new file +18 -0
new file mode 100644
index 0000000..15c598b
@@ -0,0 +1,18 @@
+Qualcomm pm8916 PMIC
+
+This PMIC is connected using SPMI bus so should be child of SPMI bus controller.
+
+Required properties:
+- compatible: "qcom,spmi-pmic";
+- reg: SPMI Slave ID, size (ignored)
+- #address-cells: 0x1 (peripheral ID)
+- #size-cells: 0x1 (size of peripheral register space)
+
+Example:
+
+pm8916 at 0 {
+	compatible = "qcom,spmi-pmic";
+	reg = <0x0 0x1>;
+	#address-cells = <0x1>;
+	#size-cells = <0x1>;
+};
drivers/power/pmic/Kconfig +16 -0
index 7f69ae1..69f8d51 100644
@@ -54,6 +54,22 @@ config DM_PMIC_MAX77686
 	This config enables implementation of driver-model pmic uclass features
 	for PMIC MAX77686. The driver implements read/write operations.
 
+config PMIC_PM8916
+	bool "Enable Driver Model for Qualcomm PM8916 PMIC"
+	depends on DM_PMIC
+	---help---
+	The PM8916 is a PMIC connected to one (or several) processors
+	with SPMI bus. It has 2 slaves with several peripherals:
+	- 18x LDO
+	- 4x GPIO
+	- Power and Reset buttons
+	- Watchdog
+	- RTC
+	- Vibrator drivers
+	- Others
+
+	Driver binding info: doc/device-tree-bindings/pmic/pm8916.txt
+
 config PMIC_RK808
 	bool "Enable support for Rockchip PMIC RK808"
 	depends on DM_PMIC
drivers/power/pmic/Makefile +1 -0
index c6e8d0c..52b4f71 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_DM_PMIC_PFUZE100) += pfuze100.o
 obj-$(CONFIG_PMIC_S2MPS11) += s2mps11.o
 obj-$(CONFIG_DM_PMIC_SANDBOX) += sandbox.o i2c_pmic_emul.o
 obj-$(CONFIG_PMIC_ACT8846) += act8846.o
+obj-$(CONFIG_PMIC_PM8916) += pm8916.o
 obj-$(CONFIG_PMIC_RK808) += rk808.o
 obj-$(CONFIG_PMIC_TPS65090) += tps65090.o
 obj-$(CONFIG_PMIC_S5M8767) += s5m8767.o
drivers/power/pmic/pm8916.c new file +96 -0

96 lines not on this page · raw message

Signature · 1 line
2.5.0
#25 lore raw

PATCH v2 15/18 gpio: Add support for Qualcomm PM8916 gpios

In reply to Mateusz Kulikowski

This driver supports GPIOs present on PM8916 PMIC.
There are 2 device drivers inside:
- GPIO driver (4 "generic" GPIOs)
- Keypad driver that presents itself as GPIO with 2 inputs (power and reset)

---

Changes in v3: None
Changes in v2:
- Add Reviewed-by

Changes in v1:
- Add binding doc
- Fixed inlcude ordering
- Merged direction_input and direction_output functions
- gpio_get: use switch instead of stacked if
- use pmic_clrsetbits
- add possibility to change prwkey bank name
- Handle invalid bindings
- Sanity HW check (i.e. check type/subtype registers)

 doc/device-tree-bindings/gpio/pm8916_gpio.txt |  48 ++++
 drivers/gpio/Kconfig                          |  10 +
 drivers/gpio/Makefile                         |   1 +
 drivers/gpio/pm8916_gpio.c                    | 302 ++++++++++++++++++++++++++
 4 files changed, 361 insertions(+)
 create mode 100644 doc/device-tree-bindings/gpio/pm8916_gpio.txt
 create mode 100644 drivers/gpio/pm8916_gpio.c
doc/device-tree-bindings/gpio/pm8916_gpio.txt new file +48 -0
new file mode 100644
index 0000000..58185b8
@@ -0,0 +1,48 @@
+Driver for part of pm8916 PMIC - gpio and power/reset keys
+
+This device should be child of SPMI pmic.
+
+1) GPIO driver
+
+Required properties:
+- compatible: "qcom,pm8916-gpio"
+- reg: peripheral ID, size of register block
+- gpio-controller
+- gpio-count: number of GPIOs
+- #gpio-cells: 2
+
+Optional properties:
+- gpio-bank-name: name of bank (as default "pm8916" is used)
+
+Example:
+
+pmic_gpios: gpios at c000 {
+	compatible = "qcom,pm8916-gpio";
+	reg = <0xc000 0x400>;
+	gpio-controller;
+	gpio-count = <4>;
+	#gpio-cells = <2>;
+	gpio-bank-name="pmic";
+};
+
+
+2) Power/Reset key driver
+
+Required properties:
+- compatible: "qcom,pm8916-pwrkey"
+- reg: peripheral ID, size of register block
+- gpio-controller
+- #gpio-cells: 2
+
+Optional properties:
+- gpio-bank-name: name of bank (as default "pm8916_key" is used)
+
+
+Example:
+
+pmic_pon: pon at 800 {
+	compatible = "qcom,pm8916-pwrkey";
+	reg = <0x800 0x96>;
+	#gpio-cells = <2>;
+	gpio-controller;
+};
drivers/gpio/Kconfig +10 -0
index a5e8182..bbafc63 100644
@@ -60,6 +60,16 @@ config MSM_GPIO
 	  - APQ8016
 	  - MSM8916
 
+config PM8916_GPIO
+	bool "Qualcomm PM8916 PMIC GPIO/keypad driver"
+	depends on DM_GPIO && PMIC_PM8916
+	help
+	  Support for GPIO pins and power/reset buttons found on
+	  Qualcomm PM8916 PMIC.
+	  Default name for GPIO bank is "pm8916".
+	  Power and reset buttons are placed in "pm8916_key" bank and
+          have gpio numbers 0 and 1 respectively.
+
 config ROCKCHIP_GPIO
 	bool "Rockchip GPIO driver"
 	depends on DM_GPIO
drivers/gpio/Makefile +1 -0
index 6083c4a..8e880bd 100644
@@ -48,3 +48,4 @@ obj-$(CONFIG_VYBRID_GPIO)	+= vybrid_gpio.o
 obj-$(CONFIG_HIKEY_GPIO)	+= hi6220_gpio.o
 obj-$(CONFIG_PIC32_GPIO)	+= pic32_gpio.o
 obj-$(CONFIG_MSM_GPIO)		+= msm_gpio.o
+obj-$(CONFIG_PM8916_GPIO)	+= pm8916_gpio.o
drivers/gpio/pm8916_gpio.c new file +302 -0

302 lines not on this page · raw message

Signature · 1 line
2.5.0
#26 lore raw

PATCH v2 15/18 gpio: Add support for Qualcomm PM8916 gpios

Quoted 24 lines · Mateusz Kulikowski

This driver supports GPIOs present on PM8916 PMIC.
There are 2 device drivers inside:
- GPIO driver (4 "generic" GPIOs)
- Keypad driver that presents itself as GPIO with 2 inputs (power and reset)

---

Changes in v3: None
Changes in v2:
- Add Reviewed-by

Changes in v1:
- Add binding doc
- Fixed inlcude ordering
- Merged direction_input and direction_output functions
- gpio_get: use switch instead of stacked if
- use pmic_clrsetbits
- add possibility to change prwkey bank name
- Handle invalid bindings
- Sanity HW check (i.e. check type/subtype registers)

Quoted 4 lines
 doc/device-tree-bindings/gpio/pm8916_gpio.txt |  48 ++++
 drivers/gpio/Kconfig                          |  10 +
 drivers/gpio/Makefile                         |   1 +

drivers/gpio/pm8916_gpio.c

               | 302 ++++++++++++++++++++++++++

4 GPIO's pin design, I think this is also comes under pincontrol.

Quoted 403 lines
 4 files changed, 361 insertions(+)
 create mode 100644 doc/device-tree-bindings/gpio/pm8916_gpio.txt
 create mode 100644 drivers/gpio/pm8916_gpio.c
doc/device-tree-bindings/gpio/pm8916_gpio.txt new file +48 -0
new file mode 100644
index 0000000..58185b8
@@ -0,0 +1,48 @@
+Driver for part of pm8916 PMIC - gpio and power/reset keys
+
+This device should be child of SPMI pmic.
+
+1) GPIO driver
+
+Required properties:
+- compatible: "qcom,pm8916-gpio"
+- reg: peripheral ID, size of register block
+- gpio-controller
+- gpio-count: number of GPIOs
+- #gpio-cells: 2
+
+Optional properties:
+- gpio-bank-name: name of bank (as default "pm8916" is used)
+
+Example:
+
+pmic_gpios: gpios at c000 {
+       compatible = "qcom,pm8916-gpio";
+       reg = <0xc000 0x400>;
+       gpio-controller;
+       gpio-count = <4>;
+       #gpio-cells = <2>;
+       gpio-bank-name="pmic";
+};
+
+
+2) Power/Reset key driver
+
+Required properties:
+- compatible: "qcom,pm8916-pwrkey"
+- reg: peripheral ID, size of register block
+- gpio-controller
+- #gpio-cells: 2
+
+Optional properties:
+- gpio-bank-name: name of bank (as default "pm8916_key" is used)
+
+
+Example:
+
+pmic_pon: pon at 800 {
+       compatible = "qcom,pm8916-pwrkey";
+       reg = <0x800 0x96>;
+       #gpio-cells = <2>;
+       gpio-controller;
+};
drivers/gpio/Kconfig +10 -0
index a5e8182..bbafc63 100644
@@ -60,6 +60,16 @@ config MSM_GPIO
          - APQ8016
          - MSM8916
 
+config PM8916_GPIO
+       bool "Qualcomm PM8916 PMIC GPIO/keypad driver"
+       depends on DM_GPIO && PMIC_PM8916
+       help
+         Support for GPIO pins and power/reset buttons found on
+         Qualcomm PM8916 PMIC.
+         Default name for GPIO bank is "pm8916".
+         Power and reset buttons are placed in "pm8916_key" bank and
+          have gpio numbers 0 and 1 respectively.
+
 config ROCKCHIP_GPIO
        bool "Rockchip GPIO driver"
        depends on DM_GPIO
drivers/gpio/Makefile +1 -0
index 6083c4a..8e880bd 100644
@@ -48,3 +48,4 @@ obj-$(CONFIG_VYBRID_GPIO)     += vybrid_gpio.o
 obj-$(CONFIG_HIKEY_GPIO)       += hi6220_gpio.o
 obj-$(CONFIG_PIC32_GPIO)       += pic32_gpio.o
 obj-$(CONFIG_MSM_GPIO)         += msm_gpio.o
+obj-$(CONFIG_PM8916_GPIO)      += pm8916_gpio.o
drivers/gpio/pm8916_gpio.c new file +302 -1
new file mode 100644
index 0000000..1abab7f
@@ -0,0 +1,302 @@
+/*
+ * Qualcomm pm8916 pmic gpio driver - part of Qualcomm PM8916 PMIC
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <power/pmic.h>
+#include <spmi/spmi.h>
+#include <asm/io.h>
+#include <asm/gpio.h>
+#include <linux/bitops.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* Register offset for each gpio */
+#define REG_OFFSET(x)          ((x) * 0x100)
+
+/* Register maps */
+
+/* Type and subtype are shared for all pm8916 peripherals */
+#define REG_TYPE               0x4
+#define REG_SUBTYPE            0x5
+
+#define REG_STATUS             0x08
+#define REG_STATUS_VAL_MASK    0x1
+
+/* MODE_CTL */
+#define REG_CTL           0x40
+#define REG_CTL_MODE_MASK       0x70
+#define REG_CTL_MODE_INPUT      0x00
+#define REG_CTL_MODE_INOUT      0x20
+#define REG_CTL_MODE_OUTPUT     0x10
+#define REG_CTL_OUTPUT_MASK     0x0F
+
+#define REG_DIG_VIN_CTL        0x41
+#define REG_DIG_VIN_VIN0       0
+
+#define REG_DIG_PULL_CTL       0x42
+#define REG_DIG_PULL_NO_PU     0x5
+
+#define REG_DIG_OUT_CTL        0x45
+#define REG_DIG_OUT_CTL_CMOS   (0x0 << 4)
+#define REG_DIG_OUT_CTL_DRIVE_L 0x1
+
+#define REG_EN_CTL             0x46
+#define REG_EN_CTL_ENABLE      (1 << 7)
+
+struct pm8916_gpio_bank {
+       uint16_t pid; /* Peripheral ID on SPMI bus */
+};
+
+static int pm8916_gpio_set_direction(struct udevice *dev, unsigned offset,
+                                    bool input, int value)
+{
+       struct pm8916_gpio_bank *priv = dev_get_priv(dev);
+       uint32_t gpio_base = priv->pid + REG_OFFSET(offset);
+       int ret;
+
+       /* Disable the GPIO */
+       ret = pmic_clrsetbits(dev->parent, gpio_base + REG_EN_CTL,
+                             REG_EN_CTL_ENABLE, 0);
+       if (ret < 0)
+               return ret;
+
+       /* Select the mode */
+       if (input)
+               ret = pmic_reg_write(dev->parent, gpio_base + REG_CTL,
+                                    REG_CTL_MODE_INPUT);
+       else
+               ret = pmic_reg_write(dev->parent, gpio_base + REG_CTL,
+                                    REG_CTL_MODE_INOUT | (value ? 1 : 0));
+       if (ret < 0)
+               return ret;
+
+       /* Set the right pull (no pull) */
+       ret = pmic_reg_write(dev->parent, gpio_base + REG_DIG_PULL_CTL,
+                            REG_DIG_PULL_NO_PU);
+       if (ret < 0)
+               return ret;
+
+       /* Configure output pin drivers if needed */
+       if (!input) {
+               /* Select the VIN - VIN0, pin is input so it doesn't matter */
+               ret = pmic_reg_write(dev->parent, gpio_base + REG_DIG_VIN_CTL,
+                                    REG_DIG_VIN_VIN0);
+               if (ret < 0)
+                       return ret;
+
+               /* Set the right dig out control */
+               ret = pmic_reg_write(dev->parent, gpio_base + REG_DIG_OUT_CTL,
+                                    REG_DIG_OUT_CTL_CMOS |
+                                    REG_DIG_OUT_CTL_DRIVE_L);
+               if (ret < 0)
+                       return ret;
+       }
+
+       /* Enable the GPIO */
+       return pmic_clrsetbits(dev->parent, gpio_base + REG_EN_CTL, 0,
+                              REG_EN_CTL_ENABLE);
+}
+
+static int pm8916_gpio_direction_input(struct udevice *dev, unsigned offset)
+{
+       return pm8916_gpio_set_direction(dev, offset, true, 0);
+}
+
+static int pm8916_gpio_direction_output(struct udevice *dev, unsigned offset,
+                                       int value)
+{
+       return pm8916_gpio_set_direction(dev, offset, false, value);
+}
+
+static int pm8916_gpio_get_function(struct udevice *dev, unsigned offset)
+{
+       struct pm8916_gpio_bank *priv = dev_get_priv(dev);
+       uint32_t gpio_base = priv->pid + REG_OFFSET(offset);
+       int reg;
+
+       /* Set the output value of the gpio */
+       reg = pmic_reg_read(dev->parent, gpio_base + REG_CTL);
+       if (reg < 0)
+               return reg;
+
+       switch (reg & REG_CTL_MODE_MASK) {
+       case REG_CTL_MODE_INPUT:
+               return GPIOF_INPUT;
+       case REG_CTL_MODE_INOUT: /* Fallthrough */
+       case REG_CTL_MODE_OUTPUT:
+               return GPIOF_OUTPUT;
+       default:
+               return GPIOF_UNKNOWN;
+       }
+}
+
+static int pm8916_gpio_get_value(struct udevice *dev, unsigned offset)
+{
+       struct pm8916_gpio_bank *priv = dev_get_priv(dev);
+       uint32_t gpio_base = priv->pid + REG_OFFSET(offset);
+       int reg;
+
+       reg = pmic_reg_read(dev->parent, gpio_base + REG_STATUS);
+       if (reg < 0)
+               return reg;
+
+       return !!(reg & REG_STATUS_VAL_MASK);
+}
+
+static int pm8916_gpio_set_value(struct udevice *dev, unsigned offset,
+                                int value)
+{
+       struct pm8916_gpio_bank *priv = dev_get_priv(dev);
+       uint32_t gpio_base = priv->pid + REG_OFFSET(offset);
+
+       /* Set the output value of the gpio */
+       return pmic_clrsetbits(dev->parent, gpio_base + REG_CTL,
+                              REG_CTL_OUTPUT_MASK, !!value);
+}
+
+static const struct dm_gpio_ops pm8916_gpio_ops = {
+       .direction_input        = pm8916_gpio_direction_input,
+       .direction_output       = pm8916_gpio_direction_output,
+       .get_value              = pm8916_gpio_get_value,
+       .set_value              = pm8916_gpio_set_value,
+       .get_function           = pm8916_gpio_get_function,
+};
+
+static int pm8916_gpio_probe(struct udevice *dev)
+{
+       struct pm8916_gpio_bank *priv = dev_get_priv(dev);
+       int reg;
+
+       priv->pid = dev_get_addr(dev);
+       if (priv->pid == FDT_ADDR_T_NONE)
+               return -EINVAL;
+
+       /* Do a sanity check */
+       reg = pmic_reg_read(dev->parent, priv->pid + REG_TYPE);
+       if (reg != 0x10)
+               return -ENODEV;
+
+       reg = pmic_reg_read(dev->parent, priv->pid + REG_SUBTYPE);
+       if (reg != 0x5)
+               return -ENODEV;
+
+       return 0;
+}
+
+static int pm8916_gpio_ofdata_to_platdata(struct udevice *dev)
+{
+       struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
+
+       uc_priv->gpio_count = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
+                                            "gpio-count", 0);
+       uc_priv->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
+                                        "gpio-bank-name", NULL);
+       if (uc_priv->bank_name == NULL)
+               uc_priv->bank_name = "pm8916";
+
+       return 0;
+}
+
+static const struct udevice_id pm8916_gpio_ids[] = {
+       { .compatible = "qcom,pm8916-gpio" },
+       { }
+};
+
+U_BOOT_DRIVER(gpio_pm8916) = {
+       .name   = "gpio_pm8916",
+       .id     = UCLASS_GPIO,
+       .of_match = pm8916_gpio_ids,
+       .ofdata_to_platdata = pm8916_gpio_ofdata_to_platdata,
+       .probe  = pm8916_gpio_probe,
+       .ops    = &pm8916_gpio_ops,
+       .priv_auto_alloc_size = sizeof(struct pm8916_gpio_bank),
+};
+
+
+/* Add pmic buttons as GPIO as well - there is no generic way for now */
+#define PON_INT_RT_STS                        0x10
+#define KPDPWR_ON_INT_BIT                     0
+#define RESIN_ON_INT_BIT                      1
+
+static int pm8941_pwrkey_get_function(struct udevice *dev, unsigned offset)
+{
+       return GPIOF_INPUT;
+}
+
+static int pm8941_pwrkey_get_value(struct udevice *dev, unsigned offset)
+{
+       struct pm8916_gpio_bank *priv = dev_get_priv(dev);
+
+       int reg = pmic_reg_read(dev->parent, priv->pid + PON_INT_RT_STS);
+
+       if (reg < 0)
+               return 0;
+
+       switch (offset) {
+       case 0: /* Power button */
+               return (reg & BIT(KPDPWR_ON_INT_BIT)) != 0;
+               break;
+       case 1: /* Reset button */
+       default:
+               return (reg & BIT(RESIN_ON_INT_BIT)) != 0;
+               break;
+       }
+}
+
+static const struct dm_gpio_ops pm8941_pwrkey_ops = {
+       .get_value              = pm8941_pwrkey_get_value,
+       .get_function           = pm8941_pwrkey_get_function,
+};
+
+static int pm8941_pwrkey_probe(struct udevice *dev)
+{
+       struct pm8916_gpio_bank *priv = dev_get_priv(dev);
+       int reg;
+
+       priv->pid = dev_get_addr(dev);
+       if (priv->pid == FDT_ADDR_T_NONE)
+               return -EINVAL;
+
+       /* Do a sanity check */
+       reg = pmic_reg_read(dev->parent, priv->pid + REG_TYPE);
+       if (reg != 0x1)
+               return -ENODEV;
+
+       reg = pmic_reg_read(dev->parent, priv->pid + REG_SUBTYPE);
+       if (reg != 0x1)
+               return -ENODEV;
+
+       return 0;
+}
+
+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;
+       if (uc_priv->bank_name == NULL)
+               uc_priv->bank_name = "pm8916_key";
+
+       return 0;
+}
+
+static const struct udevice_id pm8941_pwrkey_ids[] = {
+       { .compatible = "qcom,pm8916-pwrkey" },
+       { }
+};
+
+U_BOOT_DRIVER(pwrkey_pm8941) = {
+       .name   = "pwrkey_pm8916",
+       .id     = UCLASS_GPIO,
+       .of_match = pm8941_pwrkey_ids,
+       .ofdata_to_platdata = pm8941_pwrkey_ofdata_to_platdata,
+       .probe  = pm8941_pwrkey_probe,
+       .ops    = &pm8941_pwrkey_ops,
+       .priv_auto_alloc_size = sizeof(struct pm8916_gpio_bank),
+};
--

2.5.0

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

Signature · 1 line
Jagan.
#27 lore raw

PATCH v2 15/18 gpio: Add support for Qualcomm PM8916 gpios

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi Jagan,

Quoted 2 lines · Jagan Teki

On 8 February 2016 at 02:27, Mateusz Kulikowski
<[email protected]> wrote:

[...]

Quoted 9 lines
Quoted 6 lines

- Sanity HW check (i.e. check type/subtype registers)

 doc/device-tree-bindings/gpio/pm8916_gpio.txt |  48 ++++
 drivers/gpio/Kconfig                          |  10 +
 drivers/gpio/Makefile                         |   1 +

drivers/gpio/pm8916_gpio.c

               | 302 ++++++++++++++++++++++++++

4 GPIO's pin design, I think this is also comes under pincontrol.

Same comment as for cpu GPIO (for now I decided to keep it as is and convert it to pincontrol in the future);

Regards,
Mateusz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJWyDFwAAoJELvtohmVtQzBghoH/2FniGKIXsGBt9K/WLC2K2u5 H5GV13GmZyeJ6kBgqTVZsfzTr4GAwhzLZF4Sh1zpM/BipPrS31VmNfbYhlk43drY v7Fbr2Xk2cCModJ+GzKpOX8OPEdsu079VxSHzcfnnIj3u9fTEA72oPJUVBwGJ+wd r/tOUFc8TLVEEf2pZE2hkYO+0FN+wm7MYVjzwLWWwmnpovhMKRfbT56w4d7HCodj sHdVs0UXBSNtIct7i3/yVA+hEtG5ambXkiwXZDl0SAaJBywuBxBTnoMYyw0T8MxP eRzvGTzggYvTdjOehxQxxeQYzd8qcbvjmi8CL6QWDIp25P/JtQYhlA0z1gdOy94= =6bX5
-----END PGP SIGNATURE-----

#28 lore raw

PATCH v2 16/18 arm: Add support for Qualcomm Snapdragon family

In reply to Mateusz Kulikowski

First supported chip is APQ8016 (that is compatible with MSM8916). Drivers in SoC code:
- Reset controller (PSHOLD)
- Clock controller (very simple clock configuration for MMC and UART)

---

Changes in v3: None
Changes in v2:
- Rename DM_SPMI -> SPMI
- Make MND divider comments more compact :)
- p -> priv
- Add reviewed-by
- Reordered Kconfig to keep alphabetical order
- Renamed reset_sandbox -> msm_reset (typo in reset.c)

Changes in v1:
- Fix include order
- Cleanup defines (added spaces for readibility)
- Base address is integer to avoid casting
- Use setbits_* family where possible
- Drop unneded comments, added newlines where needed
- Check return value of dev_get_addr
- Add binding for apq8016
- Cleaned up divider calculation
- Drop most of gpio.h (only empty file is needed)

 arch/arm/Kconfig                                   |  12 +
 arch/arm/Makefile                                  |   1 +
 arch/arm/mach-snapdragon/Kconfig                   |   6 +
 arch/arm/mach-snapdragon/Makefile                  |   8 +
 arch/arm/mach-snapdragon/clock-apq8016.c           | 262 +++++++++++++++++++++
 arch/arm/mach-snapdragon/include/mach/gpio.h       |   9 +
 .../mach-snapdragon/include/mach/sysmap-apq8016.h  |  14 ++
 arch/arm/mach-snapdragon/reset.c                   |  40 ++++
 8 files changed, 352 insertions(+)
 create mode 100644 arch/arm/mach-snapdragon/Kconfig
 create mode 100644 arch/arm/mach-snapdragon/Makefile
 create mode 100644 arch/arm/mach-snapdragon/clock-apq8016.c
 create mode 100644 arch/arm/mach-snapdragon/include/mach/gpio.h
 create mode 100644 arch/arm/mach-snapdragon/include/mach/sysmap-apq8016.h
 create mode 100644 arch/arm/mach-snapdragon/reset.c
arch/arm/Kconfig +12 -0
index d2dbb1a..f16d0d9 100644
@@ -504,6 +504,16 @@ config RMOBILE
 	bool "Renesas ARM SoCs"
 	select CPU_V7
 
+config ARCH_SNAPDRAGON
+	bool "Qualcomm Snapdragon SoCs"
+	select ARM64
+	select DM
+	select DM_GPIO
+	select DM_SERIAL
+	select SPMI
+	select OF_CONTROL
+	select OF_SEPARATE
+
 config ARCH_SOCFPGA
 	bool "Altera SOCFPGA family"
 	select CPU_V7
@@ -760,6 +770,8 @@ source "arch/arm/mach-rockchip/Kconfig"
 
 source "arch/arm/mach-s5pc1xx/Kconfig"
 
+source "arch/arm/mach-snapdragon/Kconfig"
+
 source "arch/arm/mach-socfpga/Kconfig"
 
 source "arch/arm/mach-stm32/Kconfig"
arch/arm/Makefile +1 -0
index cd7d880..661de56 100644
@@ -54,6 +54,7 @@ machine-$(CONFIG_ARCH_MVEBU)		+= mvebu
 # TODO: rename CONFIG_ORION5X -> CONFIG_ARCH_ORION5X
 machine-$(CONFIG_ORION5X)		+= orion5x
 machine-$(CONFIG_ARCH_S5PC1XX)		+= s5pc1xx
+machine-$(CONFIG_ARCH_SNAPDRAGON)	+= snapdragon
 machine-$(CONFIG_ARCH_SOCFPGA)		+= socfpga
 machine-$(CONFIG_ARCH_ROCKCHIP)		+= rockchip
 machine-$(CONFIG_STM32)			+= stm32
arch/arm/mach-snapdragon/Kconfig new file +6 -0
new file mode 100644
index 0000000..156e733
@@ -0,0 +1,6 @@
+if ARCH_SNAPDRAGON
+
+config SYS_SOC
+	default "snapdragon"
+
+endif
arch/arm/mach-snapdragon/Makefile new file +8 -0
new file mode 100644
index 0000000..8e84705
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y += clock-apq8016.o
+obj-y += reset.o
arch/arm/mach-snapdragon/clock-apq8016.c new file +262 -0

262 lines not on this page · raw message

arch/arm/mach-snapdragon/include/mach/gpio.h new file +9 -0
new file mode 100644
index 0000000..ff949b2
@@ -0,0 +1,9 @@
+/*
+ * Empty gpio.h
+ *
+ * This file must stay as arch/arm/include/asm/gpio.h requires it.
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
arch/arm/mach-snapdragon/include/mach/sysmap-apq8016.h new file +14 -0
new file mode 100644
index 0000000..cdbfad0
@@ -0,0 +1,14 @@
+/*
+ * Qualcomm APQ8916 sysmap
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#ifndef _MACH_SYSMAP_APQ8016_H
+#define _MACH_SYSMAP_APQ8016_H
+
+#define GICD_BASE 0x0b000000
+#define GICC_BASE 0x0a20c000
+
+#endif
arch/arm/mach-snapdragon/reset.c new file +40 -0
new file mode 100644
index 0000000..2627eec
@@ -0,0 +1,40 @@
+/*
+ * Qualcomm APQ8016 reset controller driver
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <reset.h>
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int msm_reset_request(struct udevice *dev, enum reset_t type)
+{
+	phys_addr_t addr = dev_get_addr(dev);
+	if (!addr)
+		return -EINVAL;
+	writel(0, addr);
+	return -EINPROGRESS;
+}
+
+static struct reset_ops msm_reset_ops = {
+	.request	= msm_reset_request,
+};
+
+static const struct udevice_id msm_reset_ids[] = {
+	{ .compatible = "qcom,pshold" },
+	{ }
+};
+
+U_BOOT_DRIVER(msm_reset) = {
+	.name		= "msm_reset",
+	.id		= UCLASS_RESET,
+	.of_match	= msm_reset_ids,
+	.ops		= &msm_reset_ops,
+};
Signature · 1 line
2.5.0
#29 lore raw

PATCH v2 16/18 arm: Add support for Qualcomm Snapdragon family

Quoted 30 lines · Mateusz Kulikowski

First supported chip is APQ8016 (that is compatible with MSM8916). Drivers in SoC code:
- Reset controller (PSHOLD)
- Clock controller (very simple clock configuration for MMC and UART)

---

Changes in v3: None
Changes in v2:
- Rename DM_SPMI -> SPMI
- Make MND divider comments more compact :)
- p -> priv
- Add reviewed-by
- Reordered Kconfig to keep alphabetical order
- Renamed reset_sandbox -> msm_reset (typo in reset.c)

Changes in v1:
- Fix include order
- Cleanup defines (added spaces for readibility)
- Base address is integer to avoid casting
- Use setbits_* family where possible
- Drop unneded comments, added newlines where needed
- Check return value of dev_get_addr
- Add binding for apq8016
- Cleaned up divider calculation
- Drop most of gpio.h (only empty file is needed)

Quoted 15 lines
 arch/arm/Kconfig                                   |  12 +
 arch/arm/Makefile                                  |   1 +
 arch/arm/mach-snapdragon/Kconfig                   |   6 +
 arch/arm/mach-snapdragon/Makefile                  |   8 +
 arch/arm/mach-snapdragon/clock-apq8016.c           | 262 +++++++++++++++++++++
 arch/arm/mach-snapdragon/include/mach/gpio.h       |   9 +
 .../mach-snapdragon/include/mach/sysmap-apq8016.h  |  14 ++
 arch/arm/mach-snapdragon/reset.c                   |  40 ++++
 8 files changed, 352 insertions(+)
 create mode 100644 arch/arm/mach-snapdragon/Kconfig
 create mode 100644 arch/arm/mach-snapdragon/Makefile
 create mode 100644 arch/arm/mach-snapdragon/clock-apq8016.c
 create mode 100644 arch/arm/mach-snapdragon/include/mach/gpio.h
 create mode 100644 arch/arm/mach-snapdragon/include/mach/sysmap-apq8016.h
 create mode 100644 arch/arm/mach-snapdragon/reset.c

I think mach-qcom looks readable, I understand snapdragon is an soc name but why can't we place all qcom soc code to mach-qcom (I think Linux also doing the same)?

Quoted 425 lines
arch/arm/Kconfig +12 -0
index d2dbb1a..f16d0d9 100644
@@ -504,6 +504,16 @@ config RMOBILE
        bool "Renesas ARM SoCs"
        select CPU_V7
 
+config ARCH_SNAPDRAGON
+       bool "Qualcomm Snapdragon SoCs"
+       select ARM64
+       select DM
+       select DM_GPIO
+       select DM_SERIAL
+       select SPMI
+       select OF_CONTROL
+       select OF_SEPARATE
+
 config ARCH_SOCFPGA
        bool "Altera SOCFPGA family"
        select CPU_V7
@@ -760,6 +770,8 @@ source "arch/arm/mach-rockchip/Kconfig"
 
 source "arch/arm/mach-s5pc1xx/Kconfig"
 
+source "arch/arm/mach-snapdragon/Kconfig"
+
 source "arch/arm/mach-socfpga/Kconfig"
 
 source "arch/arm/mach-stm32/Kconfig"
arch/arm/Makefile +1 -0
index cd7d880..661de56 100644
@@ -54,6 +54,7 @@ machine-$(CONFIG_ARCH_MVEBU)          += mvebu
 # TODO: rename CONFIG_ORION5X -> CONFIG_ARCH_ORION5X
 machine-$(CONFIG_ORION5X)              += orion5x
 machine-$(CONFIG_ARCH_S5PC1XX)         += s5pc1xx
+machine-$(CONFIG_ARCH_SNAPDRAGON)      += snapdragon
 machine-$(CONFIG_ARCH_SOCFPGA)         += socfpga
 machine-$(CONFIG_ARCH_ROCKCHIP)                += rockchip
 machine-$(CONFIG_STM32)                        += stm32
arch/arm/mach-snapdragon/Kconfig new file +6 -0
new file mode 100644
index 0000000..156e733
@@ -0,0 +1,6 @@
+if ARCH_SNAPDRAGON
+
+config SYS_SOC
+       default "snapdragon"
+
+endif
arch/arm/mach-snapdragon/Makefile new file +8 -0
new file mode 100644
index 0000000..8e84705
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y += clock-apq8016.o
+obj-y += reset.o
arch/arm/mach-snapdragon/clock-apq8016.c new file +262 -0
new file mode 100644
index 0000000..d548d75
@@ -0,0 +1,262 @@
+/*
+ * Clock drivers for Qualcomm APQ8016
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+ *
+ * Based on Little Kernel driver, simplified
+ *
+ * SPDX-License-Identifier:    BSD-3-Clause
+ */
+
+#include <common.h>
+#include <clk.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/io.h>
+#include <linux/bitops.h>
+
+/* GPLL0 clock control registers */
+#define GPLL0_STATUS        0x2101C
+#define GPLL0_STATUS_ACTIVE BIT(17)
+
+#define APCS_GPLL_ENA_VOTE  0x45000
+#define APCS_GPLL_ENA_VOTE_GPLL0 BIT(0)
+
+/* vote reg for blsp1 clock */
+#define APCS_CLOCK_BRANCH_ENA_VOTE  0x45004
+#define APCS_CLOCK_BRANCH_ENA_VOTE_BLSP1 BIT(10)
+
+/* SDC(n) clock control registers; n=1,2 */
+
+/* block control register */
+#define SDCC_BCR(n)                 ((n * 0x1000) + 0x41000)
+/* cmd */
+#define SDCC_CMD_RCGR(n)            ((n * 0x1000) + 0x41004)
+/* cfg */
+#define SDCC_CFG_RCGR(n)            ((n * 0x1000) + 0x41008)
+/* m */
+#define SDCC_M(n)                   ((n * 0x1000) + 0x4100C)
+/* n */
+#define SDCC_N(n)                   ((n * 0x1000) + 0x41010)
+/* d */
+#define SDCC_D(n)                   ((n * 0x1000) + 0x41014)
+/* branch control */
+#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
+
+/* CBCR register fields */
+#define CBCR_BRANCH_ENABLE_BIT  BIT(0)
+#define CBCR_BRANCH_OFF_BIT     BIT(31)
+
+struct msm_clk_priv {
+       phys_addr_t base;
+};
+
+/* Enable clock controlled by CBC soft macro */
+static void clk_enable_cbc(phys_addr_t cbcr)
+{
+       setbits_le32(cbcr, CBCR_BRANCH_ENABLE_BIT);
+
+       while (readl(cbcr) & CBCR_BRANCH_OFF_BIT)
+               ;
+}
+
+/* clock has 800MHz */
+static void clk_enable_gpll0(phys_addr_t base)
+{
+       if (readl(base + GPLL0_STATUS) & GPLL0_STATUS_ACTIVE)
+               return; /* clock already enabled */
+
+       setbits_le32(base + APCS_GPLL_ENA_VOTE, APCS_GPLL_ENA_VOTE_GPLL0);
+
+       while ((readl(base + GPLL0_STATUS) & GPLL0_STATUS_ACTIVE) == 0)
+               ;
+}
+
+#define APPS_CMD_RGCR_UPDATE BIT(0)
+
+/* Update clock command via CMD_RGCR */
+static void clk_bcr_update(phys_addr_t apps_cmd_rgcr)
+{
+       setbits_le32(apps_cmd_rgcr, APPS_CMD_RGCR_UPDATE);
+
+       /* Wait for frequency to be updated. */
+       while (readl(apps_cmd_rgcr) & APPS_CMD_RGCR_UPDATE)
+               ;
+}
+
+struct bcr_regs {
+       uintptr_t cfg_rcgr;
+       uintptr_t cmd_rcgr;
+       uintptr_t M;
+       uintptr_t N;
+       uintptr_t D;
+};
+
+/* RCGR_CFG register fields */
+#define CFG_MODE_DUAL_EDGE (0x2 << 12) /* Counter mode */
+
+/* sources */
+#define CFG_CLK_SRC_CXO   (0 << 8)
+#define CFG_CLK_SRC_GPLL0 (1 << 8)
+#define CFG_CLK_SRC_MASK  (7 << 8)
+
+/* Mask for supported fields */
+#define CFG_MASK 0x3FFF
+
+#define CFG_DIVIDER_MASK 0x1F
+
+/* root set rate for clocks with half integer and MND divider */
+static void clk_rcg_set_rate_mnd(phys_addr_t base, const struct bcr_regs *regs,
+                                int div, int m, int n, int source)
+{
+       uint32_t cfg;
+       /* M value for MND divider. */
+       uint32_t m_val = m;
+       /* NOT(N-M) value for MND divider. */
+       uint32_t n_val = ~((n)-(m)) * !!(n);
+       /* NOT 2D value for MND divider. */
+       uint32_t d_val = ~(n);
+
+       /* Program MND values */
+       writel(m_val, base + regs->M);
+       writel(n_val, base + regs->N);
+       writel(d_val, base + regs->D);
+
+       /* setup src select and divider */
+       cfg  = readl(base + regs->cfg_rcgr);
+       cfg &= ~CFG_MASK;
+       cfg |= source & CFG_CLK_SRC_MASK; /* Select clock source */
+
+       /* Set the divider; HW permits fraction dividers (+0.5), but
+          for simplicity, we will support integers only */
+       if (div)
+               cfg |= (2 * div - 1) & CFG_DIVIDER_MASK;
+
+       if (n_val)
+               cfg |= CFG_MODE_DUAL_EDGE;
+
+       writel(cfg, base + regs->cfg_rcgr); /* Write new clock configuration */
+
+       /* Inform h/w to start using the new config. */
+       clk_bcr_update(base + regs->cmd_rcgr);
+}
+
+static const struct bcr_regs sdc_regs[] = {
+       {
+       .cfg_rcgr = SDCC_CFG_RCGR(1),
+       .cmd_rcgr = SDCC_CMD_RCGR(1),
+       .M = SDCC_M(1),
+       .N = SDCC_N(1),
+       .D = SDCC_D(1),
+       },
+       {
+       .cfg_rcgr = SDCC_CFG_RCGR(2),
+       .cmd_rcgr = SDCC_CMD_RCGR(2),
+       .M = SDCC_M(2),
+       .N = SDCC_N(2),
+       .D = SDCC_D(2),
+       }
+};
+
+/* Init clock for SDHCI controller */
+static int clk_init_sdc(struct msm_clk_priv *priv, int slot, uint rate)
+{
+       int div = 8; /* 100MHz default */
+
+       if (rate == 200000000)
+               div = 4;
+
+       clk_enable_cbc(priv->base + SDCC_AHB_CBCR(slot));
+       /* 800Mhz/div, gpll0 */
+       clk_rcg_set_rate_mnd(priv->base, &sdc_regs[slot], div, 0, 0,
+                            CFG_CLK_SRC_GPLL0);
+       clk_enable_gpll0(priv->base);
+       clk_enable_cbc(priv->base + SDCC_APPS_CBCR(slot));
+
+       return rate;
+}
+
+static const struct bcr_regs uart2_regs = {
+       .cfg_rcgr = BLSP1_UART2_APPS_CFG_RCGR,
+       .cmd_rcgr = BLSP1_UART2_APPS_CMD_RCGR,
+       .M = BLSP1_UART2_APPS_M,
+       .N = BLSP1_UART2_APPS_N,
+       .D = BLSP1_UART2_APPS_D,
+};
+
+/* Init UART clock, 115200 */
+static int clk_init_uart(struct msm_clk_priv *priv)
+{
+       /* Enable iface clk */
+       clk_enable_cbc(priv->base + BLSP1_AHB_CBCR);
+       /* 7372800 uart block clock @ GPLL0 */
+       clk_rcg_set_rate_mnd(priv->base, &uart2_regs, 1, 144, 15625,
+                            CFG_CLK_SRC_GPLL0);
+       clk_enable_gpll0(priv->base);
+       /* Enable core clk */
+       clk_enable_cbc(priv->base + BLSP1_UART2_APPS_CBCR);
+
+       return 0;
+}
+
+ulong msm_set_periph_rate(struct udevice *dev, int periph, ulong rate)
+{
+       struct msm_clk_priv *priv = dev_get_priv(dev);
+
+       switch (periph) {
+       case 0: /* SDC1 */
+               return clk_init_sdc(priv, 0, rate);
+               break;
+       case 1: /* SDC2 */
+               return clk_init_sdc(priv, 1, rate);
+               break;
+       case 4: /* UART2 */
+               return clk_init_uart(priv);
+               break;
+       default:
+               return 0;
+       }
+}
+
+static int msm_clk_probe(struct udevice *dev)
+{
+       struct msm_clk_priv *priv = dev_get_priv(dev);
+
+       priv->base = dev_get_addr(dev);
+       if (priv->base == FDT_ADDR_T_NONE)
+               return -EINVAL;
+
+       return 0;
+}
+
+static struct clk_ops msm_clk_ops = {
+       .set_periph_rate = msm_set_periph_rate,
+};
+
+static const struct udevice_id msm_clk_ids[] = {
+       { .compatible = "qcom,gcc-msm8916" },
+       { .compatible = "qcom,gcc-apq8016" },
+       { }
+};
+
+U_BOOT_DRIVER(clk_msm) = {
+       .name           = "clk_msm",
+       .id             = UCLASS_CLK,
+       .of_match       = msm_clk_ids,
+       .ops            = &msm_clk_ops,
+       .priv_auto_alloc_size = sizeof(struct msm_clk_priv),
+       .probe          = msm_clk_probe,
+};
arch/arm/mach-snapdragon/include/mach/gpio.h new file +9 -0
new file mode 100644
index 0000000..ff949b2
@@ -0,0 +1,9 @@
+/*
+ * Empty gpio.h
+ *
+ * This file must stay as arch/arm/include/asm/gpio.h requires it.
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
arch/arm/mach-snapdragon/include/mach/sysmap-apq8016.h new file +14 -0
new file mode 100644
index 0000000..cdbfad0
@@ -0,0 +1,14 @@
+/*
+ * Qualcomm APQ8916 sysmap
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+#ifndef _MACH_SYSMAP_APQ8016_H
+#define _MACH_SYSMAP_APQ8016_H
+
+#define GICD_BASE 0x0b000000
+#define GICC_BASE 0x0a20c000
+
+#endif
arch/arm/mach-snapdragon/reset.c new file +40 -1
new file mode 100644
index 0000000..2627eec
@@ -0,0 +1,40 @@
+/*
+ * Qualcomm APQ8016 reset controller driver
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <reset.h>
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int msm_reset_request(struct udevice *dev, enum reset_t type)
+{
+       phys_addr_t addr = dev_get_addr(dev);
+       if (!addr)
+               return -EINVAL;
+       writel(0, addr);
+       return -EINPROGRESS;
+}
+
+static struct reset_ops msm_reset_ops = {
+       .request        = msm_reset_request,
+};
+
+static const struct udevice_id msm_reset_ids[] = {
+       { .compatible = "qcom,pshold" },
+       { }
+};
+
+U_BOOT_DRIVER(msm_reset) = {
+       .name           = "msm_reset",
+       .id             = UCLASS_RESET,
+       .of_match       = msm_reset_ids,
+       .ops            = &msm_reset_ops,
+};
--

2.5.0

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

Signature · 1 line
Jagan.
#30 lore raw

PATCH v2 16/18 arm: Add support for Qualcomm Snapdragon family

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Quoted 2 lines · Jagan Teki

On 8 February 2016 at 02:27, Mateusz Kulikowski
<[email protected]> wrote:

[..]

Quoted 11 lines
Quoted 7 lines
 8 files changed, 352 insertions(+)
 create mode 100644 arch/arm/mach-snapdragon/Kconfig
 create mode 100644 arch/arm/mach-snapdragon/Makefile
 create mode 100644 arch/arm/mach-snapdragon/clock-apq8016.c
 create mode 100644 arch/arm/mach-snapdragon/include/mach/gpio.h
 create mode 100644 arch/arm/mach-snapdragon/include/mach/sysmap-apq8016.h
 create mode 100644 arch/arm/mach-snapdragon/reset.c

I think mach-qcom looks readable, I understand snapdragon is an soc name but why can't we place all qcom soc code to mach-qcom (I think Linux also doing the same)?

I know Linux has mach-qcom, also it was the first name I used, but IMO it's wrong.

This is Snapdragon-only code - it will not work with, say, wireless SoCs (previously Atheros)..

And it will be in-line with other mach-* in U-Boot:
We have mach-exynos, not mach-samsung; mach-at91 not mach-atmel etc.

Regards,
Mateusz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJWyDKlAAoJELvtohmVtQzB8UQH/jF/DWJSRiWvdBtvXDf0AGLy 6/2MMjhhDJDyz2C8zlwv5FlpVVggrNyX3NJoFoIuO7JAwECTnmYAiOj41AyRAYEW vVeoK+rX4nlD3flYv4UevW+Np0HxYVPyjRX2ONsqWj1u0798Wu5sF4m7H1QC24Pi iEFSTEdyNCVLaAqK2ELxL72OTiA3Xc+BQq9rvcHe8Q2wIEiAvP5F9LaWCl0z3dK8 ossNUA76d/YYfkczCgDeeY6xR6pdSizaxW7CsKdDaWFLgDQhZUzhJSgCWIGfgdgJ nY+lVVV3FbJy1Xwe6pgs6vyIqzhb0/9m9d4DTIVZFF+voLzKzE8dREseNzpx+TQ= =hT5h
-----END PGP SIGNATURE-----

#31 lore raw

PATCH v2 17/18 board: Add Qualcomm Dragonboard 410C support

In reply to Mateusz Kulikowski

This commit add support for 96Boards Dragonboard410C. It is board based on APQ8016 Qualcomm SoC, complying with 96boards specification.
Features (present out of the box):
- 4x Cortex A53 (ARMv8)
- 2x USB Host port
- 1x USB Device port
- 4x LEDs
- 1x HDMI connector
- 1x uSD connector
- 3x buttons (Power, Vol+, Vol-/Reset)
- WIFI, Bluetooth with integrated antenna
- 8GiB eMMC

U-Boot boots chained with fastboot in 64-bit mode.
For detailed build instructions see readme.txt in board directory.

---

Changes in v3:
- readme: Added info on how to enter fastboot mode and that dtbTool is also part of skales

Changes in v2:
- Renamed CONFIG_DM_SPMI -> CONFIG_SPMI
- Removed extra enter in dragonboard file
- Added ULPI* to defconfig
- Added MAINTAINERS to board
- Cleaned up config file - use distro defaults/environment:
- Dropped multiple CONFIG_CMD* and other CONFIG_*
- Added distro env/config
- Dropped old boot commands
- Split dts - pm8916_gpio entries are taken directly from Linux Dragonboard dts; Add handles for u-boot in -uboot.dtsi; They will be removed once gpio drivers are converted to pinctrl.
- Renamed some pmic nodes, fixed dragonboard.c to find them properly.
- Added header and converted comments to c98-style in head.S
- Print error if pmic gpio node is not found.

Changes in v1:
- Add better help for dragonboard
- Move static structures to board_prepare_usb
- Add DM_SPMI to defconfig

 arch/arm/dts/Makefile                            |   2 +
 arch/arm/dts/dragonboard410c-uboot.dtsi          |  28 +++++
 arch/arm/dts/dragonboard410c.dts                 | 148 ++++++++++++++++++++++
 arch/arm/mach-snapdragon/Kconfig                 |  20 +++
 board/qualcomm/dragonboard410c/Kconfig           |  15 +++
 board/qualcomm/dragonboard410c/MAINTAINERS       |   6 +
 board/qualcomm/dragonboard410c/Makefile          |   8 ++
 board/qualcomm/dragonboard410c/dragonboard410c.c | 131 +++++++++++++++++++
 board/qualcomm/dragonboard410c/head.S            |  28 +++++
 board/qualcomm/dragonboard410c/readme.txt        |  43 +++++++
 board/qualcomm/dragonboard410c/u-boot.lds        |  90 +++++++++++++
 configs/dragonboard410c_defconfig                |  31 +++++
 include/configs/dragonboard410c.h                | 153 +++++++++++++++++++++++
 13 files changed, 703 insertions(+)
 create mode 100644 arch/arm/dts/dragonboard410c-uboot.dtsi
 create mode 100644 arch/arm/dts/dragonboard410c.dts
 create mode 100644 board/qualcomm/dragonboard410c/Kconfig
 create mode 100644 board/qualcomm/dragonboard410c/MAINTAINERS
 create mode 100644 board/qualcomm/dragonboard410c/Makefile
 create mode 100644 board/qualcomm/dragonboard410c/dragonboard410c.c
 create mode 100644 board/qualcomm/dragonboard410c/head.S
 create mode 100644 board/qualcomm/dragonboard410c/readme.txt
 create mode 100644 board/qualcomm/dragonboard410c/u-boot.lds
 create mode 100644 configs/dragonboard410c_defconfig
 create mode 100644 include/configs/dragonboard410c.h
arch/arm/dts/Makefile +2 -0
index 0fa5796..ee584de 100644
@@ -102,6 +102,8 @@ dtb-$(CONFIG_FSL_LSCH2) += fsl-ls1043a-qds-duart.dtb \
 	fsl-ls1043a-qds-lpuart.dtb \
 	fsl-ls1043a-rdb.dtb
 
+dtb-$(CONFIG_ARCH_SNAPDRAGON) += dragonboard410c.dtb
+
 dtb-$(CONFIG_MACH_SUN4I) += \
 	sun4i-a10-a1000.dtb \
 	sun4i-a10-ba10-tvbox.dtb \
arch/arm/dts/dragonboard410c-uboot.dtsi new file +28 -0
new file mode 100644
index 0000000..cc2c175
@@ -0,0 +1,28 @@
+/*
+ * U-Boot addition to handle Dragonboard 410c pins
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+&pm8916_gpios {
+	usb_hub_reset_pm {
+		gpios = <&pm8916_gpios 2 0>;
+	};
+
+	usb_sw_sel_pm {
+		gpios = <&pm8916_gpios 3 0>;
+	};
+};
+
+
+&pm8916_pon {
+	key_vol_down {
+		gpios = <&pm8916_pon 1 0>;
+	};
+
+	key_power {
+		gpios = <&pm8916_pon 0 0>;
+	};
+};
arch/arm/dts/dragonboard410c.dts new file +148 -0

148 lines not on this page · raw message

arch/arm/mach-snapdragon/Kconfig +20 -0
index 156e733..dc7ba21 100644
@@ -3,4 +3,24 @@ if ARCH_SNAPDRAGON
 config SYS_SOC
 	default "snapdragon"
 
+choice
+	prompt "Snapdragon board select"
+
+config TARGET_DRAGONBOARD410C
+	bool "96Boards Dragonboard 410C"
+	help
+	  Support for 96Boards Dragonboard 410C. This board complies with
+	  96Board Open Platform Specifications. Features:
+	  - Qualcomm Snapdragon 410C SoC - APQ8016 (4xCortex A53, Adreno 306)
+	  - 1GiB RAM
+	  - 8GiB eMMC, uSD slot
+	  - WiFi, Bluetooth and GPS module
+	  - 2x Host, 1x Device USB port
+	  - HDMI
+	  - 20-pin low speed and 40-pin high speed expanders, 4 LED, 3 buttons
+
+endchoice
+
+source "board/qualcomm/dragonboard410c/Kconfig"
+
 endif
board/qualcomm/dragonboard410c/Kconfig new file +15 -0
new file mode 100644
index 0000000..03bd7ae
@@ -0,0 +1,15 @@
+if TARGET_DRAGONBOARD410C
+
+config SYS_BOARD
+	default "dragonboard410c"
+
+config SYS_VENDOR
+	default "qualcomm"
+
+config SYS_SOC
+	default "apq8016"
+
+config SYS_CONFIG_NAME
+	default "dragonboard410c"
+
+endif
board/qualcomm/dragonboard410c/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000..65cb47c
@@ -0,0 +1,6 @@
+DRAGONBOARD410C BOARD
+M:	Mateusz Kulikowski <[email protected]>
+S:	Maintained
+F:	board/qualcomm/dragonboard410c/
+F:	include/configs/dragonboard410c.h
+F:	configs/dragonboard410c_defconfig
board/qualcomm/dragonboard410c/Makefile new file +8 -0
new file mode 100644
index 0000000..cd67808
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y	:= dragonboard410c.o
+extra-y += head.o
board/qualcomm/dragonboard410c/dragonboard410c.c new file +131 -0

131 lines not on this page · raw message

board/qualcomm/dragonboard410c/head.S new file +28 -0
new file mode 100644
index 0000000..9f1e0d9
@@ -0,0 +1,28 @@
+/*
+ * Little-Kernel/Fastboot header for proper chain-loading
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <config.h>
+
+.global _fastboot_header
+_fastboot_header:
+	b _start
+	add     x13, x18, #0x16
+	/* Image load offset from start of RAM, little-endian */
+	.quad   CONFIG_SYS_TEXT_BASE-PHYS_SDRAM_1
+	/* Effective size of kernel image, little-endian */
+	.quad   0 /* 0x60000 */
+	/* Informative flags, little-endian */
+	.quad   0
+	.quad   0                               /* reserved */
+	.quad   0                               /* reserved */
+	.quad   0                               /* reserved */
+	.byte   0x41                            /* Magic number, "ARM\x64" */
+	.byte   0x52
+	.byte   0x4d
+	.byte   0x64
+	.word   0                               /* reserved */
board/qualcomm/dragonboard410c/readme.txt new file +43 -0

43 lines not on this page · raw message

board/qualcomm/dragonboard410c/u-boot.lds new file +90 -0

90 lines not on this page · raw message

configs/dragonboard410c_defconfig new file +31 -0
new file mode 100644
index 0000000..84fe597
@@ -0,0 +1,31 @@
+CONFIG_ARM=y
+CONFIG_ARM64=y
+CONFIG_ARCH_SNAPDRAGON=y
+CONFIG_TARGET_DRAGONBOARD410C=y
+
+CONFIG_SYS_PROMPT="dragonboard410c => "
+CONFIG_CMD_USB=y
+# CONFIG_CMD_IMI is not set
+# CONFIG_CMD_IMLS is not set
+CONFIG_DEFAULT_DEVICE_TREE="dragonboard410c"
+
+CONFIG_CLK=y
+CONFIG_MSM_GPIO=y
+CONFIG_PM8916_GPIO=y
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
+CONFIG_RESET=y
+CONFIG_DM_MMC=y
+CONFIG_MSM_SDHCI=y
+CONFIG_DM_PMIC=y
+CONFIG_PMIC_PM8916=y
+CONFIG_SPMI=y
+CONFIG_SPMI_MSM=y
+CONFIG_MSM_SERIAL=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_MSM=y
+CONFIG_USB_ULPI=y
+CONFIG_USB_ULPI_VIEWPORT=y
+CONFIG_USB_STORAGE=y
include/configs/dragonboard410c.h new file +153 -0

153 lines not on this page · raw message

Signature · 1 line
2.5.0
#32 lore raw

PATCH v2 17/18 board: Add Qualcomm Dragonboard 410C support

Quoted 23 lines · Mateusz Kulikowski

U-Boot boots chained with fastboot in 64-bit mode.

board/qualcomm/dragonboard410c/head.S new file +18 -0
@@ -0,0 +1,28 @@
+/*
+ * Little-Kernel/Fastboot header for proper chain-loading
+ *
+ * (C) Copyright 2015 Mateusz Kulikowski <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <config.h>
+
+.global _fastboot_header
+_fastboot_header:
+	b _start
+	add     x13, x18, #0x16
+	/* Image load offset from start of RAM, little-endian */
+	.quad   CONFIG_SYS_TEXT_BASE-PHYS_SDRAM_1
+	/* Effective size of kernel image, little-endian */
+	.quad   0 /* 0x60000 */

board/qualcomm/dragonboard410c/head.S line 28

Quoted 10 lines
board/qualcomm/dragonboard410c/head.S new file +10 -0
+	/* Informative flags, little-endian */
+	.quad   0
+	.quad   0                               /* reserved */
+	.quad   0                               /* reserved */
+	.quad   0                               /* reserved */
+	.byte   0x41                            /* Magic number, "ARM\x64" */
+	.byte   0x52
+	.byte   0x4d
+	.byte   0x64
+	.word   0                               /* reserved */

I don't think fastboot is the correct term to use here. The structure in head.S is the ARM64 Linux kernel header described in section 4 of this
document: https://www.kernel.org/doc/Documentation/arm64/booting.txt
Fastboot is AFAIK a USB protocol spoken by bootloaders used on Android devices. Little Kernel can do fastboot, but it doesn't do it to run this image.

It is also confusing to have the "add" instruction in there without an explanation, especially because having it at offset 4 instead of 0 defeats its original purpose (MZ EXE signature for EFI).

Quoted 5 lines

+6) generate qualcomm device tree, use dtbTool to generate it
+$ dtbTool -o dt.img arch/arm/dts
+
+7) generate image with mkbootimg:
+$ mkbootimg --kernel=u-boot-dtb.bin --output=u-boot.img --dt=dt.img --pagesize 2048 --base 0x80000000 --ramdisk=rd --cmdline=""

I would have liked a bit more text about what is done with the device trees here. Little Kernel refuses to run the "kernel" unless it can find a device tree matching the hardware it is running on. It adds some information to the device tree and passes it to the kernel in the x0 register. U-Boot discards the contents of the x0 register and uses the device tree appended to its image. So there is no need to point dtbTool to the same dtb file used by U-Boot. A smaller one containing only the IDs checked by Little Kernel would be enough. And dtbTool does not generate a device tree, it generates the Qualcomm device tree table containing all dtb files in the directory.

I know the goal is to eventually replace Little Kernel, but how about using the device tree passed by it? We could add some code to head.S that saves x0 in sp_el0 and abuse CONFIG_OF_HOSTFILE to retrieve it.

Best regards,

Daniel

Signature · 7 lines
Dipl.-Math. Daniel Gl?ckner, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11,
Bertha-von-Suttner-Stra?e 9, 37085 G?ttingen, Germany
Sitz der Gesellschaft: G?ttingen, Amtsgericht G?ttingen HR B 3160
Gesch?ftsf?hrung: Dr. Uwe Kracke, Ust-IdNr.: DE 205 198 055

emlix - your embedded linux partner
#33 lore raw

PATCH v2 17/18 board: Add Qualcomm Dragonboard 410C support

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi Daniel,

Thanks for the hints!

Quoted 1 line · Daniel Gl?ckner

On Sun, Feb 07, 2016 at 09:57:37PM +0100, Mateusz Kulikowski wrote:

[...]

Quoted 17 lines
Quoted 17 lines

+.global _fastboot_header

board/qualcomm/dragonboard410c/head.S new file +16 -0
+_fastboot_header:
+	b _start
+	add     x13, x18, #0x16
+	/* Image load offset from start of RAM, little-endian */
+	.quad   CONFIG_SYS_TEXT_BASE-PHYS_SDRAM_1
+	/* Effective size of kernel image, little-endian */
+	.quad   0 /* 0x60000 */
+	/* Informative flags, little-endian */
+	.quad   0
+	.quad   0                               /* reserved */
+	.quad   0                               /* reserved */
+	.quad   0                               /* reserved */
+	.byte   0x41                            /* Magic number, "ARM\x64" */
+	.byte   0x52
+	.byte   0x4d
+	.byte   0x64
Quoted 8 lines

board/qualcomm/dragonboard410c/head.S line 28

Quoted 1 line
board/qualcomm/dragonboard410c/head.S new file +1 -0
+	.word   0                               /* reserved */

I don't think fastboot is the correct term to use here. The structure in head.S is the ARM64 Linux kernel header described in section 4 of this
document: https://www.kernel.org/doc/Documentation/arm64/booting.txt
Fastboot is AFAIK a USB protocol spoken by bootloaders used on Android devices. Little Kernel can do fastboot, but it doesn't do it to run this image.

Good point, in that case I'll just rename it to arm64_header :)

Quoted 4 lines

It is also confusing to have the "add" instruction in there without an explanation, especially because having it at offset 4 instead of 0 defeats its original purpose (MZ EXE signature for EFI).

My bad, I should have put it the other way around:
add x13, x18, #0x16,
b _start

Will do that for v3

Quoted 7 lines
Quoted 6 lines

+6) generate qualcomm device tree, use dtbTool to generate it
+$ dtbTool -o dt.img arch/arm/dts
+
+7) generate image with mkbootimg:
+$ mkbootimg --kernel=u-boot-dtb.bin --output=u-boot.img --dt=dt.img --pagesize 2048 --base 0x80000000 --ramdisk=rd --cmdline=""

Quoted 10 lines

I would have liked a bit more text about what is done with the device trees here. Little Kernel refuses to run the "kernel" unless it can find a device tree matching the hardware it is running on. It adds some information to the device tree and passes it to the kernel in the x0 register. U-Boot discards the contents of the x0 register and uses the device tree appended to its image. So there is no need to point dtbTool to the same dtb file used by U-Boot. A smaller one containing only the IDs checked by Little Kernel would be enough. And dtbTool does not generate a device tree, it generates the Qualcomm device tree table containing all dtb files in the directory.

I'll clarify readme, thanks for verbose explanation.
I know (almost) empty dtb is enough (I use it personally), but I didn't wanted to pollute dts directory with fake device trees.

Quoted 3 lines

I know the goal is to eventually replace Little Kernel, but how about using the device tree passed by it? We could add some code to head.S that saves x0 in sp_el0 and abuse CONFIG_OF_HOSTFILE to retrieve it.

I prefer not to (at least for now) - It will not give us significant benefits (image will be a bit smaller and boot slightly faster, but it's not an issue as U-Boot replaces huge kernel image) and will just confuse people that already are using it. Is it fine with you?

Regards,
Mateusz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJW5IZ7AAoJELvtohmVtQzBjj0IAJMwf9zutegyq5bmzG5ZYYJW dcdqRUXXDDV5IocWDxYK1BGALoFocxxqkRaimwT04r+0ZZ4SsLKXnmKkGJcwSE6p VfWW3aXG437VlVTDwyo8idSRESrFXkjtdrke+4xDQxoFWlCfUifKJJ53NYH2AzYt lj/ZDvuGikAJPDN27DeITlJVqq1OXcOTXfJbooIMGqTFbt/R8bZb1dIP/wF6GobS OqivQcMPh12pKped7Ym1kWMWJ01CWiauePjSK4xRJyAvZUjbvzke/8joBcpHDpaw IGMR5g1RNN6d9flV/W25Ryzrz5XS9M5+ikqucBnSkQD/POnvhHKOkPL9SdMHeYY= =zhqu
-----END PGP SIGNATURE-----

#34 lore raw

PATCH v2 17/18 board: Add Qualcomm Dragonboard 410C support

Quoted 10 lines · Mateusz Kulikowski
Quoted 3 lines · Daniel Gl?ckner

It is also confusing to have the "add" instruction in there without an explanation, especially because having it at offset 4 instead of 0 defeats its original purpose (MZ EXE signature for EFI).

My bad, I should have put it the other way around:
add x13, x18, #0x16,
b _start

Will do that for v3

The Dragonboard doesn't have an EFI BIOS, so we don't need that signature. I'd replace it with a ".long 0" (after the branch instruction of course), as it is done in Linux when CONFIG_EFI is not defined.

Quoted 8 lines
Quoted 3 lines

I know the goal is to eventually replace Little Kernel, but how about using the device tree passed by it? We could add some code to head.S that saves x0 in sp_el0 and abuse CONFIG_OF_HOSTFILE to retrieve it.

I prefer not to (at least for now) - It will not give us significant benefits (image will be a bit smaller and boot slightly faster, but it's not an issue as U-Boot replaces huge kernel image) and will just confuse people that already are using it. Is it fine with you?

No need to ask me. I'm not a regular on this list.

Best regards,

Daniel

Signature · 7 lines
Dipl.-Math. Daniel Gl?ckner, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11,
Bertha-von-Suttner-Stra?e 9, 37085 G?ttingen, Germany
Sitz der Gesellschaft: G?ttingen, Amtsgericht G?ttingen HR B 3160
Gesch?ftsf?hrung: Dr. Uwe Kracke, Ust-IdNr.: DE 205 198 055

emlix - your embedded linux partner
#35 lore raw

PATCH v2 18/18 Add myself as Snapdragon and SPMI maintainer

In reply to Mateusz Kulikowski

- Update MAINTAINERS
- Update git-mailrc

---

Changes in v3: None
Changes in v2:
- New patch

Changes in v1: None

 MAINTAINERS    | 11 +++++++++++
 doc/git-mailrc |  3 +++
 2 files changed, 14 insertions(+)
MAINTAINERS +11 -0
index b387207..56a0eba 100644
@@ -125,6 +125,11 @@ F:	arch/arm/mach-s5pc1xx/
 F:	arch/arm/cpu/armv7/s5p-common/
 F:	arch/arm/include/asm/arch-s3c24x0/
 
+ARM SNAPDRAGON
+M:	Mateusz Kulikowski <[email protected]>
+S:	Maintained
+F:	arch/arm/mach-snapdragon/
+
 ARM STM SPEAR
 M:	Vipin Kumar <[email protected]>
 S:	Maintained
@@ -389,6 +394,12 @@ F:	drivers/mtd/spi/
 F:	drivers/spi/
 F:	include/spi*
 
+SPMI
+M:	Mateusz Kulikowski <[email protected]>
+S:	Maintained
+F:	drivers/spmi/
+F:	include/spmi/
+
 TQ GROUP
 M:	Martin Krause <[email protected]>
 S:	Maintained
doc/git-mailrc +3 -0
index ced7085..1201d4a 100644
@@ -33,6 +33,7 @@ alias lukma          Lukasz Majewski <[email protected]>
 alias macpaul        Macpaul Lin <[email protected]>
 alias marex          Marek Vasut <[email protected]>
 alias masahiro       Masahiro Yamada <[email protected]>
+alias mateusz        Mateusz Kulikowski <[email protected]>
 alias monstr         Michal Simek <[email protected]>
 alias panto          Pantelis Antoniou <[email protected]>
 alias prafulla       Prafulla Wadaskar <[email protected]>
@@ -67,6 +68,7 @@ alias rmobile        uboot, iwamatsu
 alias s3c            samsung
 alias s5pc           samsung
 alias samsung        uboot, prom
+alias snapdragon     uboot, mateusz
 alias socfpga        uboot, marex, Dinh Nguyen <[email protected]>
 alias sunxi          uboot, ijc, jwrdegoede
 alias tegra          uboot, sjg, Tom Warren <[email protected]>, Stephen Warren <[email protected]>
@@ -127,6 +129,7 @@ alias nand           uboot, scottwood
 alias net            uboot, jhersh
 alias phy            uboot, jhersh
 alias spi            uboot, jagan
+alias spmi           uboot, mateusz
 alias ubi            uboot, hs
 alias usb            uboot, marex
 alias video          uboot, ag
Signature · 1 line
2.5.0
#36 lore raw

v2 cover Add support for 96boards Dragonboard410C board

In reply to Mateusz Kulikowski
Quoted 4 lines · Mateusz Kulikowski

Hi All,

This is (hopefully) last version of Dragonboard410c series.

Quoted 8 lines

As always - for "simplicity" this series is available on my github:
https://github.com/hallor/u-boot/tree/dragonboard-for-mainline-v3

There are almost no changes (none that should break anything):
- Updated dragonboard readme.txt with info on how to stop @ fastboot
- Added SPMI entries into test.dts (so automatic DM tests would not fail)
- Added Tested-by and Reviewed-by Simon (from v2 comments)
- Rebased to recent master

Please note that I see a lot of warnings when building this both with gcc-5 and gcc-4.9, please fix. 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/20160224/571a0831/attachment.sig>
#37 lore raw

v2 cover Add support for 96boards Dragonboard410C board

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi Tom,

I finally was able to do some coding and so:

Quoted 1 line · Tom Rini

On Sun, Feb 07, 2016 at 09:57:20PM +0100, Mateusz Kulikowski wrote:

[...]

Quoted 5 lines
Quoted 1 line

- Rebased to recent master

Please note that I see a lot of warnings when building this both with gcc-5 and gcc-4.9, please fix. Thanks!

For v3 I've created 3 patches that fix asix and ULPI warnings.

It was easier than I was afraid :)

I will post it soon (tm).

Regards,
Mateusz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJW21yKAAoJELvtohmVtQzBZ5sH/iMISpeCogU0CDbxfGU1lMMN R8RypqqLYnKnOoeMM3KZMiDCIUkqa2chBNUnJc6huAWfg+2ZoodCQcDhCv5akwhS R52XHWyLXsNISZOq2STczLpPKgJyKqUH0ymtOHfuMKIYXeX8QWTbasFglaLoyNgg 8ugpq0XcqfsQMFdjx6qJ6SXw0+7Xef+dGoMHYW+7nduOqBSDVCz9q1uRgTE92Exh hKu81QN/Byy5sFY9lqfy96WSeGqsJX4H3jy/SijmauXRVrYzAZ/kebEYQnCCBUdS QiVr2BltTriG++h/LfbIrWhmdgJwMQW6Ul+QWk9Tc3L+yGMGMAPPk+FW7tEgbEI= =INFx
-----END PGP SIGNATURE-----