Add support for Samsung Galaxy S4 Mini Value Edition
Subsystems (6)
v2 cover Add support for Samsung Galaxy S4 Mini Value Edition
This series adds support for booting mainline Linux on the Samsung Galaxy S4 Mini Value Edition. The device is based on the Qualcomm MSM8916 SoC and quite similar to the already supported Samsung Galaxy A3/A5. With some additional patches it is almost fully functional, including display, touch screen, GPU, audio, modem (voice calls, SMS, mobile data) and sensors.
I made most of the patches almost 2 years ago but I was long unsure if I should submit them upstream. This is because the device has one big limitation:
Samsung released it with a signed 32-bit-only TrustZone firmware which is not able to boot ARM64 Linux. This means the device can actually only boot ARM32.
However, since device trees are independent of the kernel architecture and all the necessary drivers compile on ARM32 as well it is actually extremely straightforward to build an ARM32 kernel for MSM8916 (which is normally arm64).
The only necessary additions are for SMP/cpuidle without PSCI on ARM32. However, the diffstat below makes it quite obvious that the maintenance overhead for this is absolutely negligible. The SoC is almost identical to previous 32-bit SoCs like MSM8226, so it is pretty much just adding new definitions/compatibles for already existing code.
Being able to boot ARM32 Linux on MSM8916 might be also a possible opportunity for CI systems. At the moment, 32-bit Qualcomm platforms are not very well represented there. Booting ARM32 on MSM8916/APQ8016 would allow re-using the DragonBoard 410c which is often already used for automated CI testing.
Changes in v2:
- Add missing word in a comment in PATCH 1/15
- Clarify ARM32 situation in dt-bindings patches
v1: https://lore.kernel.org/phone-devel/[email protected]/
Lina Iyer (1):
soc: qcom: spm: Add 8916 SPM register data
Stephan Gerhold (14):
arm64: dts: qcom: Add device tree for Samsung Galaxy S4 Mini Value
Edition
arm64: dts: qcom: msm8916-samsung-serranove: Add touch screen
arm64: dts: qcom: msm8916-samsung-serranove: Add touch key
arm64: dts: qcom: msm8916-samsung-serranove: Add IMU
arm64: dts: qcom: msm8916-samsung-serranove: Add rt5033 battery
arm64: dts: qcom: msm8916-samsung-serranove: Add NFC
ARM: qcom: Add ARCH_MSM8916 for MSM8916 on ARM32
dt-bindings: arm: cpus: Document qcom,msm8916-smp enable-method
ARM: qcom: Add qcom,msm8916-smp enable-method identical to MSM8226
dt-bindings: soc: qcom: spm: Document qcom,msm8916-saw2-v3.0-cpu
firmware: qcom: scm: Add support for MC boot address API
arm64: dts: qcom: msm8916: Add CPU ACC and SAW/SPM
ARM: dts: qcom: msm8916: Add include for SMP without PSCI on ARM32
ARM: dts: qcom: msm8916-samsung-serranove: Include dts from arm64
.../devicetree/bindings/arm/cpus.yaml | 5 +- .../bindings/soc/qcom/qcom,spm.yaml | 1 + arch/arm/boot/dts/Makefile | 1 + .../dts/qcom-msm8916-samsung-serranove.dts | 3 + arch/arm/boot/dts/qcom-msm8916-smp.dtsi | 62 ++ arch/arm/mach-qcom/Kconfig | 10 + arch/arm/mach-qcom/platsmp.c | 1 + arch/arm64/boot/dts/qcom/Makefile | 1 + .../dts/qcom/msm8916-samsung-serranove.dts | 534 ++++++++++++++++++ arch/arm64/boot/dts/qcom/msm8916.dtsi | 56 ++ drivers/firmware/qcom_scm.c | 84 ++- drivers/firmware/qcom_scm.h | 4 + drivers/soc/qcom/spm.c | 21 + 13 files changed, 765 insertions(+), 18 deletions(-) create mode 100644 arch/arm/boot/dts/qcom-msm8916-samsung-serranove.dts create mode 100644 arch/arm/boot/dts/qcom-msm8916-smp.dtsi create mode 100644 arch/arm64/boot/dts/qcom/msm8916-samsung-serranove.dts
Signature · 1 line
2.33.0
PATCH v2 1/15 arm64: dts: qcom: Add device tree for Samsung Galaxy S4 Mini Value Edition
The Samsung Galaxy S4 Mini Value Edition is an updated version of the original S4 Mini based on MSM8916. It is similar to the other Samsung devices based on MSM8916 with only a few minor differences.
The device tree contains initial support for the S4 Mini Value Edition with:
- UART
- eMMC/SD card (needs quirk for some reason)
- Buttons
- Vibrator
- WiFi/Bluetooth (WCNSS)
- USB
Unfortunately, the S4 Mini VE was released with outdated 32-bit only firmware and never received any update from Samsung. Since the 32-bit TrustZone firmware is signed there seems to be no way currently to actually boot this device tree on arm64 Linux at the moment. :(
However, it is possible to use this device tree by compiling an ARM32 kernel instead. The device tree can be easily built on ARM32 with an #include and it works really well there. To avoid confusion for others it is still better to add this device tree on arm64. Otherwise it's easy to forget to update this one when making some changes that affect all MSM8916 devices.
Maybe someone finds a way to boot ARM64 Linux on this device at some point. In this case I expect that this device tree can be simply used as-is.
---
Changes in v2:
- Add missing word in "FIXME: Disable UHS-I modes" comment
--- arch/arm64/boot/dts/qcom/Makefile | 1 + .../dts/qcom/msm8916-samsung-serranove.dts | 301 ++++++++++++++++++ 2 files changed, 302 insertions(+) create mode 100644 arch/arm64/boot/dts/qcom/msm8916-samsung-serranove.dts
arch/arm64/boot/dts/qcom/Makefile +1 -0
@@ -15,6 +15,7 @@ dtb-$(CONFIG_ARCH_QCOM) += msm8916-longcheer-l8910.dtb dtb-$(CONFIG_ARCH_QCOM) += msm8916-mtp.dtb dtb-$(CONFIG_ARCH_QCOM) += msm8916-samsung-a3u-eur.dtb dtb-$(CONFIG_ARCH_QCOM) += msm8916-samsung-a5u-eur.dtb +dtb-$(CONFIG_ARCH_QCOM) += msm8916-samsung-serranove.dtb dtb-$(CONFIG_ARCH_QCOM) += msm8916-wingtech-wt88047.dtb dtb-$(CONFIG_ARCH_QCOM) += msm8992-bullhead-rev-101.dtb dtb-$(CONFIG_ARCH_QCOM) += msm8992-msft-lumia-octagon-talkman.dtb
arch/arm64/boot/dts/qcom/msm8916-samsung-serranove.dts new file +301 -0
301 lines not on this page · raw message
Signature · 1 line
2.33.0
PATCH v2 2/15 arm64: dts: qcom: msm8916-samsung-serranove: Add touch screen
In reply to Stephan GerholdLike msm8916-samsung-a3u-eur, the S4 Mini VE uses a Zinitix BT541 touch screen. Add it together with the necessary fixed-regulator to the device tree.
---
Changes in v2: None.
--- .../dts/qcom/msm8916-samsung-serranove.dts | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+)
arch/arm64/boot/dts/qcom/msm8916-samsung-serranove.dts +50 -0
@@ -78,6 +78,19 @@ hall-sensor { }; }; + reg_vdd_tsp: regulator-vdd-tsp { + compatible = "regulator-fixed"; + regulator-name = "vdd_tsp"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + + gpio = <&msmgpio 73 GPIO_ACTIVE_HIGH>; + enable-active-high; + + pinctrl-names = "default"; + pinctrl-0 = <&tsp_en_default>; + }; + i2c-muic { compatible = "i2c-gpio"; sda-gpios = <&msmgpio 105 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
@@ -102,6 +115,27 @@ muic: extcon@14 { }; }; +&blsp_i2c5 { + status = "okay"; + + touchscreen@20 { + compatible = "zinitix,bt541"; + reg = <0x20>; + + interrupt-parent = <&msmgpio>; + interrupts = <13 IRQ_TYPE_EDGE_FALLING>; + + touchscreen-size-x = <540>; + touchscreen-size-y = <960>; + + vdd-supply = <®_vdd_tsp>; + vddo-supply = <&pm8916_l6>; + + pinctrl-names = "default"; + pinctrl-0 = <&tsp_irq_default>; + }; +}; + &blsp1_uart2 { status = "okay"; };
@@ -298,4 +332,20 @@ muic_irq_default: muic-irq-default { drive-strength = <2>; bias-disable; }; + + tsp_en_default: tsp-en-default { + pins = "gpio73"; + function = "gpio"; + + drive-strength = <2>; + bias-disable; + }; + + tsp_irq_default: tsp-irq-default { + pins = "gpio13"; + function = "gpio"; + + drive-strength = <2>; + bias-disable; + }; };
Signature · 1 line
2.33.0
PATCH v2 3/15 arm64: dts: qcom: msm8916-samsung-serranove: Add touch key
In reply to Stephan GerholdAdd the CORERIVER TC360 touch key together with the two necessary fixed regulators for it.
Note that for some reason Samsung decided to connect this to GPIOs where no hardware I2C bus is available, so we need to fall back to software bit-banging using i2c-gpio.
---
Changes in v2: None.
--- .../dts/qcom/msm8916-samsung-serranove.dts | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+)
arch/arm64/boot/dts/qcom/msm8916-samsung-serranove.dts +87 -0
@@ -91,6 +91,32 @@ reg_vdd_tsp: regulator-vdd-tsp { pinctrl-0 = <&tsp_en_default>; }; + reg_touch_key: regulator-touch-key { + compatible = "regulator-fixed"; + regulator-name = "touch_key"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + + gpio = <&msmgpio 86 GPIO_ACTIVE_HIGH>; + enable-active-high; + + pinctrl-names = "default"; + pinctrl-0 = <&tkey_en_default>; + }; + + reg_key_led: regulator-key-led { + compatible = "regulator-fixed"; + regulator-name = "key_led"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + + gpio = <&msmgpio 60 GPIO_ACTIVE_HIGH>; + enable-active-high; + + pinctrl-names = "default"; + pinctrl-0 = <&tkey_led_en_default>; + }; + i2c-muic { compatible = "i2c-gpio"; sda-gpios = <&msmgpio 105 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
@@ -113,6 +139,35 @@ muic: extcon@14 { pinctrl-0 = <&muic_irq_default>; }; }; + + i2c-tkey { + compatible = "i2c-gpio"; + sda-gpios = <&msmgpio 16 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; + scl-gpios = <&msmgpio 17 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; + + pinctrl-names = "default"; + pinctrl-0 = <&tkey_i2c_default>; + + #address-cells = <1>; + #size-cells = <0>; + + touchkey@20 { + compatible = "coreriver,tc360-touchkey"; + reg = <0x20>; + + interrupt-parent = <&msmgpio>; + interrupts = <98 IRQ_TYPE_EDGE_FALLING>; + + vcc-supply = <®_touch_key>; + vdd-supply = <®_key_led>; + vddio-supply = <&pm8916_l6>; + + linux,keycodes = <KEY_APPSELECT KEY_BACK>; + + pinctrl-names = "default"; + pinctrl-0 = <&tkey_default>; + }; + }; }; &blsp_i2c5 {
@@ -333,6 +388,38 @@ muic_irq_default: muic-irq-default { bias-disable; }; + tkey_default: tkey-default { + pins = "gpio98"; + function = "gpio"; + + drive-strength = <2>; + bias-disable; + }; + + tkey_en_default: tkey-en-default { + pins = "gpio86"; + function = "gpio"; + + drive-strength = <2>; + bias-disable; + }; + + tkey_i2c_default: tkey-i2c-default { + pins = "gpio16", "gpio17"; + function = "gpio"; + + drive-strength = <2>; + bias-disable; + }; + + tkey_led_en_default: tkey-led-en-default { + pins = "gpio60"; + function = "gpio"; + + drive-strength = <2>; + bias-disable; + }; + tsp_en_default: tsp-en-default { pins = "gpio73"; function = "gpio";
Signature · 1 line
2.33.0
PATCH v2 4/15 arm64: dts: qcom: msm8916-samsung-serranove: Add IMU
In reply to Stephan GerholdAdd the STMicroelectronics LSM6DS3 IMU that is used in the S4 Mini VE to the device tree.
---
Changes in v2: None.
--- .../dts/qcom/msm8916-samsung-serranove.dts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+)
arch/arm64/boot/dts/qcom/msm8916-samsung-serranove.dts +23 -0
@@ -170,6 +170,21 @@ touchkey@20 { }; }; +&blsp_i2c2 { + status = "okay"; + + imu@6b { + compatible = "st,lsm6ds3"; + reg = <0x6b>; + + interrupt-parent = <&msmgpio>; + interrupts = <115 IRQ_TYPE_EDGE_RISING>; + + pinctrl-names = "default"; + pinctrl-0 = <&imu_irq_default>; + }; +}; + &blsp_i2c5 { status = "okay";
@@ -372,6 +387,14 @@ gpio_hall_sensor_default: gpio-hall-sensor-default { bias-disable; }; + imu_irq_default: imu-irq-default { + pins = "gpio115"; + function = "gpio"; + + drive-strength = <2>; + bias-disable; + }; + muic_i2c_default: muic-i2c-default { pins = "gpio105", "gpio106"; function = "gpio";
Signature · 1 line
2.33.0
PATCH v2 5/15 arm64: dts: qcom: msm8916-samsung-serranove: Add rt5033 battery
In reply to Stephan GerholdLike the Samsung Galaxy A3/A5, the S4 Mini VE uses a Richtek RT5033 PMIC as battery fuel gauge, charger, flash LED and for some regulators. For now, only add the fuel gauge/battery device to the device tree, so we can check the remaining battery percentage.
The other RT5033 drivers need some more work first before they can be used properly.
---
Changes in v2: None.
--- .../dts/qcom/msm8916-samsung-serranove.dts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+)
arch/arm64/boot/dts/qcom/msm8916-samsung-serranove.dts +23 -0
@@ -185,6 +185,21 @@ imu@6b { }; }; +&blsp_i2c4 { + status = "okay"; + + battery@35 { + compatible = "richtek,rt5033-battery"; + reg = <0x35>; + + interrupt-parent = <&msmgpio>; + interrupts = <121 IRQ_TYPE_EDGE_FALLING>; + + pinctrl-names = "default"; + pinctrl-0 = <&fg_alert_default>; + }; +}; + &blsp_i2c5 { status = "okay";
@@ -371,6 +386,14 @@ l18 { }; &msmgpio { + fg_alert_default: fg-alert-default { + pins = "gpio121"; + function = "gpio"; + + drive-strength = <2>; + bias-disable; + }; + gpio_keys_default: gpio-keys-default { pins = "gpio107", "gpio109"; function = "gpio";
Signature · 1 line
2.33.0
PATCH v2 6/15 arm64: dts: qcom: msm8916-samsung-serranove: Add NFC
In reply to Stephan GerholdThe LTE version of the S4 Mini VE has a NXP PN547, which is supported by the nxp-nci-i2c driver in mainline. It seems to detect NFC tags using "nfctool" just fine, although more testing is difficult given there seem to be very few useful applications making use of the Linux NFC subsystem. :(
Note that for some reason Samsung decided to connect the I2C pins to GPIOs where no hardware I2C bus is available, so we need to fall back to software bit-banging with i2c-gpio.
---
Changes in v2: None.
--- .../dts/qcom/msm8916-samsung-serranove.dts | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+)
arch/arm64/boot/dts/qcom/msm8916-samsung-serranove.dts +50 -0
@@ -168,6 +168,32 @@ touchkey@20 { pinctrl-0 = <&tkey_default>; }; }; + + i2c-nfc { + compatible = "i2c-gpio"; + sda-gpios = <&msmgpio 0 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; + scl-gpios = <&msmgpio 1 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>; + + pinctrl-names = "default"; + pinctrl-0 = <&nfc_i2c_default>; + + #address-cells = <1>; + #size-cells = <0>; + + nfc@2b { + compatible = "nxp,pn547", "nxp,nxp-nci-i2c"; + reg = <0x2b>; + + interrupt-parent = <&msmgpio>; + interrupts = <21 IRQ_TYPE_EDGE_RISING>; + + enable-gpios = <&msmgpio 20 GPIO_ACTIVE_HIGH>; + firmware-gpios = <&msmgpio 49 GPIO_ACTIVE_HIGH>; + + pinctrl-names = "default"; + pinctrl-0 = <&nfc_default>; + }; + }; }; &blsp_i2c2 {
@@ -434,6 +460,30 @@ muic_irq_default: muic-irq-default { bias-disable; }; + nfc_default: nfc-default { + pins = "gpio20", "gpio49"; + function = "gpio"; + + drive-strength = <2>; + bias-disable; + + irq { + pins = "gpio21"; + function = "gpio"; + + drive-strength = <2>; + bias-pull-down; + }; + }; + + nfc_i2c_default: nfc-i2c-default { + pins = "gpio0", "gpio1"; + function = "gpio"; + + drive-strength = <2>; + bias-disable; + }; + tkey_default: tkey-default { pins = "gpio98"; function = "gpio";
Signature · 1 line
2.33.0
PATCH v2 7/15 ARM: qcom: Add ARCH_MSM8916 for MSM8916 on ARM32
In reply to Stephan GerholdAdd a CONFIG_ARCH_MSM8916 option to enable building MSM8916 support on ARM32. Note that since ARM64 is the main supported architecture for MSM8916 this is only intended for testing and for devices where signed firmware does not allow booting ARM64 kernels.
---
Changes in v2: Simplify wording a bit
--- arch/arm/mach-qcom/Kconfig | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm/mach-qcom/Kconfig +10 -0
@@ -21,6 +21,16 @@ config ARCH_MSM8X60 bool "Enable support for MSM8X60" select CLKSRC_QCOM +config ARCH_MSM8916 + bool "Enable support for MSM8916" + select HAVE_ARM_ARCH_TIMER + help + Enable support for the Qualcomm Snapdragon 410 (MSM8916/APQ8016). + + Note that ARM64 is the main supported architecture for MSM8916. + The ARM32 option is intended for a few devices with signed firmware + that does not allow booting ARM64 kernels. + config ARCH_MSM8960 bool "Enable support for MSM8960" select CLKSRC_QCOM
Signature · 1 line
2.33.0
PATCH v2 8/15 dt-bindings: arm: cpus: Document qcom, msm8916-smp enable-method
In reply to Stephan GerholdSince MSM8916 is an ARM v8 64-bit SoC the CPU cores are normally booted using "psci" or "spin-table". Unfortunately, some devices come with signed 32-bit-only firmware without ARM64 and PSCI support. This setup is easy to support since it's very similar to older 32-bit only Qualcomm SoCs (e.g. MSM8226) and only requires adding a few new definitions to already existing drivers.
Document the qcom,msm8916-smp enable-method. It is actually just an alias of qcom,msm8226-smp since it should be implemented identically. The enable-method is only valid on ARM32 and must not be used on ARM64.
---
Changes in v2:
- Clarify that this is only supposed to be used on ARM 32-bit (Add comment to commit message and DT schema)
The "see above for ARM v8 64-bit" comment refers to this a few lines above in the DT schema:
# On ARM v8 64-bit this property is required
- enum:
- psci
- spin-table
--- Documentation/devicetree/bindings/arm/cpus.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/cpus.yaml +4 -1
@@ -211,6 +211,8 @@ properties: - qcom,kpss-acc-v1 - qcom,kpss-acc-v2 - qcom,msm8226-smp + # Only valid on ARM 32-bit, see above for ARM v8 64-bit + - qcom,msm8916-smp - renesas,apmu - renesas,r9a06g032-smp - rockchip,rk3036-smp
@@ -295,7 +297,8 @@ properties: Specifies the ACC* node associated with this CPU. Required for systems that have an "enable-method" property - value of "qcom,kpss-acc-v1", "qcom,kpss-acc-v2" or "qcom,msm8226-smp" + value of "qcom,kpss-acc-v1", "qcom,kpss-acc-v2", "qcom,msm8226-smp" + or "qcom,msm8916-smp". * arm/msm/qcom,kpss-acc.txt
Signature · 1 line
2.33.0
Re: [PATCH v2 08/15] dt-bindings: arm: cpus: Document qcom,msm8916-smp enable-method
Quoted 20 lines · Stephan Gerhold
Since MSM8916 is an ARM v8 64-bit SoC the CPU cores are normally booted using "psci" or "spin-table". Unfortunately, some devices come with signed 32-bit-only firmware without ARM64 and PSCI support. This setup is easy to support since it's very similar to older 32-bit only Qualcomm SoCs (e.g. MSM8226) and only requires adding a few new definitions to already existing drivers.
Document the qcom,msm8916-smp enable-method. It is actually just an alias of qcom,msm8226-smp since it should be implemented identically. The enable-method is only valid on ARM32 and must not be used on ARM64.
Signed-off-by Stephan Gerhold <[email protected]>---
Changes in v2:
- Clarify that this is only supposed to be used on ARM 32-bit (Add comment to commit message and DT schema)The "see above for ARM v8 64-bit" comment refers to this a few lines above in the DT schema:
Quoted 8 lines
# On ARM v8 64-bit this property is required
- enum:
- psci
- spin-table--- Documentation/devicetree/bindings/arm/cpus.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
PATCH v2 9/15 ARM: qcom: Add qcom, msm8916-smp enable-method identical to MSM8226
In reply to Stephan GerholdUnfortunately, some MSM8916 devices have signed firmware without ARM64 and PSCI support and can therefore only boot ARM32 Linux. The ARM Cortex-A53 cores should be actually booted exactly like the Cortex-A7 cores on MSM8226, so just add an alias for the existing code.
---
Changes in v2: Clarify commit message very slightly
--- arch/arm/mach-qcom/platsmp.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-qcom/platsmp.c +1 -0
@@ -385,6 +385,7 @@ static const struct smp_operations qcom_smp_cortex_a7_ops __initconst = {#endif };CPU_METHOD_OF_DECLARE (qcom_smp_msm8226,"qcom,msm8226-smp" , &qcom_smp_cortex_a7_ops); +CPU_METHOD_OF_DECLARE (qcom_smp_msm8916,"qcom,msm8916-smp" , &qcom_smp_cortex_a7_ops);static const struct smp_operations qcom_smp_kpssv1_ops__initconst = { .smp_prepare_cpus = qcom_smp_prepare_cpus,
Signature · 1 line
2.33.0
PATCH v2 10/15 dt-bindings: soc: qcom: spm: Document qcom, msm8916-saw2-v3.0-cpu
In reply to Stephan GerholdDocument the qcom,msm8916-saw2-v3.0-cpu compatible that is needed for cpuidle for MSM8916 on some devices with signed firmware which is only capable of booting ARM32 kernels without PSCI.
---
Changes in v2: Add Rob's Acked-by
--- Documentation/devicetree/bindings/soc/qcom/qcom,spm.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/soc/qcom/qcom,spm.yaml +1 -0
@@ -22,6 +22,7 @@ properties: - qcom,sdm660-silver-saw2-v4.1-l2 - qcom,msm8998-gold-saw2-v4.1-l2 - qcom,msm8998-silver-saw2-v4.1-l2 + - qcom,msm8916-saw2-v3.0-cpu - qcom,msm8226-saw2-v2.1-cpu - qcom,msm8974-saw2-v2.1-cpu - qcom,apq8084-saw2-v2.1-cpu
Signature · 1 line
2.33.0
PATCH v2 11/15 soc: qcom: spm: Add 8916 SPM register data
In reply to Stephan GerholdFrom: Lina Iyer <[email protected]>
Add SPM register information and initialization values for QCOM 8916 SoC.
---
Changes in v2: None.
Like for qcom,msm8916-smp and qcom,msm8226-smp, this is actually pretty much identical to the MSM8226 configuration except for the new v3.0 register offsets.
--- drivers/soc/qcom/spm.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/soc/qcom/spm.c +21 -0
@@ -67,6 +67,25 @@ static const struct spm_reg_data spm_reg_8998_silver_l2 = { .avs_limit = 0x4200420, }; +static const u16 spm_reg_offset_v3_0[SPM_REG_NR ] = { + [SPM_REG_CFG ] =0x08 , + [SPM_REG_SPM_CTL ] =0x30 , + [SPM_REG_DLY ] =0x34 , + [SPM_REG_SEQ_ENTRY ] =0x400 , +}; + +/* SPM register data for 8916 */ +static const struct spm_reg_data spm_reg_8916_cpu = { + .reg_offset = spm_reg_offset_v3_0, + .spm_cfg =0x1 , + .spm_dly =0x3C102800 , + .seq = {0x60 ,0x03 ,0x60 ,0x0B ,0x0F ,0x20 ,0x10 ,0x80 ,0x30 ,0x90 , +0x5B ,0x60 ,0x03 ,0x60 ,0x3B ,0x76 ,0x76 ,0x0B ,0x94 ,0x5B , +0x80 ,0x10 ,0x26 ,0x30 ,0x0F }, + .start_index[PM_SLEEP_MODE_STBY ] =0 , + .start_index[PM_SLEEP_MODE_SPC ] =5 , +}; +static const u16 spm_reg_offset_v2_1[SPM_REG_NR ] = { [SPM_REG_CFG ] =0x08 , [SPM_REG_SPM_CTL ] =0x30 ,
@@ -176,6 +195,8 @@ static const struct of_device_id spm_match_table[] = { .data = &spm_reg_660_silver_l2 }, { .compatible = "qcom,msm8226-saw2-v2.1-cpu", .data = &spm_reg_8226_cpu }, + { .compatible = "qcom,msm8916-saw2-v3.0-cpu", + .data = &spm_reg_8916_cpu }, { .compatible = "qcom,msm8974-saw2-v2.1-cpu", .data = &spm_reg_8974_8084_cpu }, { .compatible = "qcom,msm8998-gold-saw2-v4.1-l2",
Signature · 1 line
2.33.0
PATCH v2 12/15 firmware: qcom: scm: Add support for MC boot address API
In reply to Stephan GerholdIt looks like the old QCOM_SCM_BOOT_SET_ADDR API is broken on some MSM8916 firmware versions that implement the newer SMC32 calling convention. It just returns -EINVAL no matter which arguments are being passed.
This does not cause any problems downstream because it first tries to use the new multi-cluster API replacement which is working fine.
Implement support for the multi-cluster variant of the SCM call by attempting it first but still fallback to the old call in case of an error. Also, to be absolutely sure only use the multi-cluster variant with the SMC calling convention since older platforms should not need this.
---
Changes in v2: None.
The diff generated by Git is a bit hard to read sadly, what I did essentially is:
1. Add __qcom_scm_set_boot_addr_mc()
2. Rename original qcom_scm_set_cold/warm_boot_addr() to static __qcom_scm_set_cold/warm_boot_addr()
3. Make new qcom_scm_set_cold/warm_boot_addr() call __qcom_scm_set_boot_addr_mc() first and then fall back to the old __qcom_scm_set_cold/warm_boot_addr() as before
--- drivers/firmware/qcom_scm.c | 84 +++++++++++++++++++++++++++++-------- drivers/firmware/qcom_scm.h | 4 ++ 2 files changed, 71 insertions(+), 17 deletions(-)
drivers/firmware/qcom_scm.c +67 -17
@@ -17,6 +17,8 @@#include <linux/reset-controller.h> #include <linux/arm-smccc.h> +#include <asm/smp_plat.h> +#include "qcom_scm.h" static bool download_mode =IS_ENABLED (CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT );
@@ -260,15 +262,36 @@ static bool __qcom_scm_is_call_available(struct device *dev, u32 svc_id,return ret ? false : !!res.result[0 ]; } -/** -* qcom_scm_set_warm_boot_addr() - Set the warm boot address for cpus -* @entry: Entry point function for the cpus -* @cpus: The cpumask of cpus that will use the entry point -* -* Set the Linux entry point for the SCM to transfer control to when coming -* out of a power down. CPU power down may be executed on cpuidle or hotplug. -*/ -int qcom_scm_set_warm_boot_addr (void *entry,const cpumask_t *cpus) +static int __qcom_scm_set_boot_addr_mc (void *entry,const cpumask_t *cpus, +unsigned int flags) +{ +struct qcom_scm_desc desc = { + .svc =QCOM_SCM_SVC_BOOT , + .cmd =QCOM_SCM_BOOT_SET_ADDR_MC , + .owner =ARM_SMCCC_OWNER_SIP , + .arginfo =QCOM_SCM_ARGS (6 ), + }; +unsigned int cpu; +u64 map; + +/* Need a device for DMA of the additional arguments */ +if (!__scm ||__get_convention () ==SMC_CONVENTION_LEGACY ) +return -EOPNOTSUPP ; + + desc.args[0 ] =virt_to_phys (entry); +for_each_cpu (cpu, cpus) { + map =cpu_logical_map (cpu); + desc.args[1 ] |=BIT (MPIDR_AFFINITY_LEVEL (map,0 )); + desc.args[2 ] |=BIT (MPIDR_AFFINITY_LEVEL (map,1 )); + desc.args[3 ] |=BIT (MPIDR_AFFINITY_LEVEL (map,2 )); + } + desc.args[4 ] = ~0ULL ;/* Reserved for affinity level 3 */ + desc.args[5 ] = flags; + +return qcom_scm_call (__scm->dev, &desc,NULL ); +} + +static int __qcom_scm_set_warm_boot_addr (void *entry,const cpumask_t *cpus) {int ret;int flags =0 ;
@@ -304,17 +327,28 @@ int qcom_scm_set_warm_boot_addr(void *entry, const cpumask_t *cpus)return ret; } -EXPORT_SYMBOL (qcom_scm_set_warm_boot_addr);/** -* qcom_scm_set_cold_boot_addr() - Set the cold boot address for cpus +* qcom_scm_set_warm_boot_addr() - Set the warm boot address for cpus * @entry: Entry point function for the cpus * @cpus: The cpumask of cpus that will use the entry point * -* Set the cold boot address of the cpus. Any cpu outside the supported -* range would be removed from the cpu present mask. +* Set the Linux entry point for the SCM to transfer control to when coming +* out of a power down. CPU power down may be executed on cpuidle or hotplug. */ -int qcom_scm_set_cold_boot_addr (void *entry,const cpumask_t *cpus) +int qcom_scm_set_warm_boot_addr (void *entry,const cpumask_t *cpus) +{ +if (!cpus ||cpumask_empty (cpus)) +return -EINVAL ; + +if (__qcom_scm_set_boot_addr_mc (entry, cpus,QCOM_SCM_BOOT_MC_FLAG_WARMBOOT )) +/* Fallback to old SCM call */ +return __qcom_scm_set_warm_boot_addr (entry, cpus); +return 0 ; +} +EXPORT_SYMBOL (qcom_scm_set_warm_boot_addr); + +static int __qcom_scm_set_cold_boot_addr (void *entry,const cpumask_t *cpus) {int flags =0 ;int cpu;
@@ -331,9 +365,6 @@ int qcom_scm_set_cold_boot_addr(void *entry, const cpumask_t *cpus) .owner = ARM_SMCCC_OWNER_SIP, }; -if (!cpus ||cpumask_empty (cpus)) -return -EINVAL ; -for_each_cpu (cpu, cpus) {if (cpu <ARRAY_SIZE (scm_cb_flags)) flags |= scm_cb_flags[cpu];
@@ -346,6 +377,25 @@ int qcom_scm_set_cold_boot_addr(void *entry, const cpumask_t *cpus)return qcom_scm_call_atomic (__scm ? __scm->dev :NULL , &desc,NULL ); } + +/** +* qcom_scm_set_cold_boot_addr() - Set the cold boot address for cpus +* @entry: Entry point function for the cpus +* @cpus: The cpumask of cpus that will use the entry point +* +* Set the cold boot address of the cpus. Any cpu outside the supported +* range would be removed from the cpu present mask. +*/ +int qcom_scm_set_cold_boot_addr (void *entry,const cpumask_t *cpus) +{ +if (!cpus ||cpumask_empty (cpus)) +return -EINVAL ; + +if (__qcom_scm_set_boot_addr_mc (entry, cpus,QCOM_SCM_BOOT_MC_FLAG_COLDBOOT )) +/* Fallback to old SCM call */ +return __qcom_scm_set_cold_boot_addr (entry, cpus); +return 0 ; +}EXPORT_SYMBOL (qcom_scm_set_cold_boot_addr);/**
drivers/firmware/qcom_scm.h +4 -0
@@ -78,8 +78,12 @@ extern int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc,#define QCOM_SCM_BOOT_SET_ADDR 0x01#define QCOM_SCM_BOOT_TERMINATE_PC 0x02#define QCOM_SCM_BOOT_SET_DLOAD_MODE 0x10 +#define QCOM_SCM_BOOT_SET_ADDR_MC 0x11#define QCOM_SCM_BOOT_SET_REMOTE_STATE 0x0a#define QCOM_SCM_FLUSH_FLAG_MASK 0x3 +#define QCOM_SCM_BOOT_MC_FLAG_AARCH64 BIT(0) +#define QCOM_SCM_BOOT_MC_FLAG_COLDBOOT BIT(1) +#define QCOM_SCM_BOOT_MC_FLAG_WARMBOOT BIT(2)#define QCOM_SCM_SVC_PIL 0x02#define QCOM_SCM_PIL_PAS_INIT_IMAGE 0x01
Signature · 1 line
2.33.0
PATCH v2 13/15 arm64: dts: qcom: msm8916: Add CPU ACC and SAW/SPM
In reply to Stephan GerholdAdd the device tree nodes necessary for SMP bring-up and cpuidle without PSCI on ARM32. The hardware is typically controlled by the PSCI implementation in the TrustZone firmware and is therefore marked as status = "reserved" by default (from the device tree specification):
"Indicates that the device is operational, but should not be used.
Typically this is used for devices that are controlled by another software component, such as platform firmware."
Since this is part of the MSM8916 SoC it should be added to msm8916.dtsi but in practice these nodes should only get enabled via an extra include on ARM32.
This is necessary for some devices with signed firmware which is missing both ARM64 and PSCI support and can therefore only boot ARM32 kernels.
---
Changes in v2: None.
--- arch/arm64/boot/dts/qcom/msm8916.dtsi | 56 +++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
arch/arm64/boot/dts/qcom/msm8916.dtsi +56 -0
@@ -124,6 +124,8 @@ CPU0: cpu@0 { #cooling-cells = <2>; power-domains = <&CPU_PD0>; power-domain-names = "psci"; + qcom,acc = <&cpu0_acc>; + qcom,saw = <&cpu0_saw>; }; CPU1: cpu@1 {
@@ -137,6 +139,8 @@ CPU1: cpu@1 { #cooling-cells = <2>; power-domains = <&CPU_PD1>; power-domain-names = "psci"; + qcom,acc = <&cpu1_acc>; + qcom,saw = <&cpu1_saw>; }; CPU2: cpu@2 {
@@ -150,6 +154,8 @@ CPU2: cpu@2 { #cooling-cells = <2>; power-domains = <&CPU_PD2>; power-domain-names = "psci"; + qcom,acc = <&cpu2_acc>; + qcom,saw = <&cpu2_saw>; }; CPU3: cpu@3 {
@@ -163,6 +169,8 @@ CPU3: cpu@3 { #cooling-cells = <2>; power-domains = <&CPU_PD3>; power-domain-names = "psci"; + qcom,acc = <&cpu3_acc>; + qcom,saw = <&cpu3_saw>; }; L2_0: l2-cache {
@@ -1877,6 +1885,54 @@ frame@b028000 { status = "disabled"; }; }; + + cpu0_acc: power-manager@b088000 { + compatible = "qcom,msm8916-acc"; + reg = <0x0b088000 0x1000>; + status = "reserved"; /* Controlled by PSCI firmware */ + }; + + cpu0_saw: power-manager@b089000 { + compatible = "qcom,msm8916-saw2-v3.0-cpu", "qcom,saw2"; + reg = <0x0b089000 0x1000>; + status = "reserved"; /* Controlled by PSCI firmware */ + }; + + cpu1_acc: power-manager@b098000 { + compatible = "qcom,msm8916-acc"; + reg = <0x0b098000 0x1000>; + status = "reserved"; /* Controlled by PSCI firmware */ + }; + + cpu1_saw: power-manager@b099000 { + compatible = "qcom,msm8916-saw2-v3.0-cpu", "qcom,saw2"; + reg = <0x0b099000 0x1000>; + status = "reserved"; /* Controlled by PSCI firmware */ + }; + + cpu2_acc: power-manager@b0a8000 { + compatible = "qcom,msm8916-acc"; + reg = <0x0b0a8000 0x1000>; + status = "reserved"; /* Controlled by PSCI firmware */ + }; + + cpu2_saw: power-manager@b0a9000 { + compatible = "qcom,msm8916-saw2-v3.0-cpu", "qcom,saw2"; + reg = <0x0b0a9000 0x1000>; + status = "reserved"; /* Controlled by PSCI firmware */ + }; + + cpu3_acc: power-manager@b0b8000 { + compatible = "qcom,msm8916-acc"; + reg = <0x0b0b8000 0x1000>; + status = "reserved"; /* Controlled by PSCI firmware */ + }; + + cpu3_saw: power-manager@b0b9000 { + compatible = "qcom,msm8916-saw2-v3.0-cpu", "qcom,saw2"; + reg = <0x0b0b9000 0x1000>; + status = "reserved"; /* Controlled by PSCI firmware */ + }; }; thermal-zones {
Signature · 1 line
2.33.0
PATCH v2 14/15 ARM: dts: qcom: msm8916: Add include for SMP without PSCI on ARM32
In reply to Stephan GerholdAdd a special device tree include for MSM8916 on ARM32 that sets up SMP and cpuidle without PSCI. This is meant for devices with signed firmware that does not support PSCI and only allows booting ARM32 kernels.
---
Changes in v2: Clarify commit message very slightly
--- arch/arm/boot/dts/qcom-msm8916-smp.dtsi | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 arch/arm/boot/dts/qcom-msm8916-smp.dtsi
arch/arm/boot/dts/qcom-msm8916-smp.dtsi new file +62 -0
@@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0-only + +/ { + cpus { + cpu@0 { + enable-method = "qcom,msm8916-smp"; + }; + cpu@1 { + enable-method = "qcom,msm8916-smp"; + }; + cpu@2 { + enable-method = "qcom,msm8916-smp"; + }; + cpu@3 { + enable-method = "qcom,msm8916-smp"; + }; + + idle-states { + /delete-property/ entry-method; + }; + }; + + psci { + status = "disabled"; + }; +}; + +&CPU_SLEEP_0 { + compatible = "qcom,idle-state-spc"; +}; + +&cpu0_acc { + status = "okay"; +}; + +&cpu0_saw { + status = "okay"; +}; + +&cpu1_acc { + status = "okay"; +}; + +&cpu1_saw { + status = "okay"; +}; + +&cpu2_acc { + status = "okay"; +}; + +&cpu2_saw { + status = "okay"; +}; + +&cpu3_acc { + status = "okay"; +}; + +&cpu3_saw { + status = "okay"; +};
Signature · 1 line
2.33.0
PATCH v2 15/15 ARM: dts: qcom: msm8916-samsung-serranove: Include dts from arm64
In reply to Stephan GerholdAfter adding all necessary support for MSM8916 SMP/cpuidle without PSCI on ARM32, build the Samsung Galaxy S4 Mini VE device tree from the arm64 tree together with the ARM32 include to allow booting this device on ARM32.
The approach to include device tree files from other architectures is inspired from e.g. the Raspberry Pi (bcm2711-rpi-4-b.dts) where this is used to build the device tree for both ARM32 and ARM64.
---
Changes in v2: None.
I'm not sure what's the best way to apply this patch...
It might be easiest to apply the two ARM32 dts patches to the arm64 branch. (It does not seem to cause any conflicts at the moment...)
--- arch/arm/boot/dts/Makefile | 1 + arch/arm/boot/dts/qcom-msm8916-samsung-serranove.dts | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 arch/arm/boot/dts/qcom-msm8916-samsung-serranove.dts
arch/arm/boot/dts/Makefile +1 -0
@@ -960,6 +960,7 @@ dtb-$(CONFIG_ARCH_QCOM) += \ qcom-ipq8064-rb3011.dtb \ qcom-msm8226-samsung-s3ve3g.dtb \ qcom-msm8660-surf.dtb \ + qcom-msm8916-samsung-serranove.dtb \ qcom-msm8960-cdp.dtb \ qcom-msm8974-fairphone-fp2.dtb \ qcom-msm8974-lge-nexus5-hammerhead.dtb \
arch/arm/boot/dts/qcom-msm8916-samsung-serranove.dts new file +3 -0
@@ -0,0 +1,3 @@ +// SPDX-License-Identifier: GPL-2.0-only +#include "arm64/qcom/msm8916-samsung-serranove.dts" +#include "qcom-msm8916-smp.dtsi"
Signature · 1 line
2.33.0