S905X4 built in DVB

fix for Gpio : GPIO fix – Google Drive

@rozpruwacz testing patch for “mecool m8s dvb s2/s2x “

branch : ”coreelec-21-amlogic-dvb-demux”

copy to : projects/Amlogic-ce/devices/Amlogic-ng/patches/linux/linux-12-m8s-dvb-s2x.patch

From: CoreELEC DVB port
Subject: [PATCH] arm64: dts: amlogic: add Mecool M8S Plus DVB-S2X device tree

Add DTS for Mecool M8S Plus with Montage M88RS6060 DVB-S/S2/S2X tuner.

Hardware confirmed on live device:
  - SoC:       Amlogic S905D (GXL, gxl_p231_1g)
  - Demod+RF:  Montage M88RS6060 (all-in-one), I2C-C bus 2, addr 0x69
  - TS:        parallel, GPIODV_0..10 (tsin_a)
  - Reset:     GPIODV_13 (gpio-217)
  - Power:     GPIODV_14 (gpio-218)
  - LNB sel:   GPIODV_15 (gpio-219)

Note: Android DTB incorrectly names demod "Avl6211" — remnant of a failed
DVB-T custom ROM port.  Actual chip is M88RS6060 per dmesg on live device:
  "RS6060 chip, demod id = e2"  /  "M88RS6060 attached!"

Driver path: aml_m88dm6k_attach() -> m88rs6060_attach()

---
 arch/arm64/boot/dts/amlogic/Makefile                              |   1 +
 arch/arm64/boot/dts/amlogic/coreelec-gxl/gxl_p231_1g_m8s_dvb-s2x.dts | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 136 insertions(+)
 create mode 100644 arch/arm64/boot/dts/amlogic/coreelec-gxl/gxl_p231_1g_m8s_dvb-s2x.dts

diff --git a/arch/arm64/boot/dts/amlogic/Makefile b/arch/arm64/boot/dts/amlogic/Makefile
--- a/arch/arm64/boot/dts/amlogic/Makefile
+++ b/arch/arm64/boot/dts/amlogic/Makefile
@@ -82,6 +82,7 @@ dtb-$(CONFIG_ARM64) += coreelec-gxl/gxl_p231_1g.dtb
 dtb-$(CONFIG_ARM64) += coreelec-gxl/gxl_p231_1g_a95xr.dtb
 dtb-$(CONFIG_ARM64) += coreelec-gxl/gxl_p231_1g_m8s.dtb
 dtb-$(CONFIG_ARM64) += coreelec-gxl/gxl_p231_1g_m8s_dvb-s2.dtb
+dtb-$(CONFIG_ARM64) += coreelec-gxl/gxl_p231_1g_m8s_dvb-s2x.dtb
 dtb-$(CONFIG_ARM64) += coreelec-gxl/gxl_p231_2g.dtb
 dtb-$(CONFIG_ARM64) += coreelec-gxl/gxl_p231_2g_dvb.dtb
 dtb-$(CONFIG_ARM64) += coreelec-gxl/gxl_p231_2g_dvb_ser.dtb
diff --git a/arch/arm64/boot/dts/amlogic/coreelec-gxl/gxl_p231_1g_m8s_dvb-s2x.dts b/arch/arm64/boot/dts/amlogic/coreelec-gxl/gxl_p231_1g_m8s_dvb-s2x.dts
new file mode 100644
--- /dev/null
+++ b/arch/arm64/boot/dts/amlogic/coreelec-gxl/gxl_p231_1g_m8s_dvb-s2x.dts
@@ -0,0 +1,135 @@
+/*
+ * Mecool M8S Plus DVB-S2X device tree
+ * SoC: Amlogic S905D (GXL, gxl_p231_1g)
+ *
+ * DVB hardware (confirmed via dmesg on live device):
+ *   Demodulator+Tuner: Montage M88RS6060 (DVB-S/S2/S2X, all-in-one)
+ *   I2C bus:  1 (i2c-B, c11087c0)
+ *   I2C addr: 0x69
+ *   TS mode:  parallel (GPIODV_0..10, tsin_a)
+ *
+ * GPIO assignments (confirmed via /sys/kernel/debug/gpio on live device):
+ *   GPIODV_13 (gpio-217) - demod reset
+ *   GPIODV_14 (gpio-218) - demod power enable
+ *   GPIODV_15 (gpio-219) - LNB 13V/18V voltage select
+ *
+ * Note: Android DTB incorrectly names demod "Avl6211" -- remnant of a failed
+ * DVB-T custom ROM port.  Actual chip confirmed by dmesg:
+ *   "RS6060 chip, demod id = e2"  /  "M88RS6060 attached!"
+ *
+ * Framework: mczerski's coreelec-21-amlogic-dvb-demux (dvb-extern + dvb-demux)
+ * Driver:    aml_m88dm6k_attach() -> m88rs6060_attach()
+ *            ts_mode=0 (parallel), pin_ctrl=0x82 (hardcoded in wrapper)
+ */
+
+#include "gxl_p231_1g.dts"
+
+/ {
+	coreelec-dt-id = "gxl_p231_1g_m8s_dvb-s2x";
+
+	emmc {
+		status = "disabled";
+	};
+
+	nand {
+		status = "okay";
+	};
+
+	ethernet@0xc9410000 {
+		interrupts = <0 8 1>;
+	};
+
+	sysled {
+		led_gpio = <&gpio_ao GPIOAO_9 GPIO_ACTIVE_HIGH>;
+	};
+
+	/*
+	 * DVB external frontend.
+	 *
+	 * fe0_demod = "m88dm6k":
+	 *   Maps to AM_DTV_DEMOD_M88DM6K -> aml_m88dm6k_attach() which calls
+	 *   m88rs6060_attach().  Wrapper hardcodes ts_mode=0 (parallel),
+	 *   pin_ctrl=0x82, ci_mode=0.
+	 *
+	 * M88RS6060 is all-in-one (demod + RF tuner), so tuner_num = 0.
+	 */
+	dvb-extern {
+		compatible = "amlogic, dvb-extern";
+		status = "okay";
+
+		fe_num = <1>;
+		fe0_demod = "m88dm6k";
+		fe0_i2c_adap_id = <&i2c1>;
+		fe0_demod_i2c_addr = <0x69>;
+		fe0_ts = <0>;
+		fe0_ts_out_mode = <1>;		/* 1 = parallel */
+
+		tuner_num = <0>;		/* M88RS6060: all-in-one, no ext tuner */
+
+		/* Power enable: GPIODV_14 (gpio-218), confirmed via /sys/kernel/debug/gpio */
+		dvb_power_gpio  = <&gpio GPIODV_14 GPIO_ACTIVE_HIGH>;
+		dvb_power_dir   = <0>;		/* 0 = output */
+		dvb_power_value = <1>;		/* 1 = high = power on */
+	};
+
+	/*
+	 * DVB hardware demux.
+	 * Interrupts identical to other GXL DVB devices.
+	 */
+	dvb-demux {
+		compatible = "amlogic, dvb-demux";
+		status = "okay";
+		ts0 = "parallel";
+		ts0_control = <0x0>;
+		ts0_invert = <0x0>;
+		pinctrl-names = "p_ts0", "s_ts0";
+		pinctrl-0 = <&dvb_p_ts0_pins>;
+		pinctrl-1 = <&dvb_s_ts0_pins>;
+		clocks = <&clkc CLKID_DEMUX
+			  &clkc CLKID_ASYNC_FIFO
+			  &clkc CLKID_AHB_ARB0
+			  &clkc CLKID_HIU_IFACE>;
+		clock-names = "demux", "asyncfifo", "ahbarb0", "uparsertop";
+
+		interrupts = <GIC_SPI 23 IRQ_TYPE_EDGE_RISING>,
+			     <GIC_SPI  5 IRQ_TYPE_EDGE_RISING>,
+			     <GIC_SPI 53 IRQ_TYPE_EDGE_RISING>,
+			     <GIC_SPI 19 IRQ_TYPE_EDGE_RISING>,
+			     <GIC_SPI 25 IRQ_TYPE_EDGE_RISING>;
+		interrupt-names = "demux0_irq", "demux1_irq", "demux2_irq",
+				  "dvr0_irq", "dvr1_irq";
+	};
+};
+
+/*
+ * Parallel TS pinmux (tsin_a, GPIODV_0..10).
+ * Confirmed from Android DTB and AlexELEC pinmux nodes.
+ */
+&pinctrl_periphs {
+	dvb_p_ts0_pins: dvb_p_ts0_pins {
+		tsin_a {
+			groups = "tsin_d0_a_dv0",
+				 "tsin_d1_7_a_dv1_7",
+				 "tsin_clk_a_dv8",
+				 "tsin_sop_a_dv9",
+				 "tsin_d_valid_a_dv10";
+			function = "tsin_a";
+		};
+	};
+
+	dvb_s_ts0_pins: dvb_s_ts0_pins {
+		tsin_a {
+			groups = "tsin_d0_a_dv0",
+				 "tsin_clk_a_dv8",
+				 "tsin_sop_a_dv9",
+				 "tsin_d_valid_a_dv10";
+			function = "tsin_a";
+		};
+	};
+};
+
+/* I2C-B (bus 1): M88RS6060 at 0x69 */
+&i2c0 { status = "okay"; };
+&i2c1 { status = "okay"; };
+&i2c2 { status = "okay"; };
+&i2c3 { status = "okay"; };

/storage/.config/modules-load.d/dvb.conf

echo -e "aml_hardware_dmx\naml_dvb_extern" > /storage/.config/modules-load.d/dvb.conf

changes needed for proper freq ranges in linux-11-dvb-driver.patch

.info	= {
 		.name			= "Montage RS6060",
-		.frequency_min		=  950000000,
-		.frequency_max		= 2200000000,
-		.frequency_stepsize	= 1020000,
-		.frequency_tolerance	= 5000000,
+		.frequency_min		=  950000,   /* kHz */
+		.frequency_max		= 2200000,   /* kHz */
+		.frequency_stepsize	= 1020,      /* kHz */
+		.frequency_tolerance	= 5000,      /* kHz */
 		.symbol_rate_min	= 1000000,
 		.symbol_rate_max	= 45000000,
 	},
 	.tuner_ops = {
 		.info = {
-			.frequency_min = 950000000,
-			.frequency_max = 2200000000
+			.frequency_min = 950000,     /* kHz */
+			.frequency_max = 2200000,    /* kHz */
 		},
 	},

CoreELEC:~ # dvb-fe-tool -a 0
Device Montage RS6060 (/dev/dvb/adapter0/frontend0) capabilities:
CAN_2G_MODULATION
CAN_FEC_1_2
CAN_FEC_2_3
CAN_FEC_3_4
CAN_FEC_4_5
CAN_FEC_5_6
CAN_FEC_6_7
CAN_FEC_7_8
CAN_FEC_AUTO
CAN_INVERSION_AUTO
CAN_QPSK
CAN_RECOVER
DVB API Version 5.10, Current v5 delivery system: DVBS2
Supported delivery systems:
DVBS
[DVBS2]
Frequency range for the current standard:
From: 950 MHz
To: 2.20 GHz
Step: 1.02 MHz
Tolerance: 5.00 MHz
Symbol rate ranges for the current standard:
From: 1.00 MBauds
To: 45.0 MBauds
SEC: set voltage to OFF
ERROR FE_SET_VOLTAGE: Operation not permitted