Skip to content

Instantly share code, notes, and snippets.

@williamfligor
Created March 17, 2017 14:38
Show Gist options
  • Save williamfligor/4eff7997d40de2875841570022e32f1a to your computer and use it in GitHub Desktop.
Save williamfligor/4eff7997d40de2875841570022e32f1a to your computer and use it in GitHub Desktop.
AP6212 Bluetooth Flash and Start
/etc/init.d/bluetooth start
echo 205 > /sys/class/gpio/export # BT-RESET
echo 8 > /sys/class/gpio/export # BT-WAKE
echo out > /sys/class/gpio/gpio205/direction
echo out > /sys/class/gpio/gpio8/direction
echo -n " " > /dev/ttyS3
sleep 1
echo 0 > /sys/class/gpio/gpio205/value && echo 1 > /sys/class/gpio/gpio205/value
sleep 1
echo -n " " > /dev/ttyS3
cat /proc/tty/driver/serial
sleep 1
brcm_patchram_plus -d --patchram /etc/firmware/ap6212/4343A0.hcd --bd_addr 11:22:33:44:55:66 --no2bytes --tosleep 1000 /dev/ttyS3
sleep 1
hciattach /dev/ttyS3 any
hciconfig hci0 up
@williamfligor
Copy link
Author

With dts

--- a/arch/arm/boot/dts/sun8i-h3-nanopi-neo-air.dts
+++ b/arch/arm/boot/dts/sun8i-h3-nanopi-neo-air.dts
@@ -47,12 +47,39 @@
 	model = "FriendlyARM NanoPi NEO Air";
 	compatible = "friendlyarm,nanopi-neo-air", "allwinner,sun8i-h3";
 
+	aliases {
+		serial3 = &uart3;
+	};
+
 	wifi_pwrseq: wifi_pwrseq {
 		compatible = "mmc-pwrseq-simple";
 		pinctrl-names = "default";
 		pinctrl-0 = <&wifi_en_nanopi_neo_air>;
 		reset-gpios = <&r_pio 0 7 GPIO_ACTIVE_LOW>; /* PL7 */
 	};
+
+	rfkill-switches {
+		compatible = "simple-bus";
+		pinctrl-names = "default";
+
+		rfkill_wifi {
+			compatible = "rfkill-gpio";
+			pinctrl-names = "default";
+			pinctrl-0 = <&wifi_pwrseq>;
+			shutdown-gpio = <&r_pio 0 7 GPIO_ACTIVE_LOW>; /* PL7 */
+			label = "wifi";
+			type = <1>;
+		};
+
+		rfkill_bt {
+			compatible = "rfkill-gpio";
+			pinctrl-names = "default", "default";
+			pinctrl-0 = <&bt_pwr_pin>;
+			shutdown-gpio = <&pio 6 13 GPIO_ACTIVE_LOW>; /* PG13 */
+			label = "bt";
+			type = <2>;
+		};
+	};
 };
 
 &codec {
@@ -99,3 +126,25 @@
 		allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
 	};
 };
+
+&pio {
+	bt_pwr_pin: bt_pwr_pin@0 {
+		allwinner,pins = "PG13";
+		allwinner,function = "gpio_out";
+		allwinner,drive = <0>;
+		allwinner,pull = <0>;
+	};
+
+	bt_wake_pin: bt_wake_pin@0 {
+		allwinner,pins = "PA8";
+		allwinner,function = "gpio_out";
+		allwinner,drive = <0>;
+		allwinner,pull = <0>;
+	};
+};
+
+&uart3 { /* Connected to AP6212 on Neo Air */
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart3_pins>, <&uart3_rts_cts_pins>;
+	status = "okay";
+};
--- a/arch/arm/boot/dts/sun8i-h3.dtsi
+++ b/arch/arm/boot/dts/sun8i-h3.dtsi
@@ -424,11 +424,25 @@
 				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
 			};
 
+			uart2_rts_cts_pins: uart2_rts_cts {
+				allwinner,pins = "PA2", "PA3";
+				allwinner,function = "uart2";
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+			};
+
 			uart3_pins: uart3 {
 				allwinner,pins = "PA13", "PA14";
 				allwinner,function = "uart3";
 				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
 				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+			};
+
+			uart3_rts_cts_pins: uart3_rts_cts {
+				allwinner,pins = "PA15", "PA16";
+				allwinner,function = "uart3";
+				allwinner,drive = <SUN4I_PINCTRL_10_MA>;
+				allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
 			};
 		};

haven't been able to get rfkill to do anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment