DWR-512: adding wwan support for the dwr-512 3G modem
This PR allow the 3G modem embedded in the DWR-512 to be managed by the wwan-ncm scripts. The modem will use the usb-option and usb-cdc-ether drivers. The DWR-512 DT is updated accordingly. Signed-off-by: Giuseppe Lippolis <giu.lippolis@gmail.com>
This commit is contained in:
		 Giuseppe Lippolis
					Giuseppe Lippolis
				
			
				
					committed by
					
						 Felix Fietkau
						Felix Fietkau
					
				
			
			
				
	
			
			
			 Felix Fietkau
						Felix Fietkau
					
				
			
						parent
						
							8851a18a88
						
					
				
				
					commit
					4ba2f4dc63
				
			| @@ -63,5 +63,16 @@ | |||||||
| 		}, | 		}, | ||||||
| 		"connect": "AT*ENAP=1,${profile}", | 		"connect": "AT*ENAP=1,${profile}", | ||||||
| 		"disconnect": "AT*ENAP=0" | 		"disconnect": "AT*ENAP=0" | ||||||
|  | 	}, | ||||||
|  | 	"mtk1": { | ||||||
|  | 		"initialize": [ | ||||||
|  | 			"AT+CFUN=1" | ||||||
|  | 		], | ||||||
|  | 		"configure": [ | ||||||
|  | 			"AT+CGDCONT=${profile},\\\"${pdptype}\\\",\\\"${apn}\\\",0,0" | ||||||
|  | 		], | ||||||
|  | 		"connect": "AT+CGACT=1,${profile}", | ||||||
|  | 		"finalize": "AT+CGDATA=\\\"M-MBIM\\\",${profile},1", | ||||||
|  | 		"disconnect": "AT+CGACT=0,${profile}" | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ proto_ncm_init_config() { | |||||||
| proto_ncm_setup() { | proto_ncm_setup() { | ||||||
| 	local interface="$1" | 	local interface="$1" | ||||||
|  |  | ||||||
| 	local manufacturer initialize setmode connect ifname devname devpath | 	local manufacturer initialize setmode connect finalize ifname devname devpath | ||||||
|  |  | ||||||
| 	local device apn auth username password pincode delay mode pdptype profile $PROTO_DEFAULT_OPTIONS | 	local device apn auth username password pincode delay mode pdptype profile $PROTO_DEFAULT_OPTIONS | ||||||
| 	json_get_vars device apn auth username password pincode delay mode pdptype profile $PROTO_DEFAULT_OPTIONS | 	json_get_vars device apn auth username password pincode delay mode pdptype profile $PROTO_DEFAULT_OPTIONS | ||||||
| @@ -105,9 +105,21 @@ proto_ncm_setup() { | |||||||
| 			return 1 | 			return 1 | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	json_get_values configure configure | ||||||
|  | 	echo "Configuring modem" | ||||||
|  | 	for i in $configure; do | ||||||
|  | 		eval COMMAND="$i" gcom -d "$device" -s /etc/gcom/runcommand.gcom || { | ||||||
|  | 			echo "Failed to configure modem" | ||||||
|  | 			proto_notify_error "$interface" CONFIGURE_FAILED | ||||||
|  | 			return 1 | ||||||
|  | 		} | ||||||
|  | 	done | ||||||
|  |  | ||||||
| 	[ -n "$mode" ] && { | 	[ -n "$mode" ] && { | ||||||
| 		json_select modes | 		json_select modes | ||||||
| 		json_get_var setmode "$mode" | 		json_get_var setmode "$mode" | ||||||
|  | 		echo "Setting mode" | ||||||
| 		eval COMMAND="$setmode" gcom -d "$device" -s /etc/gcom/runcommand.gcom || { | 		eval COMMAND="$setmode" gcom -d "$device" -s /etc/gcom/runcommand.gcom || { | ||||||
| 			echo "Failed to set operating mode" | 			echo "Failed to set operating mode" | ||||||
| 			proto_notify_error "$interface" SETMODE_FAILED | 			proto_notify_error "$interface" SETMODE_FAILED | ||||||
| @@ -118,14 +130,16 @@ proto_ncm_setup() { | |||||||
|  |  | ||||||
| 	echo "Starting network $interface" | 	echo "Starting network $interface" | ||||||
| 	json_get_vars connect | 	json_get_vars connect | ||||||
|  | 	echo "Connecting modem" | ||||||
| 	eval COMMAND="$connect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || { | 	eval COMMAND="$connect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || { | ||||||
| 		echo "Failed to connect" | 		echo "Failed to connect" | ||||||
| 		proto_notify_error "$interface" CONNECT_FAILED | 		proto_notify_error "$interface" CONNECT_FAILED | ||||||
| 		return 1 | 		return 1 | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	echo "Setting up $ifname" | 	json_get_vars finalize | ||||||
|  |  | ||||||
|  | 	echo "Setting up $ifname" | ||||||
| 	proto_init_update "$ifname" 1 | 	proto_init_update "$ifname" 1 | ||||||
| 	proto_add_data | 	proto_add_data | ||||||
| 	json_add_string "manufacturer" "$manufacturer" | 	json_add_string "manufacturer" "$manufacturer" | ||||||
| @@ -150,6 +164,15 @@ proto_ncm_setup() { | |||||||
| 		proto_add_dynamic_defaults | 		proto_add_dynamic_defaults | ||||||
| 		ubus call network add_dynamic "$(json_dump)" | 		ubus call network add_dynamic "$(json_dump)" | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	[ -n "$finalize" ] && { | ||||||
|  | 		eval COMMAND="$finalize" gcom -d "$device" -s /etc/gcom/runcommand.gcom || { | ||||||
|  | 			echo "Failed to configure modem" | ||||||
|  | 			proto_notify_error "$interface" FINALIZE_FAILED | ||||||
|  | 			return 1 | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| proto_ncm_teardown() { | proto_ncm_teardown() { | ||||||
|   | |||||||
| @@ -66,15 +66,15 @@ proto_wwan_setup() { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	[ -z "$ctl_device" ] && for net in $(ls /sys/class/net/ | grep wwan); do | 	[ -z "$ctl_device" ] && for net in $(ls /sys/class/net/ | grep -e wwan -e usb); do | ||||||
| 		[ -z "$ctl_device" ] || continue | 		[ -z "$ctl_device" ] || continue | ||||||
| 		driver=$(grep DRIVER /sys/class/net/$net/device/uevent | cut -d= -f2) | 		driver=$(grep DRIVER /sys/class/net/$net/device/uevent | cut -d= -f2) | ||||||
| 		case "$driver" in | 		case "$driver" in | ||||||
| 		qmi_wwan|cdc_mbim) | 		qmi_wwan|cdc_mbim) | ||||||
| 			ctl_device=/dev/$(ls /sys/class/net/$net/device/usbmisc) | 			ctl_device=/dev/$(ls /sys/class/net/$net/device/usbmisc) | ||||||
| 			;; | 			;; | ||||||
| 		sierra_net|*cdc_ncm) | 		sierra_net|cdc_ether|*cdc_ncm) | ||||||
| 			ctl_device=/dev/$(cd /sys/class/net/$net/; find ../../../ -name ttyUSB* |xargs basename | head -n1) | 			ctl_device=/dev/$(cd /sys/class/net/$net/; find ../../../ -name ttyUSB* |xargs -n1 basename | head -n1) | ||||||
| 			;; | 			;; | ||||||
| 		*) continue;; | 		*) continue;; | ||||||
| 		esac | 		esac | ||||||
| @@ -97,7 +97,7 @@ proto_wwan_setup() { | |||||||
| 	cdc_mbim)		proto_mbim_setup $@ ;; | 	cdc_mbim)		proto_mbim_setup $@ ;; | ||||||
| 	sierra_net)		proto_directip_setup $@ ;; | 	sierra_net)		proto_directip_setup $@ ;; | ||||||
| 	comgt)			proto_3g_setup $@ ;; | 	comgt)			proto_3g_setup $@ ;; | ||||||
| 	*cdc_ncm)	proto_ncm_setup $@ ;; | 	cdc_ether|*cdc_ncm)	proto_ncm_setup $@ ;; | ||||||
| 	esac | 	esac | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -112,7 +112,7 @@ proto_wwan_teardown() { | |||||||
| 	cdc_mbim)		proto_mbim_teardown $@ ;; | 	cdc_mbim)		proto_mbim_teardown $@ ;; | ||||||
| 	sierra_net)		proto_mbim_teardown $@ ;; | 	sierra_net)		proto_mbim_teardown $@ ;; | ||||||
| 	comgt)			proto_3g_teardown $@ ;; | 	comgt)			proto_3g_teardown $@ ;; | ||||||
| 	*cdc_ncm)	proto_ncm_teardown $@ ;; | 	cdc_ether|*cdc_ncm)	proto_ncm_teardown $@ ;; | ||||||
| 	esac | 	esac | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -300,8 +300,8 @@ define Device/dwr-512-b | |||||||
|   DTS := DWR-512-B |   DTS := DWR-512-B | ||||||
|   IMAGE_SIZE := 7700k |   IMAGE_SIZE := 7700k | ||||||
|   DEVICE_TITLE := D-Link DWR-512 B |   DEVICE_TITLE := D-Link DWR-512 B | ||||||
|   DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-i2c-core kmod-i2c-ralink kmod-spi-dev \ |   DEVICE_PACKAGES := kmod-usb2 kmod-spi-dev kmod-usb-serial kmod-usb-serial-option \ | ||||||
| 			kmod-usb-serial kmod-usb-serial-option kmod-usb-serial-wwan comgt | 			kmod-usb-net kmod-usb-net-cdc-ether comgt-ncm | ||||||
| endef | endef | ||||||
| TARGET_DEVICES += dwr-512-b | TARGET_DEVICES += dwr-512-b | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user