mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-29 09:32:34 +00:00 
			
		
		
		
	Compare commits
	
		
			26 Commits
		
	
	
		
			release/v4
			...
			staging-WI
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 5973dabaad | ||
|   | 6add44ae27 | ||
|   | 14a0c2d272 | ||
|   | 9e769c85cb | ||
|   | d6e1008c7a | ||
|   | 0a4c10d6cc | ||
|   | edfd2883f5 | ||
|   | f6ac6f791e | ||
|   | 88fe15a985 | ||
|   | a9f47c9e1e | ||
|   | f17314a2d3 | ||
|   | 29739ebd13 | ||
|   | 3caba52dba | ||
|   | 44bcc50815 | ||
|   | 942d7c15b4 | ||
|   | 25be7aef1a | ||
|   | a2e1ffe089 | ||
|   | 911f8eaa4c | ||
|   | 590ee6d514 | ||
|   | 5054a71062 | ||
|   | d69c1c3176 | ||
|   | 8d0da5a086 | ||
|   | eb66feb5c5 | ||
|   | 89b6ebd518 | ||
|   | e3dfe5ea74 | ||
|   | f39339564a | 
							
								
								
									
										2
									
								
								.github/workflows/build-dev.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/build-dev.yml
									
									
									
									
										vendored
									
									
								
							| @@ -21,7 +21,7 @@ jobs: | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         target: [ 'cig_wf186h', 'cig_wf186w', 'cig_wf188n', 'cig_wf189', 'cig_wf196', 'cig_wf196', 'cybertan_eww631-a1', 'cybertan_eww631-b1', 'sonicfi_rap630w-312g', 'sonicfi_rap63xc-211g', 'sonicfi_rap630c-311g', 'sonicfi_rap630w-311g', 'sonicfi_rap630w-211g', 'sonicfi_rap650c', 'sonicfi_rap7110c-341x', 'sonicfi_rap750w-311a', 'edgecore_eap101', 'edgecore_eap102', 'edgecore_eap104', 'edgecore_eap105', 'edgecore_eap111', 'edgecore_eap112', 'edgecore_oap101', 'edgecore_oap101-6e', 'edgecore_oap101e', 'edgecore_oap101e-6e', 'edgecore_oap103', 'hfcl_ion4xe', 'hfcl_ion4xi', 'hfcl_ion4x', 'hfcl_ion4x_2', 'hfcl_ion4x_3', 'hfcl_ion4xi_w', 'hfcl_ion4x_w', 'indio_um-305ax', 'senao_iap4300m', 'senao_iap2300m', 'senao_jeap6500', 'udaya_a6-id2', 'udaya_a6-od2', 'yuncore_ax820', 'yuncore_ax840', 'yuncore_fap640', 'yuncore_fap650', 'yuncore_fap655' ] | ||||
|         target: [ 'cig_wf189h', 'cig_wf189w', 'cig_wf672', 'cig_wf186h', 'cig_wf186w', 'cig_wf188n', 'cig_wf189', 'cig_wf196', 'cig_wf196', 'cybertan_eww631-a1', 'cybertan_eww631-b1', 'sonicfi_rap630w-312g', 'sonicfi_rap63xc-211g', 'sonicfi_rap630c-311g', 'sonicfi_rap630w-311g', 'sonicfi_rap630w-211g', 'sonicfi_rap650c', 'sonicfi_rap7110c-341x', 'sonicfi_rap750e-h', 'sonicfi_rap750e-s', 'sonicfi_rap750w-311a', 'edgecore_eap101', 'edgecore_eap102', 'edgecore_eap104', 'edgecore_eap105', 'edgecore_eap111', 'edgecore_eap112', 'edgecore_oap101', 'edgecore_oap101-6e', 'edgecore_oap101e', 'edgecore_oap101e-6e', 'edgecore_oap103', 'hfcl_ion4xe', 'hfcl_ion4xi', 'hfcl_ion4x', 'hfcl_ion4x_2', 'hfcl_ion4x_3', 'hfcl_ion4xi_w', 'hfcl_ion4x_w', 'indio_um-305ax', 'senao_iap4300m', 'senao_iap2300m', 'senao_jeap6500', 'udaya_a6-id2', 'udaya_a6-od2', 'yuncore_ax820', 'yuncore_ax840', 'yuncore_fap640', 'yuncore_fap650', 'yuncore_fap655', 'emplus_wap588m', 'zyxel_nwa130be', 'sercomm_ap72tip-v4' ] | ||||
|     steps: | ||||
|     - uses: actions/checkout@v3 | ||||
|  | ||||
|   | ||||
| @@ -146,6 +146,40 @@ check_board_phy() { | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| is_morse_phy() { | ||||
| 	local dev="$1" | ||||
| 	local morse_path="/sys/class/ieee80211/${dev}/device/morse/" | ||||
|  | ||||
| 	if [ -d "$morse_path" ]; then | ||||
| 		return 0  # This is a Morse PHY | ||||
| 	else | ||||
| 		return 1  # Not a Morse PHY | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| # Set up Morse-specific wireless configuration | ||||
| setup_morse_wireless() { | ||||
| 	local dev="$1" | ||||
| 	local name="$2" | ||||
|  | ||||
| 	# Create Morse-specific wireless configuration with exact settings | ||||
| 	uci -q batch <<-EOF | ||||
| 		set wireless.${name}=wifi-device | ||||
| 		set wireless.${name}.disabled='0' | ||||
| 		set wireless.${name}.mode='ap' | ||||
| 		set wireless.${name}.type='morse' | ||||
| 		set wireless.${name}.path='platform/11009000.spi/spi_master/spi1/spi1.0' | ||||
| 		set wireless.${name}.channel='12' | ||||
| 		set wireless.${name}.hwmode='a' | ||||
| 		set wireless.${name}.band='s1g' | ||||
| 		set wireless.${name}.htmode='8' | ||||
| 		set wireless.${name}.country='US' | ||||
| 		set wireless.${name}.channels='' | ||||
| EOF | ||||
|  | ||||
| 	uci -q commit wireless | ||||
| } | ||||
|  | ||||
| detect_mac80211() { | ||||
| 	devidx=0 | ||||
| 	config_load wireless | ||||
| @@ -158,13 +192,6 @@ detect_mac80211() { | ||||
|  | ||||
| 		dev="${_dev##*/}" | ||||
|  | ||||
| 		mode_band="" | ||||
| 		channel="" | ||||
| 		htmode="" | ||||
| 		ht_capab="" | ||||
|  | ||||
| 		get_band_defaults "$dev" | ||||
|  | ||||
| 		path="$(iwinfo nl80211 path "$dev")" | ||||
| 		macaddr="$(cat /sys/class/ieee80211/${dev}/macaddress)" | ||||
|  | ||||
| @@ -183,35 +210,51 @@ detect_mac80211() { | ||||
|  | ||||
| 		name="radio${devidx}" | ||||
| 		devidx=$(($devidx + 1)) | ||||
| 		case "$dev" in | ||||
| 			phy*) | ||||
| 				if [ -n "$path" ]; then | ||||
| 					dev_id="set wireless.${name}.path='$path'" | ||||
| 				else | ||||
| 					dev_id="set wireless.${name}.macaddr='$macaddr'" | ||||
| 				fi | ||||
| 				;; | ||||
| 			*) | ||||
| 				dev_id="set wireless.${name}.phy='$dev'" | ||||
| 				;; | ||||
| 		esac | ||||
|  | ||||
| 		uci -q batch <<-EOF | ||||
| 			set wireless.${name}=wifi-device | ||||
| 			set wireless.${name}.type=mac80211 | ||||
| 			${dev_id} | ||||
| 			set wireless.${name}.channel=${channel} | ||||
| 			set wireless.${name}.band=${mode_band} | ||||
| 			set wireless.${name}.htmode=$htmode | ||||
| 			set wireless.${name}.disabled=1 | ||||
| 		# Check if this is a Morse PHY | ||||
| 		if is_morse_phy "$dev"; then | ||||
| 			# Use dedicated Morse configuration | ||||
| 			setup_morse_wireless "$dev" "$name" | ||||
| 		else | ||||
| 			# Standard wireless configuration for non-Morse devices | ||||
| 			mode_band="" | ||||
| 			channel="" | ||||
| 			htmode="" | ||||
| 			ht_capab="" | ||||
|  | ||||
| 			set wireless.default_${name}=wifi-iface | ||||
| 			set wireless.default_${name}.device=${name} | ||||
| 			set wireless.default_${name}.network=lan | ||||
| 			set wireless.default_${name}.mode=ap | ||||
| 			set wireless.default_${name}.ssid=OpenWrt | ||||
| 			set wireless.default_${name}.encryption=none | ||||
| 			# Get default settings for standard devices | ||||
| 			get_band_defaults "$dev" | ||||
|  | ||||
| 			case "$dev" in | ||||
| 				phy*) | ||||
| 					if [ -n "$path" ]; then | ||||
| 						dev_id="set wireless.${name}.path='$path'" | ||||
| 					else | ||||
| 						dev_id="set wireless.${name}.macaddr='$macaddr'" | ||||
| 					fi | ||||
| 					;; | ||||
| 				*) | ||||
| 					dev_id="set wireless.${name}.phy='$dev'" | ||||
| 					;; | ||||
| 			esac | ||||
|  | ||||
| 			uci -q batch <<-EOF | ||||
| 				set wireless.${name}=wifi-device | ||||
| 				set wireless.${name}.type=mac80211 | ||||
| 				${dev_id} | ||||
| 				set wireless.${name}.channel=${channel} | ||||
| 				set wireless.${name}.band=${mode_band} | ||||
| 				set wireless.${name}.htmode=$htmode | ||||
| 				set wireless.${name}.disabled=1 | ||||
|  | ||||
| 				set wireless.default_${name}=wifi-iface | ||||
| 				set wireless.default_${name}.device=${name} | ||||
| 				set wireless.default_${name}.network=lan | ||||
| 				set wireless.default_${name}.mode=ap | ||||
| 				set wireless.default_${name}.ssid=OpenWrt | ||||
| 				set wireless.default_${name}.encryption=none | ||||
| EOF | ||||
| 		uci -q commit wireless | ||||
| 			uci -q commit wireless | ||||
| 		fi | ||||
| 	done | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,13 @@ | ||||
| --- a/net/mac80211/rx.c | ||||
| +++ b/net/mac80211/rx.c | ||||
| @@ -4193,8 +4196,10 @@ | ||||
| 	case NL80211_IFTYPE_STATION: | ||||
| 		if (!bssid && !sdata->u.mgd.use_4addr) | ||||
| 			return false; | ||||
| +#if 0 | ||||
| 		if (ieee80211_is_robust_mgmt_frame(skb) && !rx->sta) | ||||
| 			return false; | ||||
| +#endif | ||||
| 		if (multicast) | ||||
| 			return true; | ||||
| 		return ether_addr_equal(sdata->vif.addr, hdr->addr1); | ||||
| @@ -0,0 +1,443 @@ | ||||
| --- a/include/linux/ieee80211.h | ||||
| +++ b/include/linux/ieee80211.h | ||||
| @@ -3434,6 +3434,9 @@ | ||||
|  	WLAN_ACTION_ADDBA_REQ = 0, | ||||
|  	WLAN_ACTION_ADDBA_RESP = 1, | ||||
|  	WLAN_ACTION_DELBA = 2, | ||||
| +	WLAN_ACTION_NDP_ADDBA_REQ = 128, | ||||
| +	WLAN_ACTION_NDP_ADDBA_RESP = 129, | ||||
| +	WLAN_ACTION_NDP_DELBA = 130,     | ||||
|  }; | ||||
|   | ||||
|  /* BACK (block-ack) parties */ | ||||
|  | ||||
|  | ||||
| --- a/include/net/mac80211.h | ||||
| +++ b/include/net/mac80211.h | ||||
| @@ -125,6 +125,13 @@ | ||||
|   * via the usual ieee80211_tx_dequeue). | ||||
|   */ | ||||
|   | ||||
| + /** Morse Micro patches which add functionality that the driver needs to know about, can be | ||||
| +  * signalled by adding a define here. | ||||
| +  */ | ||||
| + | ||||
| + /** mac80211 has the capability to negotiate NDP block acknowledgements */ | ||||
| + #define MORSE_MAC80211_S1G_FEATURE_NDP_BLOCKACK | ||||
| + | ||||
|  struct device; | ||||
|   | ||||
|  /** | ||||
| @@ -2437,7 +2444,10 @@ | ||||
|   * | ||||
|   * @IEEE80211_HW_DETECTS_COLOR_COLLISION: HW/driver has support for BSS color | ||||
|   *	collision detection and doesn't need it in software. | ||||
| - * | ||||
| + *  | ||||
| + + @IEEE80211_HW_SUPPORTS_NDP_BLOCKACK: Hardware supports 11ah A-MPDU aggregation with NDP block | ||||
| + +  ACKs | ||||
| + + | ||||
|   * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays | ||||
|   */ | ||||
|  enum ieee80211_hw_flags { | ||||
| @@ -2494,6 +2504,7 @@ | ||||
|  	IEEE80211_HW_SUPPORTS_RX_DECAP_OFFLOAD, | ||||
|  	IEEE80211_HW_SUPPORTS_CONC_MON_RX_DECAP, | ||||
|  	IEEE80211_HW_DETECTS_COLOR_COLLISION, | ||||
| +	IEEE80211_HW_SUPPORTS_NDP_BLOCKACK, | ||||
|   | ||||
|  	/* keep last, obviously */ | ||||
|  	NUM_IEEE80211_HW_FLAGS | ||||
| @@ -3315,7 +3326,8 @@ | ||||
|   *	action is set to %IEEE80211_AMPDU_RX_START or | ||||
|   *	%IEEE80211_AMPDU_TX_OPERATIONAL | ||||
|   * @amsdu: indicates the peer's ability to receive A-MSDU within A-MPDU. | ||||
| - *	valid when the action is set to %IEEE80211_AMPDU_TX_OPERATIONAL | ||||
| + *	valid when the action is set to %IEEE80211_AMPDU_TX_OPERATIONAL  | ||||
| + * @ndp: indicates the driver has requested the session to use NDP block ACKs | ||||
|   * @timeout: BA session timeout. Valid only when the action is set to | ||||
|   *	%IEEE80211_AMPDU_RX_START | ||||
|   */ | ||||
| @@ -3326,6 +3338,7 @@ | ||||
|  	u16 ssn; | ||||
|  	u16 buf_size; | ||||
|  	bool amsdu; | ||||
| +       bool ndp; | ||||
|  	u16 timeout; | ||||
|  }; | ||||
|   | ||||
|  | ||||
| --- a/net/mac80211/agg-rx.c | ||||
| +++ b/net/mac80211/agg-rx.c | ||||
| @@ -80,6 +80,8 @@ | ||||
|  	RCU_INIT_POINTER(sta->ampdu_mlme.tid_rx[tid], NULL); | ||||
|  	__clear_bit(tid, sta->ampdu_mlme.agg_session_valid); | ||||
|   | ||||
| +       if (tid_rx) params.ndp = tid_rx->ndp; | ||||
| + | ||||
|  	ht_dbg(sta->sdata, | ||||
|  	       "Rx BA session stop requested for %pM tid %u %s reason: %d\n", | ||||
|  	       sta->sta.addr, tid, | ||||
| @@ -94,7 +96,7 @@ | ||||
|  	/* check if this is a self generated aggregation halt */ | ||||
|  	if (initiator == WLAN_BACK_RECIPIENT && tx) | ||||
|  		ieee80211_send_delba(sta->sdata, sta->sta.addr, | ||||
| -				     tid, WLAN_BACK_RECIPIENT, reason); | ||||
| +				     tid, params.ndp, WLAN_BACK_RECIPIENT, reason); | ||||
|   | ||||
|  	/* | ||||
|  	 * return here in case tid_rx is not assigned - which will happen if | ||||
| @@ -214,7 +216,7 @@ | ||||
|   | ||||
|  static void ieee80211_send_addba_resp(struct sta_info *sta, u8 *da, u16 tid, | ||||
|  				      u8 dialog_token, u16 status, u16 policy, | ||||
| -				      u16 buf_size, u16 timeout, | ||||
| +				      u16 buf_size, u16 timeout, bool ndp, | ||||
|  				      const struct ieee80211_addba_ext_ie *addbaext) | ||||
|  { | ||||
|  	struct ieee80211_sub_if_data *sdata = sta->sdata; | ||||
| @@ -248,7 +250,8 @@ | ||||
|   | ||||
|  	skb_put(skb, 1 + sizeof(mgmt->u.action.u.addba_resp)); | ||||
|  	mgmt->u.action.category = WLAN_CATEGORY_BACK; | ||||
| -	mgmt->u.action.u.addba_resp.action_code = WLAN_ACTION_ADDBA_RESP; | ||||
| +	mgmt->u.action.u.addba_resp.action_code = ndp ? | ||||
| +                       WLAN_ACTION_NDP_ADDBA_RESP : WLAN_ACTION_ADDBA_RESP; | ||||
|  	mgmt->u.action.u.addba_resp.dialog_token = dialog_token; | ||||
|   | ||||
|  	capab = 0; | ||||
| @@ -273,7 +276,7 @@ | ||||
|  void ___ieee80211_start_rx_ba_session(struct sta_info *sta, | ||||
|  				      u8 dialog_token, u16 timeout, | ||||
|  				      u16 start_seq_num, u16 ba_policy, u16 tid, | ||||
| -				      u16 buf_size, bool tx, bool auto_seq, | ||||
| +				      u16 buf_size, bool tx, bool auto_seq, bool ndp, | ||||
|  				      const struct ieee80211_addba_ext_ie *addbaext) | ||||
|  { | ||||
|  	struct ieee80211_local *local = sta->sdata->local; | ||||
| @@ -284,6 +287,7 @@ | ||||
|  		.tid = tid, | ||||
|  		.amsdu = false, | ||||
|  		.timeout = timeout, | ||||
| +		.ndp = ndp, | ||||
|  		.ssn = start_seq_num, | ||||
|  	}; | ||||
|  	int i, ret = -EOPNOTSUPP; | ||||
| @@ -306,6 +310,12 @@ | ||||
|  		goto end; | ||||
|  	} | ||||
|   | ||||
| +     | ||||
| +       if (ndp && !ieee80211_hw_check(&local->hw, SUPPORTS_NDP_BLOCKACK)) { | ||||
| +       	ht_dbg(sta->sdata, "Requested NDP BA but HW does not support it\n"); | ||||
| +       	goto end; | ||||
| +       } | ||||
| + | ||||
|  	if (test_sta_flag(sta, WLAN_STA_BLOCK_BA)) { | ||||
|  		ht_dbg(sta->sdata, | ||||
|  		       "Suspend in progress - Denying ADDBA request (%pM tid %d)\n", | ||||
| @@ -438,6 +448,7 @@ | ||||
|  	tid_agg_rx->started = false; | ||||
|  	tid_agg_rx->reorder_buf_filtered = 0; | ||||
|  	tid_agg_rx->tid = tid; | ||||
| +       tid_agg_rx->ndp = params.ndp; | ||||
|  	tid_agg_rx->sta = sta; | ||||
|  	status = WLAN_STATUS_SUCCESS; | ||||
|   | ||||
| @@ -459,20 +470,20 @@ | ||||
|  	if (tx) | ||||
|  		ieee80211_send_addba_resp(sta, sta->sta.addr, tid, | ||||
|  					  dialog_token, status, 1, buf_size, | ||||
| -					  timeout, addbaext); | ||||
| +					  timeout, params.ndp, addbaext); | ||||
|  } | ||||
|   | ||||
|  static void __ieee80211_start_rx_ba_session(struct sta_info *sta, | ||||
|  					    u8 dialog_token, u16 timeout, | ||||
|  					    u16 start_seq_num, u16 ba_policy, | ||||
|  					    u16 tid, u16 buf_size, bool tx, | ||||
| -					    bool auto_seq, | ||||
| +					    bool auto_seq, bool ndp, | ||||
|  					    const struct ieee80211_addba_ext_ie *addbaext) | ||||
|  { | ||||
|  	mutex_lock(&sta->ampdu_mlme.mtx); | ||||
|  	___ieee80211_start_rx_ba_session(sta, dialog_token, timeout, | ||||
|  					 start_seq_num, ba_policy, tid, | ||||
| -					 buf_size, tx, auto_seq, addbaext); | ||||
| +					 buf_size, tx, auto_seq, ndp, addbaext); | ||||
|  	mutex_unlock(&sta->ampdu_mlme.mtx); | ||||
|  } | ||||
|   | ||||
| @@ -485,6 +496,7 @@ | ||||
|  	struct ieee802_11_elems *elems = NULL; | ||||
|  	u8 dialog_token; | ||||
|  	int ies_len; | ||||
| +       bool ndp_ba; | ||||
|   | ||||
|  	/* extract session parameters from addba request frame */ | ||||
|  	dialog_token = mgmt->u.action.u.addba_req.dialog_token; | ||||
| @@ -496,6 +508,7 @@ | ||||
|  	ba_policy = (capab & IEEE80211_ADDBA_PARAM_POLICY_MASK) >> 1; | ||||
|  	tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; | ||||
|  	buf_size = (capab & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK) >> 6; | ||||
| +       ndp_ba = (mgmt->u.action.u.addba_req.action_code == WLAN_ACTION_NDP_ADDBA_REQ); | ||||
|   | ||||
|  	ies_len = len - offsetof(struct ieee80211_mgmt, | ||||
|  				 u.action.u.addba_req.variable); | ||||
| @@ -508,7 +521,7 @@ | ||||
|   | ||||
|  	__ieee80211_start_rx_ba_session(sta, dialog_token, timeout, | ||||
|  					start_seq_num, ba_policy, tid, | ||||
| -					buf_size, true, false, | ||||
| +					buf_size, true, false, ndp_ba, | ||||
|  					elems ? elems->addba_ext_ie : NULL); | ||||
|  free: | ||||
|  	kfree(elems); | ||||
| 	 | ||||
| --- a/net/mac80211/agg-tx.c | ||||
| +++ b/net/mac80211/agg-tx.c | ||||
| @@ -65,7 +65,7 @@ | ||||
|   */ | ||||
|   | ||||
|  static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata, | ||||
| -					 const u8 *da, u16 tid, | ||||
| +					 const u8 *da, u16 tid, bool ndp, | ||||
|  					 u8 dialog_token, u16 start_seq_num, | ||||
|  					 u16 agg_size, u16 timeout) | ||||
|  { | ||||
| @@ -99,7 +99,8 @@ | ||||
|  	skb_put(skb, 1 + sizeof(mgmt->u.action.u.addba_req)); | ||||
|   | ||||
|  	mgmt->u.action.category = WLAN_CATEGORY_BACK; | ||||
| -	mgmt->u.action.u.addba_req.action_code = WLAN_ACTION_ADDBA_REQ; | ||||
| +	mgmt->u.action.u.addba_req.action_code = ndp ? WLAN_ACTION_NDP_ADDBA_REQ : | ||||
| +                       WLAN_ACTION_ADDBA_REQ; | ||||
|   | ||||
|  	mgmt->u.action.u.addba_req.dialog_token = dialog_token; | ||||
|  	if (amsdu) | ||||
| @@ -488,7 +489,7 @@ | ||||
|  	} | ||||
|   | ||||
|  	/* send AddBA request */ | ||||
| -	ieee80211_send_addba_request(sdata, sta->sta.addr, tid, | ||||
| +	ieee80211_send_addba_request(sdata, sta->sta.addr, tid, tid_tx->ndp, | ||||
|  				     tid_tx->dialog_token, tid_tx->ssn, | ||||
|  				     buf_size, tid_tx->timeout); | ||||
|   | ||||
| @@ -506,10 +507,18 @@ | ||||
|  		.tid = tid, | ||||
|  		.buf_size = 0, | ||||
|  		.amsdu = false, | ||||
| +		.ndp = false, | ||||
|  		.timeout = 0, | ||||
|  	}; | ||||
|  	int ret; | ||||
|   | ||||
| +      /* If the HW supports NDP blockacks, try to negotiate. It's the drivers responsibility to | ||||
| +       * clear .ndp if the conditions for NDP block acks are not met for this TID. | ||||
| +       * TODO: remove driver responsibility when S1G STA caps exist in mac80211 | ||||
| +       */ | ||||
| +       if (ieee80211_hw_check(&local->hw, SUPPORTS_NDP_BLOCKACK)) | ||||
| +       	params.ndp = true; | ||||
| + | ||||
|  	tid_tx = rcu_dereference_protected_tid_tx(sta, tid); | ||||
|   | ||||
|  	/* | ||||
| @@ -532,6 +541,11 @@ | ||||
|  	params.ssn = sta->tid_seq[tid] >> 4; | ||||
|  	ret = drv_ampdu_action(local, sdata, ¶ms); | ||||
|  	tid_tx->ssn = params.ssn; | ||||
| + | ||||
| +     | ||||
| +       /* driver may clear this flag if it does not want NDP for this session */ | ||||
| +       tid_tx->ndp = params.ndp; | ||||
| +       | ||||
|  	if (ret == IEEE80211_AMPDU_TX_START_DELAY_ADDBA) { | ||||
|  		return; | ||||
|  	} else if (ret == IEEE80211_AMPDU_TX_START_IMMEDIATE) { | ||||
| @@ -769,6 +783,7 @@ | ||||
|  	tid_tx = rcu_dereference_protected_tid_tx(sta, tid); | ||||
|  	params.buf_size = tid_tx->buf_size; | ||||
|  	params.amsdu = tid_tx->amsdu; | ||||
| +	params.ndp = tid_tx->ndp; | ||||
|   | ||||
|  	ht_dbg(sta->sdata, "Aggregation is on for %pM tid %d\n", | ||||
|  	       sta->sta.addr, tid); | ||||
| @@ -950,7 +965,7 @@ | ||||
|  		ieee80211_agg_start_txq(sta, tid, false); | ||||
|   | ||||
|  	if (send_delba) | ||||
| -		ieee80211_send_delba(sdata, sta->sta.addr, tid, | ||||
| +		ieee80211_send_delba(sdata, sta->sta.addr, tid, tid_tx->ndp, | ||||
|  			WLAN_BACK_INITIATOR, WLAN_REASON_QSTA_NOT_USE); | ||||
|  } | ||||
|   | ||||
| @@ -1009,6 +1024,13 @@ | ||||
|  		goto out; | ||||
|  	} | ||||
|   | ||||
| +       if ((tid_tx->ndp && mgmt->u.action.u.addba_resp.action_code != WLAN_ACTION_NDP_ADDBA_RESP) || | ||||
| +           (!tid_tx->ndp && mgmt->u.action.u.addba_resp.action_code != WLAN_ACTION_ADDBA_RESP)) { | ||||
| +            ht_dbg(sta->sdata, "wrong addBA response action code, %d ndp %d\n", | ||||
| +                               mgmt->u.action.u.addba_resp.action_code, tid_tx->ndp); | ||||
| +           goto out; | ||||
| +       } | ||||
| + | ||||
|  	del_timer_sync(&tid_tx->addba_resp_timer); | ||||
|   | ||||
|  	ht_dbg(sta->sdata, "switched off addBA timer for %pM tid %d\n", | ||||
| --- a/net/mac80211/debugfs.c | ||||
| +++ b/net/mac80211/debugfs.c | ||||
| @@ -543,6 +543,7 @@ | ||||
|  	FLAG(SUPPORTS_RX_DECAP_OFFLOAD), | ||||
|  	FLAG(SUPPORTS_CONC_MON_RX_DECAP), | ||||
|  	FLAG(DETECTS_COLOR_COLLISION), | ||||
| +	FLAG(SUPPORTS_NDP_BLOCKACK), | ||||
|  #undef FLAG | ||||
|  }; | ||||
|   | ||||
| --- a/net/mac80211/ht.c | ||||
| +++ b/net/mac80211/ht.c | ||||
| @@ -365,7 +365,7 @@ | ||||
|  				       sta->ampdu_mlme.tid_rx_manage_offl)) | ||||
|  			___ieee80211_start_rx_ba_session(sta, 0, 0, 0, 1, tid, | ||||
|  							 IEEE80211_MAX_AMPDU_BUF_HT, | ||||
| -							 false, true, NULL); | ||||
| +							 false, true, false, NULL); | ||||
|   | ||||
|  		if (test_and_clear_bit(tid + IEEE80211_NUM_TIDS, | ||||
|  				       sta->ampdu_mlme.tid_rx_manage_offl)) | ||||
| @@ -412,7 +412,7 @@ | ||||
|  } | ||||
|   | ||||
|  void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata, | ||||
| -			  const u8 *da, u16 tid, | ||||
| +			  const u8 *da, u16 tid, bool ndp, | ||||
|  			  u16 initiator, u16 reason_code) | ||||
|  { | ||||
|  	struct ieee80211_local *local = sdata->local; | ||||
| @@ -443,7 +443,7 @@ | ||||
|  	skb_put(skb, 1 + sizeof(mgmt->u.action.u.delba)); | ||||
|   | ||||
|  	mgmt->u.action.category = WLAN_CATEGORY_BACK; | ||||
| -	mgmt->u.action.u.delba.action_code = WLAN_ACTION_DELBA; | ||||
| +	mgmt->u.action.u.delba.action_code = ndp ? WLAN_ACTION_NDP_DELBA : WLAN_ACTION_DELBA; | ||||
|  	params = (u16)(initiator << 11); 	/* bit 11 initiator */ | ||||
|  	params |= (u16)(tid << 12); 		/* bit 15:12 TID number */ | ||||
|   | ||||
| --- a/net/mac80211/ieee80211_i.h | ||||
| +++ b/net/mac80211/ieee80211_i.h | ||||
| @@ -1902,7 +1902,7 @@ | ||||
|  				       const struct ieee80211_ht_cap *ht_cap_ie, | ||||
|  				       struct sta_info *sta); | ||||
|  void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata, | ||||
| -			  const u8 *da, u16 tid, | ||||
| +			  const u8 *da, u16 tid, bool ndp, | ||||
|  			  u16 initiator, u16 reason_code); | ||||
|  int ieee80211_send_smps_action(struct ieee80211_sub_if_data *sdata, | ||||
|  			       enum ieee80211_smps_mode smps, const u8 *da, | ||||
| @@ -1919,7 +1919,7 @@ | ||||
|  void ___ieee80211_start_rx_ba_session(struct sta_info *sta, | ||||
|  				      u8 dialog_token, u16 timeout, | ||||
|  				      u16 start_seq_num, u16 ba_policy, u16 tid, | ||||
| -				      u16 buf_size, bool tx, bool auto_seq, | ||||
| +				      u16 buf_size, bool tx, bool auto_seq, bool ndp, | ||||
|  				      const struct ieee80211_addba_ext_ie *addbaext); | ||||
|  void ieee80211_sta_tear_down_BA_sessions(struct sta_info *sta, | ||||
|  					 enum ieee80211_agg_stop_reason reason); | ||||
| --- a/net/mac80211/iface.c | ||||
| +++ b/net/mac80211/iface.c | ||||
| @@ -1551,14 +1551,17 @@ | ||||
|  		if (sta) { | ||||
|  			switch (mgmt->u.action.u.addba_req.action_code) { | ||||
|  			case WLAN_ACTION_ADDBA_REQ: | ||||
| +			case WLAN_ACTION_NDP_ADDBA_REQ: | ||||
|  				ieee80211_process_addba_request(local, sta, | ||||
|  								mgmt, len); | ||||
|  				break; | ||||
|  			case WLAN_ACTION_ADDBA_RESP: | ||||
| +			case WLAN_ACTION_NDP_ADDBA_RESP: | ||||
|  				ieee80211_process_addba_resp(local, sta, | ||||
|  							     mgmt, len); | ||||
|  				break; | ||||
|  			case WLAN_ACTION_DELBA: | ||||
| +			case WLAN_ACTION_NDP_DELBA: | ||||
|  				ieee80211_process_delba(sdata, sta, | ||||
|  							mgmt, len); | ||||
|  				break; | ||||
| --- a/net/mac80211/rx.c | ||||
| +++ b/net/mac80211/rx.c | ||||
| @@ -1389,7 +1389,7 @@ | ||||
|  		if (ack_policy == IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK && | ||||
|  		    !test_bit(tid, rx->sta->ampdu_mlme.agg_session_valid) && | ||||
|  		    !test_and_set_bit(tid, rx->sta->ampdu_mlme.unexpected_agg)) | ||||
| -			ieee80211_send_delba(rx->sdata, rx->sta->sta.addr, tid, | ||||
| +			ieee80211_send_delba(rx->sdata, rx->sta->sta.addr, tid, false, | ||||
|  					     WLAN_BACK_RECIPIENT, | ||||
|  					     WLAN_REASON_QSTA_REQUIRE_SETUP); | ||||
|  		goto dont_reorder; | ||||
| @@ -3101,7 +3101,7 @@ | ||||
|   | ||||
|  		if (!test_bit(tid, rx->sta->ampdu_mlme.agg_session_valid) && | ||||
|  		    !test_and_set_bit(tid, rx->sta->ampdu_mlme.unexpected_agg)) | ||||
| -			ieee80211_send_delba(rx->sdata, rx->sta->sta.addr, tid, | ||||
| +			ieee80211_send_delba(rx->sdata, rx->sta->sta.addr, tid, false, | ||||
|  					     WLAN_BACK_RECIPIENT, | ||||
|  					     WLAN_REASON_QSTA_REQUIRE_SETUP); | ||||
|   | ||||
| @@ -3526,16 +3526,19 @@ | ||||
|   | ||||
|  		switch (mgmt->u.action.u.addba_req.action_code) { | ||||
|  		case WLAN_ACTION_ADDBA_REQ: | ||||
| +		case WLAN_ACTION_NDP_ADDBA_REQ: | ||||
|  			if (len < (IEEE80211_MIN_ACTION_SIZE + | ||||
|  				   sizeof(mgmt->u.action.u.addba_req))) | ||||
|  				goto invalid; | ||||
|  			break; | ||||
|  		case WLAN_ACTION_ADDBA_RESP: | ||||
| +		case WLAN_ACTION_NDP_ADDBA_RESP: | ||||
|  			if (len < (IEEE80211_MIN_ACTION_SIZE + | ||||
|  				   sizeof(mgmt->u.action.u.addba_resp))) | ||||
|  				goto invalid; | ||||
|  			break; | ||||
|  		case WLAN_ACTION_DELBA: | ||||
| +		case WLAN_ACTION_NDP_DELBA: | ||||
|  			if (len < (IEEE80211_MIN_ACTION_SIZE + | ||||
|  				   sizeof(mgmt->u.action.u.delba))) | ||||
|  				goto invalid; | ||||
| --- a/net/mac80211/sta_info.h | ||||
| +++ b/net/mac80211/sta_info.h | ||||
| @@ -170,6 +170,7 @@ | ||||
|   * @failed_bar_ssn: ssn of the last failed BAR tx attempt | ||||
|   * @bar_pending: BAR needs to be re-sent | ||||
|   * @amsdu: support A-MSDU withing A-MDPU | ||||
| + * @ndp: this session is using NDP block ACKs | ||||
|   * | ||||
|   * This structure's lifetime is managed by RCU, assignments to | ||||
|   * the array holding it must hold the aggregation mutex. | ||||
| @@ -198,6 +199,7 @@ | ||||
|  	u16 failed_bar_ssn; | ||||
|  	bool bar_pending; | ||||
|  	bool amsdu; | ||||
| +	bool ndp; | ||||
|  	u8 tid; | ||||
|  }; | ||||
|   | ||||
| @@ -225,6 +227,7 @@ | ||||
|   *	and ssn. | ||||
|   * @removed: this session is removed (but might have been found due to RCU) | ||||
|   * @started: this session has started (head ssn or higher was received) | ||||
| + * @ndp: this session is using NDP block ACKs | ||||
|   * | ||||
|   * This structure's lifetime is managed by RCU, assignments to | ||||
|   * the array holding it must hold the aggregation mutex. | ||||
| @@ -252,7 +255,8 @@ | ||||
|  	u8 tid; | ||||
|  	u8 auto_seq:1, | ||||
|  	   removed:1, | ||||
| -	   started:1; | ||||
| +	   started:1, | ||||
| +	   ndp:1; | ||||
|  }; | ||||
|   | ||||
|  /** | ||||
| @@ -169,7 +169,8 @@ | ||||
| 		compatible = "mediatek,eth-mac"; | ||||
| 		reg = <0>; | ||||
| 		phy-mode = "sgmii"; | ||||
| 		phy-handle = <&phy1>;      // add phy handler | ||||
| 		phy-handle = <&phy30>; | ||||
| 		phy-handle2 = <&phy1>; | ||||
| 		mtd-mac-address = <&factory 0x24>; | ||||
| 	}; | ||||
|  | ||||
| @@ -181,9 +182,9 @@ | ||||
| 		mtd-mac-address = <&factory 0x2a>; | ||||
| 	}; | ||||
|  | ||||
|         mdio: mdio-bus { | ||||
|                 #address-cells = <1>; | ||||
|                 #size-cells = <0>; | ||||
| 	mdio: mdio-bus { | ||||
| 		#address-cells = <1>; | ||||
| 		#size-cells = <0>; | ||||
|  | ||||
| 		phy0: ethernet-phy@0 { | ||||
| 			compatible = "ethernet-phy-id03a2.9461"; | ||||
| @@ -193,6 +194,16 @@ | ||||
| 			nvmem-cell-names = "phy-cal-data"; | ||||
| 		}; | ||||
|  | ||||
| 		phy30: ethernet-phy@30 { // AN8801SB | ||||
| 			compatible = "ethernet-phy-idc0ff.0421"; | ||||
| 			reg = <30>; //0x1e | ||||
| 			phy-mode = "sgmii"; | ||||
| 			full-duplex; | ||||
| 			pause; | ||||
| 			airoha,surge = <1>; | ||||
| 			airoha,polarity = <2>; | ||||
| 		}; | ||||
|  | ||||
| 		phy1: ethernet-phy@1 { | ||||
| 			compatible = "ethernet-phy-id03a2.9471"; | ||||
| 			reg = <24>;            // set phy address to 0x18 | ||||
| @@ -200,9 +211,8 @@ | ||||
| 			reset-assert-us = <600>; | ||||
| 			reset-deassert-us = <20000>; | ||||
| 			phy-mode = "sgmii"; | ||||
|     }; | ||||
|  | ||||
|         }; | ||||
| 		}; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &hnat { | ||||
|   | ||||
| @@ -255,18 +255,21 @@ | ||||
| &spi2 { | ||||
| 	pinctrl-names = "default"; | ||||
| 	pinctrl-0 = <&spi2_pins>; | ||||
|         address-cells = <1>; | ||||
|         size-cells = <0>; | ||||
| 	status = "okay"; | ||||
|  | ||||
| 	slb9670: slb9670@0 { | ||||
| 		compatible = "infineon,slb9670"; | ||||
| 		reg = <0>; /* CE0 */ | ||||
| 		#address-cells = <1>; | ||||
| 		#size-cells = <0>; | ||||
| 		spi-cal-enable; | ||||
| 		spi-cal-mode = "read-data"; | ||||
| 		spi-cal-datalen = <2>; | ||||
| 		spi-cal-data = /bits/ 8 <0x00 0x1b>; | ||||
| 		spi-max-frequency = <40000000>; | ||||
|  | ||||
|         mm6108: mm6108@0 { | ||||
|                 compatible = "morse,mm610x-spi"; | ||||
|                 reg = <0>; | ||||
|                 reset-gpios = <&pio 31 0>; | ||||
|                 power-gpios = <&pio 5 0>,<&pio 0 0>; | ||||
|                 spi-irq-gpios = <&pio 30 0>; | ||||
|                 status = "okay"; | ||||
|                 spi-max-frequency = <52000000>; | ||||
|                 spi-tx-bus-width = <1>; | ||||
|                 spi-rx-bus-width = <1>; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| @@ -338,6 +341,18 @@ | ||||
| 			function = "spi"; | ||||
| 			groups = "spi2"; | ||||
| 		}; | ||||
|  | ||||
|                 conf-pu { | ||||
|                         pins = "SPI2_CS"; | ||||
|                         drive-strength = <8>; | ||||
|                         mediatek,pull-up-adv = <3>; | ||||
|                 }; | ||||
|  | ||||
|                 conf-pd { | ||||
|                         pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO"; | ||||
|                         drive-strength = <8>; | ||||
|                         mediatek,pull-down-adv = <3>; | ||||
|                 }; | ||||
| 	}; | ||||
|  | ||||
| 	uart1_pins: uart1-pins-g1 { | ||||
|   | ||||
| @@ -0,0 +1,349 @@ | ||||
| /dts-v1/; | ||||
| #include "mt7981.dtsi" | ||||
| / { | ||||
| 	model = "Emplus WAP588M"; | ||||
| 	compatible = "emplus,wap588m"; | ||||
| 	chosen { | ||||
| 		bootargs = "console=ttyS0,115200n1 loglevel=8  \ | ||||
| 				earlycon=uart8250,mmio32,0x11002000"; | ||||
| 	}; | ||||
|  | ||||
| 	memory { | ||||
| 		reg = <0 0x40000000 0 0x10000000>; | ||||
| 	}; | ||||
|  | ||||
| 	gpio-keys { | ||||
| 		compatible = "gpio-keys"; | ||||
|  | ||||
| 		reset { | ||||
| 			label = "reset"; | ||||
| 			linux,code = <KEY_RESTART>; | ||||
| 			gpios = <&pio 1 GPIO_ACTIVE_LOW>; | ||||
| 				}; | ||||
| 	}; | ||||
|  | ||||
| 	leds { | ||||
| 		compatible = "gpio-leds"; | ||||
| 		power { | ||||
| 			label = "power"; | ||||
| 			gpios = <&pio 11 GPIO_ACTIVE_LOW>; | ||||
| 			linux,default-trigger = "timer"; | ||||
| 			default-state = "on"; | ||||
|  | ||||
| 		}; | ||||
| 		wifi2g { | ||||
| 			label = "wifi2g"; | ||||
| 			gpios = <&pio 9 GPIO_ACTIVE_LOW>; | ||||
| 			linux,default-trigger = "ra0"; | ||||
| 		}; | ||||
| 		wifi5g { | ||||
| 			label = "wifi5g"; | ||||
| 			gpios = <&pio 12 GPIO_ACTIVE_LOW>; | ||||
| 			linux,default-trigger = "rax0"; | ||||
| 		}; | ||||
| 		lan { | ||||
| 			label = "lan"; | ||||
| 			gpios = <&pio 10 GPIO_ACTIVE_LOW>; | ||||
| 			linux,default-trigger = "eth0"; | ||||
| 		}; | ||||
| 		wan { | ||||
| 			label = "wan"; | ||||
| 			gpios = <&pio 13 GPIO_ACTIVE_LOW>; | ||||
| 			linux,default-trigger = "eth1"; | ||||
| 		}; | ||||
| 	}; | ||||
|  | ||||
| 	nmbm_spim_nand { | ||||
| 		compatible = "generic,nmbm"; | ||||
|  | ||||
| 		#address-cells = <1>; | ||||
| 		#size-cells = <1>; | ||||
|  | ||||
| 		lower-mtd-device = <&spi_nand>; | ||||
| 		forced-create; | ||||
|  | ||||
| 		partitions { | ||||
| 			compatible = "fixed-partitions"; | ||||
| 			#address-cells = <1>; | ||||
| 			#size-cells = <1>; | ||||
|  | ||||
| 			partition@0 { | ||||
| 				label = "BL2"; | ||||
| 				reg = <0x00000 0x0100000>; | ||||
| 				read-only; | ||||
| 			}; | ||||
|  | ||||
| 			partition@100000 { | ||||
| 				label = "u-boot-env"; | ||||
| 				reg = <0x0100000 0x0080000>; | ||||
| 			}; | ||||
|  | ||||
| 			factory: partition@180000 { | ||||
| 				label = "Factory"; | ||||
| 				reg = <0x180000 0x0200000>; | ||||
| 			}; | ||||
|  | ||||
| 			partition@380000 { | ||||
| 				label = "FIP"; | ||||
| 				reg = <0x380000 0x0200000>; | ||||
| 			}; | ||||
|  | ||||
| 			partition@580000 { | ||||
| 				label = "ubi"; //110MB | ||||
| 				reg = <0x580000 0x3700000>; | ||||
| 			}; | ||||
|  | ||||
| 			partition@3C80000 { | ||||
| 				label = "ubi_1"; //110MB | ||||
| 				reg = <0x3C80000 0x3700000>; | ||||
| 			}; | ||||
|  | ||||
| 			partition@7380000 { | ||||
| 				label = "cert"; //384KB | ||||
| 				reg = <0x7380000 0x0060000>; | ||||
| 			}; | ||||
|  | ||||
| 			partition@73E0000 { | ||||
| 				label = "userconfig"; //640KB | ||||
| 				reg = <0x73E0000 0x00a0000>; | ||||
| 			}; | ||||
|  | ||||
| 			partition@7480000 { | ||||
| 				label = "crashdump"; //384KB | ||||
| 				reg = <0x7480000 0x0060000>; | ||||
| 			}; | ||||
| 		}; | ||||
| 	}; | ||||
|  | ||||
| 	sound_wm8960 { | ||||
| 		compatible = "mediatek,mt79xx-wm8960-machine"; | ||||
| 		mediatek,platform = <&afe>; | ||||
| 		audio-routing = "Headphone", "HP_L", | ||||
| 				"Headphone", "HP_R", | ||||
| 				"LINPUT1", "AMIC", | ||||
| 				"RINPUT1", "AMIC"; | ||||
| 		mediatek,audio-codec = <&wm8960>; | ||||
| 		status = "disabled"; | ||||
| 	}; | ||||
|  | ||||
| 	sound_si3218x { | ||||
| 		compatible = "mediatek,mt79xx-si3218x-machine"; | ||||
| 		mediatek,platform = <&afe>; | ||||
| 		mediatek,ext-codec = <&proslic_spi>; | ||||
| 		status = "disabled"; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &afe { | ||||
| 	pinctrl-names = "default"; | ||||
| 	pinctrl-0 = <&pcm_pins>; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &i2c0 { | ||||
| 	pinctrl-names = "default"; | ||||
| 	pinctrl-0 = <&i2c_pins>; | ||||
| 	status = "disabled"; | ||||
|  | ||||
| 	wm8960: wm8960@1a { | ||||
| 		compatible = "wlf,wm8960"; | ||||
| 		reg = <0x1a>; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &uart0 { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &watchdog { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| ð { | ||||
|         status = "okay"; | ||||
|  | ||||
|         gmac0: mac@0 { | ||||
|                 compatible = "mediatek,eth-mac"; | ||||
|                 reg = <0>; | ||||
|                 phy-mode = "sgmii"; | ||||
|                 phy-handle = <&phy1>; | ||||
|         }; | ||||
|  | ||||
| 	gmac1: mac@1 { | ||||
| 		compatible = "mediatek,eth-mac"; | ||||
| 		reg = <1>; | ||||
| 		phy-mode = "gmii"; | ||||
| 		phy-handle = <&phy0>; | ||||
| 	}; | ||||
|  | ||||
|         mdio: mdio-bus { | ||||
|                 #address-cells = <1>; | ||||
|                 #size-cells = <0>; | ||||
|  | ||||
| 		// MT7981 internal PHY | ||||
| 		phy0: ethernet-phy@0 { | ||||
| 			compatible = "ethernet-phy-id03a2.9461"; | ||||
| 			reg = <0>; | ||||
| 			phy-mode = "gmii"; | ||||
| 			nvmem-cells = <&phy_calibration>; | ||||
| 			nvmem-cell-names = "phy-cal-data"; | ||||
| 		}; | ||||
|  | ||||
|  | ||||
| 		// RTL8211FS PHY | ||||
| 		phy1: ethernet-phy@1 { | ||||
| 			compatible = "ethernet-phy-id001c.c916"; | ||||
| 			reg = <1>; | ||||
| 			reset-gpios = <&pio 39 GPIO_ACTIVE_LOW>; | ||||
| 			reset-assert-us = <120000>; | ||||
| 			reset-deassert-us = <120000>; | ||||
| 			phy-mode = "sgmii"; | ||||
| 		}; | ||||
|     }; | ||||
| }; | ||||
|  | ||||
| &hnat { | ||||
| 	mtketh-wan = "eth1"; | ||||
| 	mtketh-lan = "eth0"; | ||||
| 	mtketh-max-gmac = <2>; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &spi0 { | ||||
| 	pinctrl-names = "default"; | ||||
| 	pinctrl-0 = <&spi0_flash_pins>; | ||||
| 	status = "okay"; | ||||
| 	spi_nand: spi_nand@0 { | ||||
| 		#address-cells = <1>; | ||||
| 		#size-cells = <1>; | ||||
| 		compatible = "spi-nand"; | ||||
| 		reg = <0>; | ||||
| 		spi-max-frequency = <52000000>; | ||||
| 		spi-tx-bus-width = <4>; | ||||
| 		spi-rx-bus-width = <4>; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &spi1 { | ||||
| 	pinctrl-names = "default"; | ||||
| 	pinctrl-0 = <&spic_pins>; | ||||
| 	status = "okay"; | ||||
|  | ||||
| 	proslic_spi: proslic_spi@0 { | ||||
| 		compatible = "silabs,proslic_spi"; | ||||
| 		reg = <0>; | ||||
| 		spi-max-frequency = <10000000>; | ||||
| 		spi-cpha = <1>; | ||||
| 		spi-cpol = <1>; | ||||
| 		channel_count = <1>; | ||||
| 		debug_level = <4>;       /* 1 = TRC, 2 = DBG, 4 = ERR */ | ||||
| 		reset_gpio = <&pio 15 0>; | ||||
| 		ig,enable-spi = <1>;     /* 1: Enable, 0: Disable */ | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &wbsys { | ||||
| 	mediatek,mtd-eeprom = <&factory 0x0000>; | ||||
| 	status = "okay"; | ||||
| 	pinctrl-names = "dbdc"; | ||||
| 	pinctrl-0 = <&wf_dbdc_pins>; | ||||
| }; | ||||
|  | ||||
| &pio { | ||||
|  | ||||
| 	i2c_pins: i2c-pins-g0 { | ||||
|                 mux { | ||||
|                         function = "i2c"; | ||||
|                         groups = "i2c0_0"; | ||||
|                 }; | ||||
|         }; | ||||
|  | ||||
|         pcm_pins: pcm-pins-g0 { | ||||
|                 mux { | ||||
|                         function = "pcm"; | ||||
|                         groups = "pcm"; | ||||
|                 }; | ||||
|         }; | ||||
|  | ||||
|         pwm0_pin: pwm0-pin-g0 { | ||||
|                 mux { | ||||
|                         function = "pwm"; | ||||
|                         groups = "pwm0_0"; | ||||
|                 }; | ||||
|         }; | ||||
|  | ||||
|         pwm1_pin: pwm1-pin-g0 { | ||||
|                 mux { | ||||
|                         function = "pwm"; | ||||
|                         groups = "pwm1_0"; | ||||
|                 }; | ||||
|         }; | ||||
|  | ||||
|         pwm2_pin: pwm2-pin { | ||||
|                 mux { | ||||
|                         function = "pwm"; | ||||
|                         groups = "pwm2"; | ||||
|                 }; | ||||
|         }; | ||||
|  | ||||
| 	spi0_flash_pins: spi0-pins { | ||||
| 		mux { | ||||
| 			function = "spi"; | ||||
| 			groups = "spi0", "spi0_wp_hold"; | ||||
| 		}; | ||||
|  | ||||
| 		conf-pu { | ||||
| 			pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP"; | ||||
| 			drive-strength = <MTK_DRIVE_8mA>; | ||||
| 			bias-pull-up = <MTK_PUPD_SET_R1R0_11>; | ||||
| 		}; | ||||
|  | ||||
| 		conf-pd { | ||||
| 			pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO"; | ||||
| 			drive-strength = <MTK_DRIVE_8mA>; | ||||
| 			bias-pull-down = <MTK_PUPD_SET_R1R0_11>; | ||||
| 		}; | ||||
| 	}; | ||||
|  | ||||
| 	spic_pins: spi1-pins { | ||||
| 		mux { | ||||
| 			function = "spi"; | ||||
| 			groups = "spi1_1"; | ||||
| 		}; | ||||
| 	}; | ||||
|  | ||||
| 	uart1_pins: uart1-pins-g1 { | ||||
|                 mux { | ||||
|                         function = "uart"; | ||||
|                         groups = "uart1_1"; | ||||
|                 }; | ||||
|         }; | ||||
|  | ||||
| 	uart2_pins: uart2-pins-g1 { | ||||
| 		mux { | ||||
|                         function = "uart"; | ||||
|                         groups = "uart2_1"; | ||||
|                 }; | ||||
|         }; | ||||
| 	wf_dbdc_pins: wf_dbdc-pins { | ||||
| 		mux { | ||||
| 			function = "eth"; | ||||
| 			groups = "wf0_mode1"; | ||||
| 		}; | ||||
| 		conf { | ||||
| 			pins = "WF_HB1", "WF_HB2", "WF_HB3", "WF_HB4", | ||||
| 			       "WF_HB0", "WF_HB0_B", "WF_HB5", "WF_HB6", | ||||
| 			       "WF_HB7", "WF_HB8", "WF_HB9", "WF_HB10", | ||||
| 			       "WF_TOP_CLK", "WF_TOP_DATA", "WF_XO_REQ", | ||||
| 			       "WF_CBA_RESETB", "WF_DIG_RESETB"; | ||||
| 			drive-strength = <MTK_DRIVE_4mA>; | ||||
| 		}; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &xhci { | ||||
| 	mediatek,u3p-dis-msk = <0x0>; | ||||
| 	phys = <&u2port0 PHY_TYPE_USB2>, | ||||
| 	       <&u3port0 PHY_TYPE_USB3>; | ||||
| 	status = "disabled"; | ||||
| }; | ||||
| @@ -113,7 +113,6 @@ static const struct AIR_LED_CFG_T led_cfg_dlt[MAX_LED_SIZE] = { | ||||
| 	/* LED2 */ | ||||
| 	{LED_ENABLE, AIR_LED_GPIO9, AIR_ACTIVE_LOW,  AIR_LED2_ON, AIR_LED2_BLK}, | ||||
| }; | ||||
|  | ||||
| static const u16 led_blink_cfg_dlt = AIR_LED_BLK_DUR_64M; | ||||
| /* RGMII delay */ | ||||
| static const u8 rxdelay_force = FALSE; | ||||
| @@ -140,7 +139,6 @@ static int __air_buckpbus_reg_write(struct phy_device *phydev, u32 addr, | ||||
| 	err |= mbus->write(mbus, phy_addr, 0x13, (u16)(data >> 16)); | ||||
| 	err |= mbus->write(mbus, phy_addr, 0x14, (u16)(data & 0xffff)); | ||||
| 	err |= mbus->write(mbus, phy_addr, 0x1F, 0); | ||||
|  | ||||
| 	return err; | ||||
| } | ||||
|  | ||||
| @@ -167,6 +165,41 @@ static u32 __air_buckpbus_reg_read(struct phy_device *phydev, u32 addr) | ||||
| 	return data; | ||||
| } | ||||
|  | ||||
| static u32 __air_buckpbus_reg_modify(struct phy_device *phydev, u32 addr, | ||||
| 					u32 mask, u32 set) | ||||
| { | ||||
| 	int err = 0; | ||||
| 	u32 data_h, data_l, data_old, data_new; | ||||
| 	int phy_addr = phydev_phy_addr(phydev); | ||||
| 	struct mii_bus *mbus = phydev_mdiobus(phydev); | ||||
|  | ||||
| 	err = mbus->write(mbus, phy_addr, 0x1F, 4); | ||||
| 	err |= mbus->write(mbus, phy_addr, 0x10, 0); | ||||
| 	err |= mbus->write(mbus, phy_addr, 0x15, (u16)(addr >> 16)); | ||||
| 	err |= mbus->write(mbus, phy_addr, 0x16, (u16)(addr & 0xffff)); | ||||
| 	data_h = mbus->read(mbus, phy_addr, 0x17); | ||||
| 	data_l = mbus->read(mbus, phy_addr, 0x18); | ||||
| 	if (err < 0) { | ||||
| 		mbus->write(mbus, phy_addr, 0x1F, 0); | ||||
| 		return INVALID_DATA; | ||||
| 	} | ||||
|  | ||||
| 	data_old = ((data_h & 0xffff) << 16) | (data_l & 0xffff); | ||||
| 	data_new = (data_old & ~mask) | set; | ||||
| 	if (data_new == data_old) { | ||||
| 		mbus->write(mbus, phy_addr, 0x1F, 0); | ||||
| 		return 0; | ||||
| 	} | ||||
|  | ||||
| 	err |= mbus->write(mbus, phy_addr, 0x11, (u16)(addr >> 16)); | ||||
| 	err |= mbus->write(mbus, phy_addr, 0x12, (u16)(addr & 0xffff)); | ||||
| 	err |= mbus->write(mbus, phy_addr, 0x13, (u16)(data_new >> 16)); | ||||
| 	err |= mbus->write(mbus, phy_addr, 0x14, (u16)(data_new & 0xffff)); | ||||
| 	err |= mbus->write(mbus, phy_addr, 0x1F, 0); | ||||
|  | ||||
| 	return err; | ||||
| } | ||||
|  | ||||
| static int air_buckpbus_reg_write(struct phy_device *phydev, u32 addr, u32 data) | ||||
| { | ||||
| 	int err = 0; | ||||
| @@ -189,82 +222,18 @@ static u32 air_buckpbus_reg_read(struct phy_device *phydev, u32 addr) | ||||
| 	return data; | ||||
| } | ||||
|  | ||||
| static int __an8801_cl45_write(struct phy_device *phydev, int devad, u16 reg, | ||||
| 				u16 val) | ||||
| { | ||||
| 	u32 addr = (AN8801_EPHY_ADDR | AN8801_CL22 | (devad << 18) | | ||||
| 				(reg << 2)); | ||||
|  | ||||
| 	return __air_buckpbus_reg_write(phydev, addr, val); | ||||
| } | ||||
|  | ||||
| static int __an8801_cl45_read(struct phy_device *phydev, int devad, u16 reg) | ||||
| { | ||||
| 	u32 addr = (AN8801_EPHY_ADDR | AN8801_CL22 | (devad << 18) | | ||||
| 				(reg << 2)); | ||||
|  | ||||
| 	return __air_buckpbus_reg_read(phydev, addr); | ||||
| } | ||||
|  | ||||
| int __an8801_modify_cl45_changed(struct phy_device *phydev, int devad, u32 regnum, | ||||
| 				u16 mask, u16 set) | ||||
| { | ||||
| 	int new, ret; | ||||
|  | ||||
| 	ret = __an8801_cl45_read(phydev, devad, regnum); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
|  | ||||
| 	new = (ret & ~mask) | set; | ||||
| 	if (new == ret) | ||||
| 		return 0; | ||||
|  | ||||
| 	ret = __an8801_cl45_write(phydev, devad, regnum, new); | ||||
|  | ||||
| 	return ret < 0 ? ret : 1; | ||||
| } | ||||
|  | ||||
| static int an8801_modify_cl45_changed(struct phy_device *phydev, int devad, | ||||
| 				u32 regnum, u16 mask, u16 set) | ||||
| static int air_buckpbus_reg_modify(struct phy_device *phydev, u32 addr, | ||||
| 					u32 mask, u32 set) | ||||
| { | ||||
| 	int err = 0; | ||||
|  | ||||
| 	mdiobus_lock(phydev); | ||||
| 	err = __an8801_modify_cl45_changed(phydev, devad, regnum, mask, set); | ||||
| 	err = __air_buckpbus_reg_modify(phydev, addr, mask, set); | ||||
| 	mdiobus_unlock(phydev); | ||||
|  | ||||
| 	return err; | ||||
| } | ||||
|  | ||||
| static int an8801_cl45_write(struct phy_device *phydev, int devad, u16 reg, | ||||
| 			      u16 val) | ||||
| { | ||||
| 	int err = 0; | ||||
|  | ||||
| 	mdiobus_lock(phydev); | ||||
| 	err = __an8801_cl45_write(phydev, devad, reg, val); | ||||
| 	mdiobus_unlock(phydev); | ||||
|  | ||||
| 	return err; | ||||
| } | ||||
|  | ||||
| static int an8801_cl45_read(struct phy_device *phydev, int devad, u16 reg, | ||||
| 			     u16 *read_data) | ||||
| { | ||||
| 	int data = 0; | ||||
|  | ||||
| 	mdiobus_lock(phydev); | ||||
| 	data = __an8801_cl45_read(phydev, devad, reg); | ||||
| 	mdiobus_unlock(phydev); | ||||
|  | ||||
| 	if (data == INVALID_DATA) | ||||
| 		return -EINVAL; | ||||
|  | ||||
| 	*read_data = data; | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static int air_sw_reset(struct phy_device *phydev) | ||||
| { | ||||
| 	u32 reg_value; | ||||
| @@ -298,50 +267,36 @@ static int an8801_led_set_usr_def(struct phy_device *phydev, u8 entity, | ||||
|  | ||||
| 	on_evt |= LED_ON_EN; | ||||
|  | ||||
| 	err = an8801_cl45_write(phydev, 0x1f, LED_ON_CTRL(entity), on_evt); | ||||
| 	err = phy_write_mmd(phydev, 0x1f, LED_ON_CTRL(entity), on_evt); | ||||
| 	if (err) | ||||
| 		return -1; | ||||
|  | ||||
| 	return an8801_cl45_write(phydev, 0x1f, LED_BLK_CTRL(entity), blk_evt); | ||||
| 	return phy_write_mmd(phydev, 0x1f, LED_BLK_CTRL(entity), blk_evt); | ||||
| } | ||||
|  | ||||
| static int an8801_led_set_mode(struct phy_device *phydev, u8 mode) | ||||
| { | ||||
| 	int err; | ||||
| 	u16 data; | ||||
|  | ||||
| 	err = an8801_cl45_read(phydev, 0x1f, LED_BCR, &data); | ||||
| 	if (err) | ||||
| 		return -1; | ||||
|  | ||||
| 	switch (mode) { | ||||
| 	case AIR_LED_MODE_DISABLE: | ||||
| 		data &= ~LED_BCR_EXT_CTRL; | ||||
| 		data &= ~LED_BCR_MODE_MASK; | ||||
| 		data |= LED_BCR_MODE_DISABLE; | ||||
| 		break; | ||||
| 		return phy_modify_mmd(phydev, 0x1f, LED_BCR, | ||||
| 						(LED_BCR_EXT_CTRL | LED_BCR_CLK_EN), | ||||
| 						0x0); | ||||
| 	case AIR_LED_MODE_USER_DEFINE: | ||||
| 		data |= (LED_BCR_EXT_CTRL | LED_BCR_CLK_EN); | ||||
| 		return phy_modify_mmd(phydev, 0x1f, LED_BCR, | ||||
| 						(LED_BCR_EXT_CTRL | LED_BCR_CLK_EN), | ||||
| 						(LED_BCR_EXT_CTRL | LED_BCR_CLK_EN)); | ||||
| 	default: | ||||
| 		break; | ||||
| 	} | ||||
| 	return an8801_cl45_write(phydev, 0x1f, LED_BCR, data); | ||||
| 	dev_err(phydev_dev(phydev), | ||||
| 				"LED mode %d is not supported\n", mode); | ||||
| 	return -EINVAL; | ||||
| } | ||||
|  | ||||
| static int an8801_led_set_state(struct phy_device *phydev, u8 entity, u8 state) | ||||
| { | ||||
| 	u16 data; | ||||
| 	int err; | ||||
|  | ||||
| 	err = an8801_cl45_read(phydev, 0x1f, LED_ON_CTRL(entity), &data); | ||||
| 	if (err) | ||||
| 		return err; | ||||
|  | ||||
| 	if (state) | ||||
| 		data |= LED_ON_EN; | ||||
| 	else | ||||
| 		data &= ~LED_ON_EN; | ||||
|  | ||||
| 	return an8801_cl45_write(phydev, 0x1f, LED_ON_CTRL(entity), data); | ||||
| 	return phy_modify_mmd(phydev, 0x1f, LED_ON_CTRL(entity), LED_ON_EN, | ||||
| 					(state) ? LED_ON_EN : 0x0); | ||||
| } | ||||
|  | ||||
| static int an8801_led_init(struct phy_device *phydev) | ||||
| @@ -352,12 +307,12 @@ static int an8801_led_init(struct phy_device *phydev) | ||||
| 	u32 data; | ||||
| 	u16 led_blink_cfg = priv->led_blink_cfg; | ||||
|  | ||||
| 	ret = an8801_cl45_write(phydev, 0x1f, LED_BLK_DUR, | ||||
| 	ret = phy_write_mmd(phydev, 0x1f, LED_BLK_DUR, | ||||
| 				 LED_BLINK_DURATION(led_blink_cfg)); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
|  | ||||
| 	ret = an8801_cl45_write(phydev, 0x1f, LED_ON_DUR, | ||||
| 	ret = phy_write_mmd(phydev, 0x1f, LED_ON_DUR, | ||||
| 				 (LED_BLINK_DURATION(led_blink_cfg) >> 1)); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
| @@ -406,6 +361,56 @@ static int an8801_led_init(struct phy_device *phydev) | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static int an8801_ack_interrupt(struct phy_device *phydev) | ||||
| { | ||||
| 	u32 reg_val = 0; | ||||
|  | ||||
| 	air_buckpbus_reg_write(phydev, 0x10285404, 0x102); | ||||
| 	reg_val = air_buckpbus_reg_read(phydev, 0x10285400); | ||||
| 	air_buckpbus_reg_write(phydev, 0x10285400, 0x0); | ||||
| 	air_buckpbus_reg_write(phydev, 0x10285400, reg_val | 0x10); | ||||
| 	air_buckpbus_reg_write(phydev, 0x10285404, 0x12); | ||||
| 	air_buckpbus_reg_write(phydev, 0x10285704, 0x1f); | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static int an8801_config_intr(struct phy_device *phydev) | ||||
| { | ||||
| 	if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { | ||||
| 		air_buckpbus_reg_write(phydev, 0x1000007c, BIT(AIR_INTERRUPT_GPIO) << 16); | ||||
| 		air_buckpbus_reg_modify(phydev, 0x10285700, 0x1, 0x1); | ||||
| 	} else { | ||||
| 		air_buckpbus_reg_write(phydev, 0x1000007c, 0x0); | ||||
| 		air_buckpbus_reg_modify(phydev, 0x10285700, 0x1, 0x0); | ||||
| 	} | ||||
| 	an8801_ack_interrupt(phydev); | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static int an8801_did_interrupt(struct phy_device *phydev) | ||||
| { | ||||
| 	u32 reg_val = 0; | ||||
|  | ||||
| 	reg_val = air_buckpbus_reg_read(phydev, 0x10285704); | ||||
|  | ||||
| 	if (reg_val & 0x11) | ||||
| 		return 1; | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| #if (KERNEL_VERSION(5, 11, 0) < LINUX_VERSION_CODE) | ||||
| static irqreturn_t an8801_handle_interrupt(struct phy_device *phydev) | ||||
| { | ||||
| 	if (!an8801_did_interrupt(phydev)) | ||||
| 		return IRQ_NONE; | ||||
|  | ||||
| 	an8801_ack_interrupt(phydev); | ||||
| 	phy_trigger_machine(phydev); | ||||
| 	return IRQ_HANDLED; | ||||
| } | ||||
| #endif | ||||
|  | ||||
| static int findClosestNumber(const u16 *arr, u16 size, u16 target) | ||||
| { | ||||
| 	int left = 0, right = size - 1; | ||||
| @@ -431,77 +436,77 @@ static int findClosestNumber(const u16 *arr, u16 size, u16 target) | ||||
| static int an8801sb_i2mpb_config(struct phy_device *phydev) | ||||
| { | ||||
| 	int ret = 0; | ||||
| 	u16 cl45_value = 0, temp_cl45 = 0, set = 0; | ||||
| 	u16 cl45_value = 0, temp_cl45 = 0; | ||||
| 	u16 mask = 0; | ||||
|  | ||||
| 	ret = an8801_cl45_read(phydev, MMD_DEV_VSPEC1, 0x12, &cl45_value); | ||||
| 	cl45_value = phy_read_mmd(phydev, MMD_DEV_VSPEC1, 0x12); | ||||
| 	dev_dbg(phydev_dev(phydev), "%s:%d cl45_value 0x%x!\n", __func__, __LINE__, cl45_value); | ||||
| 	cl45_value = (cl45_value & GENMASK(15, 10)) + (6 << 10); | ||||
| 	ret = an8801_modify_cl45_changed(phydev, MMD_DEV_VSPEC1, 0x12, GENMASK(15, 10), cl45_value); | ||||
| 	ret = phy_modify_mmd(phydev, MMD_DEV_VSPEC1, 0x12, GENMASK(15, 10), cl45_value); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
| 	ret = an8801_cl45_read(phydev, MMD_DEV_VSPEC1, 0x16, &temp_cl45); | ||||
| 	temp_cl45 = phy_read_mmd(phydev, MMD_DEV_VSPEC1, 0x16); | ||||
| 	dev_dbg(phydev_dev(phydev), "%s:%d cl45_value 0x%x!\n", __func__, __LINE__, temp_cl45); | ||||
| 	mask = GENMASK(15, 10) | GENMASK(5, 0); | ||||
| 	cl45_value = (temp_cl45 & GENMASK(15, 10)) + (9 << 10); | ||||
| 	cl45_value = ((temp_cl45 & GENMASK(5, 0)) + 6) | cl45_value; | ||||
| 	ret = an8801_modify_cl45_changed(phydev, MMD_DEV_VSPEC1, 0x16, mask, cl45_value); | ||||
| 	ret = phy_modify_mmd(phydev, MMD_DEV_VSPEC1, 0x16, mask, cl45_value); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
| 	ret = an8801_cl45_read(phydev, MMD_DEV_VSPEC1, 0x17, &cl45_value); | ||||
| 	cl45_value = phy_read_mmd(phydev, MMD_DEV_VSPEC1, 0x17); | ||||
| 	dev_dbg(phydev_dev(phydev), "%s:%d cl45_value 0x%x!\n", __func__, __LINE__, cl45_value); | ||||
| 	cl45_value = (cl45_value & GENMASK(13, 8)) + (6 << 8); | ||||
| 	ret = an8801_modify_cl45_changed(phydev, MMD_DEV_VSPEC1, 0x17, GENMASK(13, 8), cl45_value); | ||||
| 	ret = phy_modify_mmd(phydev, MMD_DEV_VSPEC1, 0x17, GENMASK(13, 8), cl45_value); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
| 	ret = an8801_cl45_read(phydev, MMD_DEV_VSPEC1, 0x18, &temp_cl45); | ||||
| 	temp_cl45 = phy_read_mmd(phydev, MMD_DEV_VSPEC1, 0x18); | ||||
| 	dev_dbg(phydev_dev(phydev), "%s:%d cl45_value 0x%x!\n", __func__, __LINE__, temp_cl45); | ||||
| 	mask = GENMASK(13, 8) | GENMASK(5, 0); | ||||
| 	cl45_value = (temp_cl45 & GENMASK(13, 8)) + (9 << 8); | ||||
| 	cl45_value = ((temp_cl45 & GENMASK(5, 0)) + 6) | cl45_value; | ||||
| 	ret = an8801_modify_cl45_changed(phydev, MMD_DEV_VSPEC1, 0x18, mask, cl45_value); | ||||
| 	ret = phy_modify_mmd(phydev, MMD_DEV_VSPEC1, 0x18, mask, cl45_value); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
| 	ret = an8801_cl45_read(phydev, MMD_DEV_VSPEC1, 0x19, &cl45_value); | ||||
| 	cl45_value = phy_read_mmd(phydev, MMD_DEV_VSPEC1, 0x19); | ||||
| 	dev_dbg(phydev_dev(phydev), "%s:%d cl45_value 0x%x!\n", __func__, __LINE__, cl45_value); | ||||
| 	cl45_value = (cl45_value & GENMASK(13, 8)) + (6 << 8); | ||||
| 	ret = an8801_modify_cl45_changed(phydev, MMD_DEV_VSPEC1, 0x19, GENMASK(13, 8), cl45_value); | ||||
| 	ret = phy_modify_mmd(phydev, MMD_DEV_VSPEC1, 0x19, GENMASK(13, 8), cl45_value); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
| 	ret = an8801_cl45_read(phydev, MMD_DEV_VSPEC1, 0x20, &cl45_value); | ||||
| 	cl45_value = phy_read_mmd(phydev, MMD_DEV_VSPEC1, 0x20); | ||||
| 	dev_dbg(phydev_dev(phydev), "%s:%d cl45_value 0x%x!\n", __func__, __LINE__, cl45_value); | ||||
| 	cl45_value = (cl45_value & GENMASK(5, 0)) + 6; | ||||
| 	ret = an8801_modify_cl45_changed(phydev, MMD_DEV_VSPEC1, 0x20, GENMASK(5, 0), cl45_value); | ||||
| 	ret = phy_modify_mmd(phydev, MMD_DEV_VSPEC1, 0x20, GENMASK(5, 0), cl45_value); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
| 	ret = an8801_cl45_read(phydev, MMD_DEV_VSPEC1, 0x21, &cl45_value); | ||||
| 	cl45_value = phy_read_mmd(phydev, MMD_DEV_VSPEC1, 0x21); | ||||
| 	dev_dbg(phydev_dev(phydev), "%s:%d cl45_value 0x%x!\n", __func__, __LINE__, cl45_value); | ||||
| 	cl45_value = (cl45_value & GENMASK(13, 8)) + (6 << 8); | ||||
| 	ret = an8801_modify_cl45_changed(phydev, MMD_DEV_VSPEC1, 0x21, GENMASK(13, 8), cl45_value); | ||||
| 	ret = phy_modify_mmd(phydev, MMD_DEV_VSPEC1, 0x21, GENMASK(13, 8), cl45_value); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
| 	ret = an8801_cl45_read(phydev, MMD_DEV_VSPEC1, 0x22, &cl45_value); | ||||
| 	cl45_value = phy_read_mmd(phydev, MMD_DEV_VSPEC1, 0x22); | ||||
| 	dev_dbg(phydev_dev(phydev), "%s:%d cl45_value 0x%x!\n", __func__, __LINE__, cl45_value); | ||||
| 	cl45_value = (cl45_value & GENMASK(5, 0)) + 6; | ||||
| 	ret = an8801_modify_cl45_changed(phydev, MMD_DEV_VSPEC1, 0x22, GENMASK(5, 0), cl45_value); | ||||
| 	ret = phy_modify_mmd(phydev, MMD_DEV_VSPEC1, 0x22, GENMASK(5, 0), cl45_value); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
| 	ret = an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0x23, 0x883); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0x24, 0x883); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0x25, 0x883); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0x26, 0x883); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0x0, 0x100); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0x1, 0x1bc); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0x2, 0x1d0); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0x3, 0x186); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0x4, 0x202); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0x5, 0x20e); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0x6, 0x300); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0x7, 0x3c0); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0x8, 0x3d0); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0x9, 0x317); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0xa, 0x206); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC1, 0xb, 0xe); | ||||
| 	ret = phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0x23, 0x883); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0x24, 0x883); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0x25, 0x883); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0x26, 0x883); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0x0, 0x100); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0x1, 0x1bc); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0x2, 0x1d0); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0x3, 0x186); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0x4, 0x202); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0x5, 0x20e); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0x6, 0x300); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0x7, 0x3c0); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0x8, 0x3d0); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0x9, 0x317); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0xa, 0x206); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC1, 0xb, 0xe); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
|  | ||||
| @@ -510,14 +515,14 @@ static int an8801sb_i2mpb_config(struct phy_device *phydev) | ||||
| } | ||||
|  | ||||
| void update_r50_value(struct phy_device *phydev, | ||||
| 			u16 *cl45_value, int pos1, int pos2) | ||||
| 	u16 *cl45_value, int pos1, int pos2) | ||||
| { | ||||
| 	*cl45_value &= ~(0x007f << 8); | ||||
| 	*cl45_value |= ((r50ohm_table[pos1]) & 0x007f) << 8; | ||||
| 	*cl45_value &= ~(0x007f); | ||||
| 	*cl45_value |= (r50ohm_table[pos2]) & 0x007f; | ||||
| 	dev_dbg(phydev_dev(phydev), "Read: r50ohm_tx_1=%d r50ohm_tx_2=%d\n", | ||||
| 			r50ohm_table[pos1], r50ohm_table[pos2]); | ||||
| 		r50ohm_table[pos1], r50ohm_table[pos2]); | ||||
| } | ||||
|  | ||||
| int calculate_position(int pos, int shift, int table_size) | ||||
| @@ -529,7 +534,7 @@ int calculate_position(int pos, int shift, int table_size) | ||||
| } | ||||
|  | ||||
| int process_r50(struct phy_device *phydev, int reg, | ||||
| 			u16 *cl45_value, u16 *r50ohm_tx_a, u16 *r50ohm_tx_b) | ||||
| 	u16 *cl45_value, u16 *r50ohm_tx_a, u16 *r50ohm_tx_b) | ||||
| { | ||||
| 	int pos1 = findClosestNumber(r50ohm_table, r50ohm_table_size, *r50ohm_tx_a); | ||||
| 	int pos2 = findClosestNumber(r50ohm_table, r50ohm_table_size, *r50ohm_tx_b); | ||||
| @@ -539,7 +544,7 @@ int process_r50(struct phy_device *phydev, int reg, | ||||
| 		pos2 = calculate_position(pos2, R50_SHIFT, r50ohm_table_size); | ||||
|  | ||||
| 		update_r50_value(phydev, cl45_value, pos1, pos2); | ||||
| 		return an8801_cl45_write(phydev, 0x1e, reg, *cl45_value); | ||||
| 		return phy_write_mmd(phydev, 0x1e, reg, *cl45_value); | ||||
| 	} | ||||
| 	return 0; | ||||
| } | ||||
| @@ -558,10 +563,10 @@ static int an8801r_of_init(struct phy_device *phydev) | ||||
| 			return -1; | ||||
| 		} | ||||
| 		if (val < AIR_RGMII_DELAY_NOSTEP || | ||||
| 		    val > AIR_RGMII_DELAY_STEP_7) { | ||||
| 			val > AIR_RGMII_DELAY_STEP_7) { | ||||
| 			dev_err(phydev_dev(phydev), | ||||
| 				   "airoha,rxclk-delay value %u out of range.", | ||||
| 				   val); | ||||
| 					"airoha,rxclk-delay value %u out of range.", | ||||
| 					val); | ||||
| 			return -1; | ||||
| 		} | ||||
| 		priv->rxdelay_force = TRUE; | ||||
| @@ -574,14 +579,14 @@ static int an8801r_of_init(struct phy_device *phydev) | ||||
| 		if (of_property_read_u32(of_node, "airoha,txclk-delay", | ||||
| 					 &val) != 0) { | ||||
| 			dev_err(phydev_dev(phydev), | ||||
| 				   "airoha,txclk-delay value is invalid."); | ||||
| 					"airoha,txclk-delay value is invalid."); | ||||
| 			return -1; | ||||
| 		} | ||||
| 		if (val < AIR_RGMII_DELAY_NOSTEP || | ||||
| 		    val > AIR_RGMII_DELAY_STEP_7) { | ||||
| 			val > AIR_RGMII_DELAY_STEP_7) { | ||||
| 			dev_err(phydev_dev(phydev), | ||||
| 				   "airoha,txclk-delay value %u out of range.", | ||||
| 				   val); | ||||
| 					"airoha,txclk-delay value %u out of range.", | ||||
| 					val); | ||||
| 			return -1; | ||||
| 		} | ||||
| 		priv->txdelay_force = TRUE; | ||||
| @@ -603,10 +608,10 @@ static int an8801sb_of_init(struct phy_device *phydev) | ||||
| 			return -1; | ||||
| 		} | ||||
| 		if (val < AIR_POL_TX_NOR_RX_REV || | ||||
| 		    val > AIR_POL_TX_REV_RX_NOR) { | ||||
| 			val > AIR_POL_TX_REV_RX_NOR) { | ||||
| 			dev_err(phydev_dev(phydev), | ||||
| 				   "airoha,polarity value %u out of range.", | ||||
| 				   val); | ||||
| 					"airoha,polarity value %u out of range.", | ||||
| 					val); | ||||
| 			return -1; | ||||
| 		} | ||||
| 		priv->pol = val; | ||||
| @@ -615,15 +620,15 @@ static int an8801sb_of_init(struct phy_device *phydev) | ||||
|  | ||||
| 	if (of_find_property(of_node, "airoha,surge", NULL)) { | ||||
| 		if (of_property_read_u32(of_node, "airoha,surge", | ||||
| 					&val) != 0) { | ||||
| 					 &val) != 0) { | ||||
| 			dev_err(phydev_dev(phydev), "airoha,surge value is invalid."); | ||||
| 			return -1; | ||||
| 		} | ||||
| 		if (val < AIR_SURGE_0R || | ||||
| 			val > AIR_SURGE_5R) { | ||||
| 			dev_err(phydev_dev(phydev), | ||||
| 				"airoha,surge value %u out of range.", | ||||
| 				val); | ||||
| 					"airoha,surge value %u out of range.", | ||||
| 					val); | ||||
| 			return -1; | ||||
| 		} | ||||
| 		priv->surge = val; | ||||
| @@ -693,23 +698,19 @@ int an8801sb_surge_protect_cfg(struct phy_device *phydev) | ||||
| 	u16 cl45_value = 0; | ||||
|  | ||||
| 	if (priv->surge) { | ||||
| 		ret = an8801_cl45_read(phydev, 0x1e, 0x174, &cl45_value); | ||||
| 		if (ret < 0) | ||||
| 			return ret; | ||||
| 		cl45_value = phy_read_mmd(phydev, 0x1e, 0x174); | ||||
| 		r50ohm_tx_a = (cl45_value >> 8) & 0x007f; | ||||
| 		r50ohm_tx_b = cl45_value & 0x007f; | ||||
| 		dev_dbg(phydev_dev(phydev), "Read: (0x174) value=0x%04x r50ohm_tx_a=%d r50ohm_tx_b=%d\n", | ||||
| 		cl45_value, r50ohm_tx_a, r50ohm_tx_b); | ||||
| 			cl45_value, r50ohm_tx_a, r50ohm_tx_b); | ||||
| 		ret = process_r50(phydev, 0x174, &cl45_value, &r50ohm_tx_a, &r50ohm_tx_b); | ||||
| 		if (ret < 0) | ||||
| 			return ret; | ||||
| 		ret = an8801_cl45_read(phydev, 0x1e, 0x175, &cl45_value); | ||||
| 		if (ret < 0) | ||||
| 			return ret; | ||||
| 		cl45_value = phy_read_mmd(phydev, 0x1e, 0x175); | ||||
| 		r50ohm_tx_c = (cl45_value >> 8) & 0x007f; | ||||
| 		r50ohm_tx_d = cl45_value & 0x007f; | ||||
| 		dev_dbg(phydev_dev(phydev), "Read: (0x175) value=0x%04x r50ohm_tx_c=%d r50ohm_tx_d=%d\n", | ||||
| 		cl45_value, r50ohm_tx_c, r50ohm_tx_d); | ||||
| 			cl45_value, r50ohm_tx_c, r50ohm_tx_d); | ||||
| 		ret = process_r50(phydev, 0x175, &cl45_value, &r50ohm_tx_c, &r50ohm_tx_d); | ||||
| 		if (ret < 0) | ||||
| 			return ret; | ||||
| @@ -764,10 +765,10 @@ static int an8801sb_config_init(struct phy_device *phydev) | ||||
| 	dev_info(phydev_dev(phydev), | ||||
| 		"Tx, Rx Polarity : %08x\n", pbus_value); | ||||
|  | ||||
| 	ret = an8801_cl45_write(phydev, MMD_DEV_VSPEC2, 0x600, 0x1e); | ||||
| 	ret |= an8801_cl45_write(phydev, MMD_DEV_VSPEC2, 0x601, 0x02); | ||||
| 	ret = phy_write_mmd(phydev, MMD_DEV_VSPEC2, 0x600, 0x1e); | ||||
| 	ret |= phy_write_mmd(phydev, MMD_DEV_VSPEC2, 0x601, 0x02); | ||||
|  | ||||
| 	ret |= an8801_cl45_write(phydev, 7, 60, 0x0); | ||||
| 	ret |= phy_write_mmd(phydev, 7, 60, 0x0); | ||||
| 	if (ret != 0) { | ||||
| 		dev_err(phydev_dev(phydev), | ||||
| 			"AN8801SB initialize fail, ret %d !\n", ret); | ||||
| @@ -940,7 +941,7 @@ static ssize_t an8801_polarity_write(struct file *file, const char __user *ptr, | ||||
| } | ||||
|  | ||||
| static ssize_t an8801_mdio_write(struct file *file, const char __user *ptr, | ||||
| 				size_t len, loff_t *off) | ||||
| 					size_t len, loff_t *off) | ||||
| { | ||||
| 	struct phy_device *phydev = file->private_data; | ||||
| 	char buf[64], param1[32], param2[32]; | ||||
| @@ -955,7 +956,7 @@ static ssize_t an8801_mdio_write(struct file *file, const char __user *ptr, | ||||
| 	if (count > sizeof(buf) - 1) | ||||
| 		return -EINVAL; | ||||
| 	if (copy_from_user(buf, ptr, len)) | ||||
| 	return -EFAULT; | ||||
| 		return -EFAULT; | ||||
|  | ||||
| 	ret = sscanf(buf, "%s %s", param1, param2); | ||||
| 	if (ret < 0) | ||||
| @@ -991,16 +992,16 @@ static ssize_t an8801_mdio_write(struct file *file, const char __user *ptr, | ||||
| 			pr_notice("\nphy=0x%x, devad=0x%x, reg=0x%x, val=0x%x\n", | ||||
| 				phydev_phy_addr(phydev), devad, reg, val); | ||||
|  | ||||
| 			ret = an8801_cl45_write(phydev, devad, reg, val); | ||||
| 			ret = phy_write_mmd(phydev, devad, reg, val); | ||||
| 			if (ret < 0) | ||||
| 				return ret; | ||||
| 			an8801_cl45_read(phydev, devad, reg, ®_val); | ||||
| 			reg_val = phy_read_mmd(phydev, devad, reg); | ||||
| 			pr_notice("\nphy=0x%x, devad=0x%x, reg=0x%x, val=0x%x confirm..\n", | ||||
| 				phydev_phy_addr(phydev), devad, reg, reg_val); | ||||
| 		} else if (!strncmp("r", param2, strlen("r"))) { | ||||
| 			if (sscanf(buf, "cl45 r %x %x", &devad, ®) == -1) | ||||
| 				return -EFAULT; | ||||
| 			an8801_cl45_read(phydev, devad, reg, ®_val); | ||||
| 			reg_val = phy_read_mmd(phydev, devad, reg); | ||||
| 			pr_notice("\nphy=0x%x, devad=0x%x, reg=0x%x, val=0x%x\n", | ||||
| 				phydev_phy_addr(phydev), devad, reg, reg_val); | ||||
| 		} else { | ||||
| @@ -1020,7 +1021,6 @@ static int an8801_counter_show(struct seq_file *seq, void *v) | ||||
| 	struct phy_device *phydev = seq->private; | ||||
| 	int ret = 0; | ||||
| 	u32 pkt_cnt = 0; | ||||
| 	struct mii_bus *mbus = phydev_mdiobus(phydev); | ||||
|  | ||||
| 	seq_puts(seq, "==========AIR PHY COUNTER==========\n"); | ||||
| 	seq_puts(seq, "|\t<<SERDES COUNTER>>\n"); | ||||
| @@ -1143,8 +1143,9 @@ static ssize_t an8801_debugfs_pbus(struct file *file, | ||||
| 	if (buf[0] == 'w') { | ||||
| 		if (sscanf(buf, "w %x %x", ®, &val) == -1) | ||||
| 			return -EFAULT; | ||||
|  | ||||
| 		pr_notice("\nphy=0x%x, reg=0x%x, val=0x%x\n", | ||||
| 			phydev_phy_addr(phydev), reg, val); | ||||
| 				phydev_phy_addr(phydev), reg, val); | ||||
|  | ||||
| 		ret = air_buckpbus_reg_write(phydev, reg, val); | ||||
| 		if (ret < 0) | ||||
| @@ -1188,10 +1189,9 @@ int an8801_info_show(struct seq_file *seq, void *v) | ||||
| 	for (reg = MII_BMCR; reg <= MII_STAT1000; reg++) { | ||||
| 		if ((reg <= MII_LPA) || (reg >= MII_CTRL1000)) | ||||
| 			seq_printf(seq, "| RG_MII 0x%02x     : 0x%08x\n", | ||||
| 			reg, phy_read(phydev, reg)); | ||||
| 				reg, phy_read(phydev, reg)); | ||||
| 	} | ||||
| 	seq_puts(seq, "\n"); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| @@ -1231,10 +1231,10 @@ static const struct file_operations an8801_polarity_fops = { | ||||
| }; | ||||
|  | ||||
| static const struct file_operations an8801_mdio_fops = { | ||||
|    .owner = THIS_MODULE, | ||||
|    .open = simple_open, | ||||
|    .write = an8801_mdio_write, | ||||
|    .llseek = noop_llseek, | ||||
| 	.owner = THIS_MODULE, | ||||
| 	.open = simple_open, | ||||
| 	.write = an8801_mdio_write, | ||||
| 	.llseek = noop_llseek, | ||||
| }; | ||||
|  | ||||
| int an8801_debugfs_init(struct phy_device *phydev) | ||||
| @@ -1354,13 +1354,22 @@ static int an8801sb_read_status(struct phy_device *phydev) | ||||
| 	if (phydev->link == LINK_DOWN) { | ||||
| 		prespeed = 0; | ||||
| 		phydev->speed = 0; | ||||
| 		ret |= an8801_cl45_write( | ||||
| 		ret |= phy_write_mmd( | ||||
| 			phydev, MMD_DEV_VSPEC2, PHY_PRE_SPEED_REG, prespeed); | ||||
|  | ||||
| 		mdelay(10);        /* delay 10 ms */ | ||||
| 		reg_value = air_buckpbus_reg_read(phydev, 0x10220010); | ||||
| 		reg_value &= 0x7fff; | ||||
| 		air_buckpbus_reg_write(phydev, 0x10220010, reg_value); | ||||
|  | ||||
| 		reg_value = air_buckpbus_reg_read(phydev, 0x10220000); | ||||
| 		reg_value |= AN8801SB_SGMII_AN0_ANRESTART; | ||||
| 		air_buckpbus_reg_write(phydev, 0x10220000, reg_value); | ||||
| 	} | ||||
|  | ||||
| 	if (prespeed != phydev->speed && phydev->link == LINK_UP) { | ||||
| 		prespeed = phydev->speed; | ||||
| 		ret |= an8801_cl45_write( | ||||
| 		ret |= phy_write_mmd( | ||||
| 			phydev, MMD_DEV_VSPEC2, PHY_PRE_SPEED_REG, prespeed); | ||||
| 		dev_info(phydev_dev(phydev), "AN8801SB SPEED %d\n", prespeed); | ||||
| 		while (an_retry > 0) { | ||||
| @@ -1374,28 +1383,19 @@ static int an8801sb_read_status(struct phy_device *phydev) | ||||
| 		mdelay(10);        /* delay 10 ms */ | ||||
|  | ||||
|  | ||||
| 		if (phydev->autoneg == AUTONEG_DISABLE) { | ||||
| 			dev_info(phydev_dev(phydev), | ||||
| 				"AN8801SB force speed = %d\n", prespeed); | ||||
| 			if (prespeed == SPEED_1000) { | ||||
| 				air_buckpbus_reg_write( | ||||
| 					phydev, 0x10220010, 0xd801); | ||||
| 			} else if (prespeed == SPEED_100) { | ||||
| 				air_buckpbus_reg_write( | ||||
| 					phydev, 0x10220010, 0xd401); | ||||
| 			} else { | ||||
| 				air_buckpbus_reg_write( | ||||
| 					phydev, 0x10220010, 0xd001); | ||||
| 			} | ||||
|  | ||||
| 			reg_value = air_buckpbus_reg_read( | ||||
| 				phydev, 0x10220000); | ||||
| 			reg_value |= AN8801SB_SGMII_AN0_ANRESTART; | ||||
| 		if (prespeed == SPEED_1000) { | ||||
| 			air_buckpbus_reg_write( | ||||
| 				phydev, 0x10220000, reg_value); | ||||
| 				phydev, 0x10220010, 0xd801); | ||||
| 		} else if (prespeed == SPEED_100) { | ||||
| 			air_buckpbus_reg_write( | ||||
| 				phydev, 0x10220010, 0xd401); | ||||
| 		} else { | ||||
| 			air_buckpbus_reg_write( | ||||
| 				phydev, 0x10220010, 0xd001); | ||||
| 		} | ||||
|  | ||||
| 		reg_value = air_buckpbus_reg_read(phydev, 0x10220000); | ||||
| 		reg_value |= AN8801SB_SGMII_AN0_RESET; | ||||
| 		reg_value |= (AN8801SB_SGMII_AN0_RESET | AN8801SB_SGMII_AN0_ANRESTART); | ||||
| 		air_buckpbus_reg_write(phydev, 0x10220000, reg_value); | ||||
| 	} | ||||
| 	return ret; | ||||
| @@ -1451,9 +1451,12 @@ static struct phy_driver airoha_driver[] = { | ||||
| 		.probe          = an8801_phy_probe, | ||||
| 		.remove         = an8801_phy_remove, | ||||
| 		.read_status    = an8801_read_status, | ||||
| #if (KERNEL_VERSION(4, 5, 0) < LINUX_VERSION_CODE) | ||||
| 		.read_mmd       = __an8801_cl45_read, | ||||
| 		.write_mmd      = __an8801_cl45_write, | ||||
| 		.config_intr	= an8801_config_intr, | ||||
| #if (KERNEL_VERSION(5, 11, 0) < LINUX_VERSION_CODE) | ||||
| 		.handle_interrupt = an8801_handle_interrupt, | ||||
| #else | ||||
| 		.did_interrupt	= an8801_did_interrupt, | ||||
| 		.ack_interrupt	= an8801_ack_interrupt, | ||||
| #endif | ||||
| 	} | ||||
| }; | ||||
|   | ||||
| @@ -12,10 +12,10 @@ | ||||
|  | ||||
| /* NAMING DECLARATIONS | ||||
|  */ | ||||
| #define AN8801_DRIVER_VERSION  "1.1.4" | ||||
| #define AN8801_DRIVER_VERSION  "1.1.6" | ||||
|  | ||||
| #define DEBUGFS_COUNTER         "counter" | ||||
| #define DEBUGFS_INFO     "driver_info" | ||||
| #define DEBUGFS_INFO            "driver_info" | ||||
| #define DEBUGFS_PBUS_OP         "pbus_op" | ||||
| #define DEBUGFS_POLARITY        "polarity" | ||||
| #define DEBUGFS_MDIO            "mdio" | ||||
| @@ -88,7 +88,7 @@ | ||||
| #define LED_BLK_EVT_1000M_RX        BIT(1) | ||||
| #define LED_BLK_EVT_1000M_TX        BIT(0) | ||||
|  | ||||
| #define UNIT_LED_BLINK_DURATION     1024 | ||||
| #define UNIT_LED_BLINK_DURATION     780 | ||||
|  | ||||
| /* Serdes auto negotation restart */ | ||||
| #define AN8801SB_SGMII_AN0_ANRESTART    (0x0200) | ||||
| @@ -135,6 +135,9 @@ For reference only | ||||
| #define LED_BLINK_DURATION(f)       (UNIT_LED_BLINK_DURATION << (f)) | ||||
| #define LED_GPIO_SEL(led, gpio)     ((led) << ((gpio) * 3)) | ||||
|  | ||||
| /* Interrupt GPIO number, should not conflict with LED */ | ||||
| #define AIR_INTERRUPT_GPIO	3 | ||||
|  | ||||
| /* DATA TYPE DECLARATIONS | ||||
|  */ | ||||
| enum AIR_LED_GPIO_PIN_T { | ||||
|   | ||||
| @@ -587,7 +587,7 @@ static int en8801s_phase1_init(struct phy_device *phydev) | ||||
|  | ||||
| 	phydev->dev_flags = PHY_STATE_INIT; | ||||
|  | ||||
| 	dev_info(dev, "Phase1 initialize OK ! (%s)\n", EN8801S_DRIVER_VERSION); | ||||
| 	dev_info(dev, "Phase1 initialize OK ! (%s) 10Te TP_IDL fixed.\n", EN8801S_DRIVER_VERSION); | ||||
| 	if (priv->pro_version == 4) { | ||||
| 		ret = en8801s_phase2_init(phydev); | ||||
| 		if (ret != 0) { | ||||
| @@ -811,14 +811,7 @@ static int en8801s_phase2_init(struct phy_device *phydev) | ||||
| 		retry--; | ||||
| 	} | ||||
| 	pbus_data = airoha_pbus_read(mbus, pbus_addr, 0x1C38); /* RAW#2 */ | ||||
| 	ret = airoha_cl45_read(mbus, phy_addr, 0x1E, 0x12, &cl45_value); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
| 	GPHY_RG_1E_012.DATA = cl45_value; | ||||
| 	GPHY_RG_1E_012.DataBitField.da_tx_i2mpb_a_tbt = | ||||
| 				(u16)(pbus_data & 0x03f); | ||||
| 	ret = airoha_cl45_write(mbus, phy_addr, 0x1E, 0x12, | ||||
| 				GPHY_RG_1E_012.DATA); | ||||
| 	ret = airoha_cl45_write(mbus, phy_addr, 0x1E, 0x12, 0xA018); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
| 	ret = airoha_cl45_read(mbus, phy_addr, 0x1E, 0x17, &cl45_value); | ||||
| @@ -893,6 +886,17 @@ static int en8801s_phase2_init(struct phy_device *phydev) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	//Fix 10Te TP_IDL | ||||
| 	ret = airoha_cl45_read(mbus, phy_addr, 0x1E, | ||||
| 				0x1A3, &cl45_value); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
| 	cl45_value &= ~0xf0; | ||||
| 	ret = airoha_cl45_write(mbus, phy_addr, 0x1E, | ||||
| 				0x1A3, cl45_value); | ||||
| 	if (ret < 0) | ||||
| 		return ret; | ||||
|  | ||||
| 	priv->first_init = false; | ||||
| 	dev_info(phydev_dev(phydev), "Phase2 initialize OK !\n"); | ||||
| 	return 0; | ||||
|   | ||||
| @@ -307,3 +307,28 @@ define Device/senao_jeap6500 | ||||
| endef | ||||
| TARGET_DEVICES += senao_jeap6500 | ||||
| DEFAULT_DEVICE_VARS += FIT_KEY_DIR FIT_KEY_NAME | ||||
|  | ||||
| define Device/emplus_wap588m | ||||
|    DEVICE_VENDOR := EMPLUS | ||||
|    DEVICE_MODEL := WAP588M | ||||
|    DEVICE_DTS := mt7981-emplus-wap588m | ||||
|    DEVICE_DTS_DIR := $(DTS_DIR)/mediatek | ||||
|    SUPPORTED_DEVICES := emplus,wap588m | ||||
|    DEVICE_PACKAGES := kmod-mt7981-firmware kmod-mt7915e uboot-envtools -procd-ujail | ||||
|    UBINIZE_OPTS := -E 5 | ||||
|    BLOCKSIZE := 128k | ||||
|    PAGESIZE := 2048 | ||||
|    IMAGE_SIZE := 65536k | ||||
|    KERNEL_IN_UBI := 1 | ||||
|    FIT_KEY_DIR := $(DTS_DIR)/mediatek/keys/emplus_wap588m | ||||
|    FIT_KEY_NAME := fit_key | ||||
|    IMAGES += factory.bin | ||||
|    IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE) | ||||
|    IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata | ||||
|    KERNEL = kernel-bin | lzma | \ | ||||
|      fit-sign lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | ||||
|    KERNEL_INITRAMFS = kernel-bin | lzma | \ | ||||
|      fit-sign lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | ||||
|  endef | ||||
|  TARGET_DEVICES += emplus_wap588m | ||||
|  DEFAULT_DEVICE_VARS += FIT_KEY_DIR FIT_KEY_NAME | ||||
|   | ||||
| @@ -31,7 +31,10 @@ mediatek_setup_interfaces() | ||||
| 		;; | ||||
| 	sonicfi,rap630w-211g) | ||||
| 		ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" eth1 | ||||
| 		;;		 | ||||
| 		;; | ||||
|     emplus,wap588m) | ||||
|         ucidef_set_interfaces_lan_wan "eth0" "eth1" | ||||
|         ;; | ||||
| 	*)	 | ||||
| 		ucidef_set_interfaces_lan_wan "eth1" "eth0" | ||||
| 		;; | ||||
|   | ||||
| @@ -18,6 +18,7 @@ case "$board" in | ||||
| edgecore,eap111|\ | ||||
| edgecore,eap112|\ | ||||
| senao,iap2300m|\ | ||||
| emplus,wap588m|\ | ||||
| senao,jeap6500) | ||||
| 	ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x20000" "0x20000" | ||||
| 	;; | ||||
|   | ||||
| @@ -1,5 +1,17 @@ | ||||
| REQUIRE_IMAGE_METADATA=1 | ||||
|  | ||||
| swap_wap588m_active_fw() { | ||||
| 	echo "Doing swap active_fw" > /dev/console | ||||
|         tmp_active_fw=$(fw_printenv | grep active_fw | awk -F= {'print $2'}) | ||||
| 	if [ $tmp_active_fw == "0" ]; then | ||||
| 		fw_setenv active_fw 1 | ||||
|                 fw_setenv mtdparts nmbm0:1024k\(bl2\),512k\(u-boot-env\),2048k\(factory\),2048k\(fip\),56320k\(ubi_1\),56320k\(ubi\),384k\(cert\),640k\(userconfig\),384k\(crashdump\) | ||||
| 	else | ||||
| 		fw_setenv active_fw 0 | ||||
|                 fw_setenv mtdparts nmbm0:1024k\(bl2\),512k\(u-boot-env\),2048k\(factory\),2048k\(fip\),56320k\(ubi\),56320k\(ubi_1\),384k\(cert\),640k\(userconfig\),384k\(crashdump\) | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| senao_swap_active_fw() { | ||||
| 	echo "Doing swap active_fw" > /dev/console | ||||
| 	tmp_active_fw=$(fw_printenv -n active_fw) | ||||
| @@ -47,6 +59,7 @@ platform_do_upgrade() { | ||||
| 		nand_do_upgrade "$1" | ||||
| 		;; | ||||
| 	senao,iap2300m|\ | ||||
| 	emplus,wap588m|\ | ||||
| 	senao,jeap6500) | ||||
| 		CI_UBIPART="ubi_1" | ||||
| 		nand_do_upgrade "$1" | ||||
| @@ -68,6 +81,7 @@ platform_check_image() { | ||||
| 	edgecore,eap111|\ | ||||
| 	edgecore,eap112|\ | ||||
| 	senao,iap2300m|\ | ||||
| 	emplus,wap588m|\ | ||||
| 	senao,jeap6500) | ||||
| 		nand_do_platform_check "$board" "$1" | ||||
| 		return $? | ||||
| @@ -92,5 +106,8 @@ platform_post_upgrade_success() { | ||||
| 		senao,jeap6500) | ||||
| 			senao_swap_active_fw | ||||
| 		;; | ||||
| 		emplus,wap588m) | ||||
| 			swap_wap588m_active_fw | ||||
| 		;; | ||||
| 	esac | ||||
| } | ||||
|   | ||||
| @@ -2,7 +2,6 @@ CONFIG_64BIT=y | ||||
| CONFIG_AHCI_MTK=y | ||||
| CONFIG_AIROHA_EN8801SC_PHY=y | ||||
| # CONFIG_AIROHA_EN8811H_PHY is not set | ||||
| # CONFIG_AIROHA_AN8801_PHY is not set | ||||
| CONFIG_AN8855_GSW=y | ||||
| CONFIG_ARCH_CLOCKSOURCE_DATA=y | ||||
| CONFIG_ARCH_DMA_ADDR_T_64BIT=y | ||||
|   | ||||
| @@ -1,15 +1,3 @@ | ||||
| From 535fdc6dfce7def996a5188819ffc96231c36f98 Mon Sep 17 00:00:00 2001 | ||||
| From: Bo-Cun Chen <bc-bocun.chen@mediatek.com> | ||||
| Date: Tue, 2 Jan 2024 18:13:43 +0800 | ||||
| Subject: [PATCH] [networking][999-2738-an8801sb-gphy-support.patch] | ||||
|  | ||||
| --- | ||||
|  drivers/net/phy/Kconfig  |   5 + | ||||
|  drivers/net/phy/Makefile |   1 + | ||||
|  2 files changed, 6 insertions(+) | ||||
|  | ||||
| diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig | ||||
| index ccd3f3f..5dbfb17 100644 | ||||
| --- a/drivers/net/phy/Kconfig | ||||
| +++ b/drivers/net/phy/Kconfig | ||||
| @@ -345,6 +345,11 @@ config SFP | ||||
| @@ -24,8 +12,6 @@ index ccd3f3f..5dbfb17 100644 | ||||
|  config AIROHA_EN8801SC_PHY | ||||
|  	tristate "Drivers for Airoha EN8801S Gigabit PHYs for MediaTek SoC." | ||||
|  	---help--- | ||||
| diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile | ||||
| index 1e8d67b..d39e54b 100644 | ||||
| --- a/drivers/net/phy/Makefile | ||||
| +++ b/drivers/net/phy/Makefile | ||||
| @@ -74,6 +74,7 @@ endif | ||||
| @@ -36,6 +22,64 @@ index 1e8d67b..d39e54b 100644 | ||||
|  obj-$(CONFIG_AIROHA_EN8801SC_PHY)	+= en8801sc.o | ||||
|  air_en8811h-y := air_en8811h_main.o air_en8811h_api.o | ||||
|  obj-$(CONFIG_AIROHA_EN8811H_PHY)	+= air_en8811h.o | ||||
| --  | ||||
| 2.18.0 | ||||
|  | ||||
| --- a/drivers/net/phy/phylink.c | ||||
| +++ b/drivers/net/phy/phylink.c | ||||
| @@ -870,12 +870,17 @@ | ||||
|  	of_node_put(phy_node); | ||||
|   | ||||
|  	if (!phy_dev) | ||||
| -		return -ENODEV; | ||||
| - | ||||
| +	{ | ||||
| +		phylink_info(pl, "[phylink] reload phy-handle2. %s %d\n",__func__, __LINE__); | ||||
| +		phy_node = of_parse_phandle(dn, "phy-handle2", 0); | ||||
| +		phy_dev = of_phy_attach(pl->netdev, phy_node, flags, pl->link_interface); | ||||
| +		if (!phy_dev) | ||||
| +			return -ENODEV; | ||||
| +	} | ||||
| +	 | ||||
|  	ret = phylink_bringup_phy(pl, phy_dev, pl->link_config.interface); | ||||
|  	if (ret) | ||||
|  		phy_detach(phy_dev); | ||||
| - | ||||
|  	return ret; | ||||
|  } | ||||
|  EXPORT_SYMBOL_GPL(phylink_of_phy_connect); | ||||
| --- a/drivers/of/of_mdio.c | ||||
| +++ b/drivers/of/of_mdio.c | ||||
| @@ -226,7 +226,9 @@ | ||||
|  		return rc; | ||||
|   | ||||
|  	/* Loop over the child nodes and register a phy_device for each phy */ | ||||
| +	int an8801=0; | ||||
|  	for_each_available_child_of_node(np, child) { | ||||
| +		if(an8801==1)break; | ||||
|  		addr = of_mdio_parse_addr(&mdio->dev, child); | ||||
|  		if (addr < 0) { | ||||
|  			scanphys = true; | ||||
| @@ -234,7 +236,25 @@ | ||||
|  		} | ||||
|   | ||||
|  		if (of_mdiobus_child_is_phy(child)) | ||||
| +		{ | ||||
| +			if(addr==30) | ||||
| +			{ | ||||
| +				int phy_id ; | ||||
| + | ||||
| +				phy_id = mdiobus_read(mdio, addr, MII_PHYSID1) << 16 ; | ||||
| +				phy_id = phy_id + mdiobus_read(mdio, addr, MII_PHYSID2); | ||||
| +				dev_info(&mdio->dev, "[of_mdio] %s %d  addr:%d phy_id:0x%x  \n",__func__, __LINE__, addr, phy_id); | ||||
| + | ||||
| +				if (phy_id==0 || phy_id==0x1a750000) | ||||
| +				{ | ||||
| +					dev_info(&mdio->dev, "[of_mdio] %s %d  continue  \n",__func__, __LINE__); | ||||
| +					continue; | ||||
| +				} | ||||
| +				else | ||||
| +					an8801=1; | ||||
| +			} | ||||
|  			rc = of_mdiobus_register_phy(mdio, child, addr); | ||||
| +		} | ||||
|  		else | ||||
|  			rc = of_mdiobus_register_device(mdio, child, addr); | ||||
|   | ||||
|   | ||||
							
								
								
									
										125
									
								
								feeds/morse/kernel/mm-board-config/LICENSE.binaries
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										125
									
								
								feeds/morse/kernel/mm-board-config/LICENSE.binaries
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,125 @@ | ||||
|                                   MORSE MICRO | ||||
|                      BINARY DISTRIBUTION LICENSE AGREEMENT | ||||
|  | ||||
| 1. Parties. | ||||
| This Software License Agreement (SLA) is between Morse Micro Pty. Ltd. and the | ||||
| user of the Software set forth (“you”, “user”, “customer”), and is effective as | ||||
| of the date of first access or download of the software by you. Morse Micro is | ||||
| licensing this software to you free of charge upon the condition that you | ||||
| accept all the terms of this SLA and only use this Software in conjunction with | ||||
| Morse Micro products. ANY USE, REPRODUCTION, OR DISTRIBUTION OF THE SOFTWARE | ||||
| CONSTITUTES YOUR ACCEPTANCE OF THIS AGREEMENT. | ||||
|  | ||||
| 2. Definitions. | ||||
| "Software" means any binary or source code that you have received from Morse | ||||
| Micro or its authorized licensees and/or those portions of such software | ||||
| produced by Program’s code within the Software, as well as any other machine | ||||
| readable materials (including, but not limited to, libraries, source files, | ||||
| header files, and data files), any updates or error corrections provided by | ||||
| Morse Micro, and any user manuals, programming guides and other documentation | ||||
| provided to you by Morse Micro under this SLA. | ||||
|  | ||||
| 3. License and Restrictions. | ||||
| Morse Micro grants you a non-exclusive, non-transferable, limited license | ||||
| without license fees to: | ||||
|  | ||||
|     a. use the software solely with a hardware product that includes one of the | ||||
|     Morse Micro Wi-Fi HaLow chips, including | ||||
|     wireless modules or evaluation kits; | ||||
|  | ||||
|     b. to reproduce and distribute the Software complete, unmodified, and as | ||||
|     provided by Morse Micro, solely for use with a hardware product that | ||||
|     includes one of the Morse Micro Wi-Fi HaLow chips, including wireless | ||||
|     modules or evaluation kits. | ||||
|  | ||||
| 4. Reservation of Rights. | ||||
| You should distribute Software with a copy of this SLA. Software is | ||||
| copyrighted. Title to Software and all associated intellectual property rights | ||||
| is retained by Morse Micro. Except as expressly provided herein, no license or | ||||
| right, express or implied, is hereby conveyed or granted to you by Morse Micro. | ||||
| You must retain all copyright notices on all Software, derivative works and | ||||
| documentation. The intellectual property and proprietary rights of whatever | ||||
| nature in the Software and derivative works are and will remain the exclusive | ||||
| property of Morse Micro or its suppliers. Nothing in this Agreement should be | ||||
| construed as transferring any aspects of such rights to you or any third party. | ||||
| Morse Micro and its suppliers reserve any and all rights not expressly granted | ||||
| in this Agreement. You may not sell, assign, sublicense, lease, or otherwise | ||||
| transfer any part of this license. You must not: | ||||
|  | ||||
|     a. use, license, sell or otherwise distribute the Software except as | ||||
|     provided in this SLA; | ||||
|  | ||||
|     b. attempt to modify in any way, reverse engineer, decompile or disassemble | ||||
|     any portion of the Software; | ||||
|  | ||||
|     c. use the Software or other material in violation of any applicable law or | ||||
|     regulation, including but not limited to any regulatory agency. | ||||
|  | ||||
| 5. Ownership. | ||||
| The Software is licensed and not sold.  Title to and ownership of the Software, | ||||
| including all intellectual property rights thereto, and any portion thereof | ||||
| remain with Morse Micro or its licensors. You hereby covenant that you will not | ||||
| assert any claim that the Software created by or for Morse Micro infringe any | ||||
| intellectual property right owned or controlled by you. | ||||
|  | ||||
| 6. Termination. | ||||
| This SLA will terminate immediately without notice from Morse Micro if you fail | ||||
| to comply with any of its provisions, including the export laws provisions and | ||||
| Section 10 that may govern the export of the Software from certain | ||||
| jurisdictions, including technical data. | ||||
|  | ||||
| 7. Disclaimer and Limitation of Liability. | ||||
| THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MORSE MICRO | ||||
| FURTHER DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT | ||||
| LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||
| PURPOSE OR NON-INFRINGEMENT. IN NO EVENT SHALL MORSE MICRO BE LIABLE FOR ANY | ||||
| INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE OR CONSEQUENTIAL DAMAGES, OR DAMAGES | ||||
| FOR LOSS OF PROFITS, REVENUE, DATA OR DATA USE, INCURRED BY YOU OR ANY THIRD | ||||
| PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT, EVEN IF MORSE MICRO HAS BEEN | ||||
| ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THE SOFTWARE IS NOT INTENDED FOR | ||||
| USE IN ENVIRONMENTS OR APPLICATIONS WHERE EXTRAORDINARILY HIGH LEVELS OF | ||||
| QUALITY, RELIABILITY, AND FAILURE TOLERANCE ARE DEMANDED, AND/OR WHERE A | ||||
| MALFUNCTION OR FAILURE COULD LEAD TO SIGNIFICANT HARM TO LIFE, HEALTH, | ||||
| PROPERTY, OR RESULT IN SEVERE SOCIETAL REPERCUSSIONS ("CRITICAL APPLICATIONS"). | ||||
| CRITICAL APPLICATIONS ENCOMPASS, BUT ARE NOT LIMITED TO, EQUIPMENT UTILIZED IN | ||||
| NUCLEAR FACILITIES, AVIATION AND SPACE EQUIPMENT, MEDICAL DEVICES, AUTOMOTIVE, | ||||
| TRAIN, MARINE, AND OTHER TRANSPORTATION EQUIPMENT, DEVICES INVOLVED IN | ||||
| CONTROLLING COMBUSTION OR EXPLOSIONS, SAFETY DEVICES, ELEVATORS AND ESCALATORS, | ||||
| DEVICES ASSOCIATED WITH ELECTRIC POWER, AND EQUIPMENT USED IN FINANCE-RELATED | ||||
| FIELDS. | ||||
|  | ||||
| 8. Survival. | ||||
| Sections 4, 5, 6, 7 and 10 will survive termination or expiration of this SLA. | ||||
|  | ||||
| 9. Privacy. | ||||
| Some features of the Software, if activated, may transmit a limited amount of | ||||
| data to Morse Micro (or its service provider) about the status of the system | ||||
| before a crash event. Morse Micro does not associate the data with personally | ||||
| identifiable information. | ||||
|  | ||||
| 10. Export Laws. | ||||
| YOU UNDERSTAND AND AGREE THAT THE SOFTWARE IS SUBJECT TO ALL APPLICABLE EXPORT- | ||||
| RELATED LAWS AND REGULATIONS AND THAT YOU MAY NOT EXPORT, RE-EXPORT OR TRANSFER | ||||
| THE SOFTWARE OR ANY DIRECT PRODUCT OF THE SOFTWARE EXCEPT AS PERMITTED UNDER | ||||
| THOSE LAWS. WITHOUT LIMITING THE FOREGOING, EXPORT, RE-EXPORT, OR TRANSFER OF | ||||
| THE SOFTWARE TO CUBA, IRAN, NORTH KOREA, SUDAN, AND SYRIA IS PROHIBITED. | ||||
|  | ||||
| 11. Governing Law. | ||||
| The laws of New South Wales, Australia, govern all matters arising out of or | ||||
| relating to this SLA without giving effect to any conflict of law principles. | ||||
| If any provision of this SLA is held to be unenforceable, this SLA will remain | ||||
| in effect with the provision omitted, unless omission would frustrate the | ||||
| intent of the parties, in which case this Agreement will immediately terminate. | ||||
|  | ||||
| 12. Entire Agreement. | ||||
| This Agreement constitutes the entire agreement between the parties and | ||||
| supersedes all prior and contemporaneous agreements, proposals or | ||||
| representations, written or oral, concerning its subject matter. No | ||||
| modification, amendment, or waiver of any provision of this Agreement will be | ||||
| effective unless in writing and either signed or accepted electronically by the | ||||
| party against whom the modification, amendment or waiver is to be asserted. A | ||||
| waiver of any breach under this Agreement does not constitute a waiver of any | ||||
| other breach or future breach. | ||||
|  | ||||
|  | ||||
| MORSE MICRO | ||||
							
								
								
									
										86
									
								
								feeds/morse/kernel/mm-board-config/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								feeds/morse/kernel/mm-board-config/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,86 @@ | ||||
| # | ||||
| # Copyright 2022 Morse Micro | ||||
| # | ||||
| # This is free software, licensed under the MIT License. | ||||
| # | ||||
| # This package installs Morse Micro board configuration binaries, which are | ||||
| # distributed under the Morse Micro Binary Distribution License. | ||||
| # This license is available in LICENSE.binaries. | ||||
| # | ||||
|  | ||||
| include $(TOPDIR)/rules.mk | ||||
|  | ||||
| PKG_NAME:=morse-board-config | ||||
| PKG_RELEASE=6 | ||||
|  | ||||
| PKG_VERSION:=rel_1_12_4_2024_Jun_11 | ||||
|  | ||||
| PKG_SOURCE:=morsemicro-bcf-rel_1_12_4_2024_Jun_11.tar | ||||
| PKG_SOURCE_URL:=https://github.com/MorseMicro/bcf_binaries/releases/download/v1.12.4/ | ||||
| PKG_HASH:=e403764730aa149e78874135da154bab2a24574308d3f2df88c9b4c125766ae3 | ||||
|  | ||||
| PKG_MAINTAINER:=Morse Micro <info@morsemicro.com> | ||||
| PKG_BUILD_PARALLEL:=1 | ||||
|  | ||||
| RSTRIP:=: | ||||
|  | ||||
| include $(INCLUDE_DIR)/kernel.mk | ||||
| include $(INCLUDE_DIR)/package.mk | ||||
|  | ||||
| define Package/morse-board-config | ||||
|   SECTION:=firmware | ||||
|   CATEGORY:=Firmware | ||||
|   URL:=$(PKG_SOURCE_URL) | ||||
|   TITLE:=Morse Micro WIFI HaLow Board Config File | ||||
|   PROVIDES:=morse-board-config | ||||
| endef | ||||
|  | ||||
| define Package/morse-board-config-hotplug-model | ||||
|   SECTION:=firmware | ||||
|   CATEGORY:=Firmware | ||||
|   TITLE:=Hotplug scripts for module type reporting | ||||
|   DEPENDS:=+morse-board-config | ||||
| endef | ||||
|  | ||||
| define Package/morse-board-config-hotplug-model/description | ||||
|   When enabled, a hotplug script will be installed to | ||||
|   append a relevant module type suffix based on the value | ||||
|   programmed into the Morse chips OTP bits. | ||||
| endef | ||||
|  | ||||
| TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS) | ||||
|  | ||||
| define Build/Compile | ||||
|  | ||||
| endef | ||||
|  | ||||
| define Package/morse-board-config/install | ||||
| 	$(INSTALL_DIR) $(1)/usr/share/morse-bcf | ||||
| 	$(INSTALL_DIR) $(1)/lib/firmware/morse | ||||
|  | ||||
| 	$(INSTALL_DATA) $(PKG_BUILD_DIR)/lib/firmware/morse/* $(1)/lib/firmware/morse/ | ||||
|  | ||||
| 	# Install all files from override folder, including failsafe. | ||||
| 	$(INSTALL_DATA) ./files/lib/firmware/morse/* $(1)/lib/firmware/morse/ | ||||
|  | ||||
| ifeq ($(CONFIG_TARGET_PROFILE), "DEVICE_edgecore_eap112") | ||||
| 	ln -s /lib/firmware/morse/bcf_edgecore_eap112_fcc.bin $(1)/lib/firmware/morse/bcf_default.bin | ||||
| else | ||||
| 	# Link the failsafe bcf by default so userspace can query the driver. | ||||
| 	ln -s /lib/firmware/morse/bcf_failsafe.bin $(1)/lib/firmware/morse/bcf_default.bin | ||||
| endif | ||||
| 	# Create symlinks for the production programmed otp devices | ||||
| 	while IFS=, read -r board_type suffix serial; do \ | ||||
| 		ln -s /lib/firmware/morse/bcf_$$$${serial}.bin $(1)/lib/firmware/morse/bcf_boardtype_$$$${board_type}.bin; \ | ||||
| 	done < ./files/usr/share/morse-bcf/db.txt | ||||
|  | ||||
| 	$(INSTALL_DATA) ./files/usr/share/morse-bcf/db.txt $(1)/usr/share/morse-bcf/db.txt | ||||
| endef | ||||
|  | ||||
| define Package/morse-board-config-hotplug-model/install | ||||
| 	$(INSTALL_DIR) $(1)/etc/hotplug.d/ieee80211 | ||||
| 	$(INSTALL_DATA) ./files/etc/hotplug.d/ieee80211/20-module-type $(1)/etc/hotplug.d/ieee80211/20-module-type | ||||
| endef | ||||
|  | ||||
| $(eval $(call BuildPackage,morse-board-config)) | ||||
| $(eval $(call BuildPackage,morse-board-config-hotplug-model)) | ||||
| @@ -0,0 +1,19 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| [ "${ACTION}" = "add" ] && { | ||||
| 	basename "$(readlink -f "/sys/${DEVPATH}/device/driver")" | grep '^morse_' || return; | ||||
|  | ||||
| 	board_type=$(printf "%04x" "$(cat /sys/${DEVPATH}/device/board_type)"); | ||||
|  | ||||
| 	# Avoid mutating model information when OTP is not burnt, ie 0000. | ||||
| 	[ "$board_type" = "0000" ] && return; | ||||
|  | ||||
| 	module_id=$(awk -F, '$1==b{print toupper($2)}' b="$board_type" /usr/share/morse-bcf/db.txt) | ||||
|  | ||||
| 	model=$(cat /tmp/sysinfo/model) | ||||
|  | ||||
| 	# Don't append a module id if that module id already exists in the model | ||||
| 	[ "${model%-"$module_id"}" != "${model}" ] && return; | ||||
|  | ||||
| 	echo "$model-$module_id" > /tmp/sysinfo/model | ||||
| } | ||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								feeds/morse/kernel/mm-board-config/files/lib/firmware/morse/bcf_mf08651_us.bin
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								feeds/morse/kernel/mm-board-config/files/lib/firmware/morse/bcf_mf08651_us.bin
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -0,0 +1 @@ | ||||
| 0801,05us,mf08651_us | ||||
							
								
								
									
										183
									
								
								feeds/morse/kernel/mm61xx/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										183
									
								
								feeds/morse/kernel/mm61xx/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,183 @@ | ||||
| # | ||||
| # Copyright 2022 Morse Micro | ||||
| # | ||||
| # This is free software, licensed under the GPL 2 license. | ||||
| # | ||||
|  | ||||
| include $(TOPDIR)/rules.mk | ||||
|  | ||||
| PKG_NAME:=morse_driver | ||||
| PKG_RELEASE=3 | ||||
|  | ||||
| PKG_VERSION:=1.11.4 | ||||
|  | ||||
| PKG_LICENSE:=GPLv2 | ||||
| PKG_LICENSE_FILES:=LICENSE | ||||
|  | ||||
| PKG_SOURCE_VERSION:=$(PKG_VERSION) | ||||
| PKG_SOURCE_URL:=https://github.com/MorseMicro/morse_driver.git | ||||
| PKG_HASH:=159d018a92e0cf742795ed49bd94fb6ed324163012bb91c2a2e4e0f6037bbf23 | ||||
| PKG_SOURCE_PROTO:=git | ||||
| PKG_SOURCE_VERSION:=b2ab42a5f22527422adf6afab73f2d019c16f162 | ||||
|  | ||||
| PKG_MAINTAINER:=Morse Micro | ||||
| PKG_BUILD_PARALLEL:=1 | ||||
|  | ||||
| include $(INCLUDE_DIR)/kernel.mk | ||||
| include $(INCLUDE_DIR)/package.mk | ||||
|  | ||||
| DTC=$(wildcard $(LINUX_DIR)/scripts/dtc/dtc) | ||||
|  | ||||
| define KernelPackage/morse | ||||
|   SUBMENU:=Wireless Drivers | ||||
|   TITLE:=Morse Micro WIFI HaLow driver | ||||
|   DEPENDS:= +kmod-mmc +kmod-mac80211 +kmod-trelay +kmod-lib-crc7 +morse-fw +morse-board-config | ||||
|   FILES:=\ | ||||
|     $(PKG_BUILD_DIR)/morse.ko \ | ||||
|     $(PKG_BUILD_DIR)/dot11ah/dot11ah.ko | ||||
|   AUTOLOAD:=$(call AutoProbe,morse) | ||||
|   MODPARAMS.morse:=country=US | ||||
|   PROVIDES:=kmod-morse | ||||
| endef | ||||
|  | ||||
| define KernelPackage/morse/config | ||||
|  | ||||
|        config MORSE_SDIO | ||||
|             bool "SDIO support " | ||||
|             default n | ||||
|             depends on PACKAGE_kmod-morse | ||||
|  | ||||
|        config MORSE_SPI | ||||
|             bool "SPI support " | ||||
|             default y | ||||
|             depends on PACKAGE_kmod-morse | ||||
|  | ||||
|        config MORSE_USER_ACCESS | ||||
|             bool "User space access support " | ||||
|             default y | ||||
|             depends on PACKAGE_kmod-morse | ||||
|  | ||||
|        config MORSE_VENDOR_COMMAND | ||||
|             bool "Vendor command support " | ||||
|             default y | ||||
|             depends on PACKAGE_kmod-morse | ||||
|  | ||||
|        config MORSE_MONITOR | ||||
|             bool "Monitor mode support " | ||||
|             default n | ||||
|             depends on PACKAGE_kmod-morse | ||||
|  | ||||
|        config MORSE_DEBUG | ||||
|             bool "Enable debug " | ||||
|             default n | ||||
|             depends on PACKAGE_kmod-morse | ||||
|             help | ||||
|               Compiles the driver with debug info and some additional debug features. | ||||
|  | ||||
|       config MORSE_DEBUG_LOGGING | ||||
|             bool "Enable debug logging" | ||||
|             default n | ||||
|             depends on PACKAGE_kmod-morse | ||||
|             select KERNEL_DYNAMIC_DEBUG_CORE | ||||
|             help | ||||
|               Enables debug level logging from the driver. Logging must be enabled at run time. | ||||
|               There may be a binary size and performance impact when this is y. | ||||
|  | ||||
|        config MORSE_RC | ||||
|             bool "Enable MMRC (Morse Micro Rate Control) " | ||||
|             default y | ||||
|             depends on PACKAGE_kmod-morse | ||||
|  | ||||
|        config MORSE_SDIO_ALIGNMENT | ||||
|             int "Required alignment for bulk SDIO reads/writes" | ||||
|             default 2 | ||||
|             range 2 8 | ||||
|             depends on MORSE_SDIO | ||||
|             help | ||||
|               Number of bytes to align data buffers for bulk SDIO transactions. Some hosts have | ||||
|               specific alignment requirements for DMA, use this setting to | ||||
|               adjust the alignment required. | ||||
|  | ||||
|               Must be a power of 2. | ||||
|  | ||||
| endef | ||||
|  | ||||
| ifeq ($(CONFIG_MORSE_SDIO),y) | ||||
|   NOSTDINC_FLAGS += -DCONFIG_MORSE_SDIO | ||||
|   MORSE_MAKEDEFS += CONFIG_MORSE_SDIO=y | ||||
| endif | ||||
|  | ||||
| ifeq ($(CONFIG_MORSE_SPI),y) | ||||
|   MORSE_MAKEDEFS += CONFIG_MORSE_SPI=y | ||||
| endif | ||||
|  | ||||
| ifeq ($(CONFIG_MORSE_USER_ACCESS),y) | ||||
|   NOSTDINC_FLAGS += -DCONFIG_MORSE_USER_ACCESS | ||||
|   MORSE_MAKEDEFS += CONFIG_MORSE_USER_ACCESS=y | ||||
| endif | ||||
|  | ||||
| ifeq ($(CONFIG_MORSE_VENDOR_COMMAND),y) | ||||
|   NOSTDINC_FLAGS += -DCONFIG_MORSE_VENDOR_COMMAND | ||||
|   MORSE_MAKEDEFS += CONFIG_MORSE_VENDOR_COMMAND=y | ||||
| endif | ||||
|  | ||||
| ifeq ($(CONFIG_MORSE_MONITOR),y) | ||||
|   NOSTDINC_FLAGS += -DCONFIG_MORSE_MONITOR | ||||
|   MORSE_MAKEDEFS += CONFIG_MORSE_MONITOR=y | ||||
| endif | ||||
|  | ||||
| ifeq ($(CONFIG_MORSE_DEBUG),y) | ||||
|   # This DEBUG (used by the driver Makefile) should not be confused with | ||||
|   # -DDEBUG (used by the kernel build system). | ||||
|   MORSE_MAKEDEFS += DEBUG=y | ||||
|   MORSE_MAKEDEFS += CONFIG_MORSE_DEBUGFS=y | ||||
|   MORSE_MAKEDEFS += CONFIG_MORSE_ENABLE_TEST_MODES=y | ||||
| else | ||||
|   MORSE_MAKEDEFS += DEBUG=n | ||||
| endif | ||||
|  | ||||
| ifeq ($(CONFIG_MORSE_RC),y) | ||||
|   NOSTDINC_FLAGS += -DCONFIG_MORSE_RC | ||||
|   MORSE_MAKEDEFS += CONFIG_MORSE_RC=y | ||||
| endif | ||||
|  | ||||
| MORSE_MAKEDEFS += \ | ||||
|   MORSE_VERSION=0-$(PKG_VERSION) \ | ||||
|   KERNEL_SRC=$(LINUX_DIR) \ | ||||
|   CONFIG_MORSE_SDIO_ALIGNMENT=$(CONFIG_MORSE_SDIO_ALIGNMENT) \ | ||||
|   CONFIG_BACKPORT_VERSION=v5.18.1 | ||||
| # This refers to the version of mac80211 backported to OpenWrt | ||||
| # Occasionally patches are required to remove some parts of the driver | ||||
| # as OpenWrt may sometimes pull in further patches from later kernel versions | ||||
| # than that of the mac80211 backport. | ||||
|  | ||||
| NOSTDINC_FLAGS = \ | ||||
| 	-I$(PKG_BUILD_DIR) \ | ||||
| 	-I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \ | ||||
| 	-I$(STAGING_DIR)/usr/include/mac80211-backport \ | ||||
| 	-I$(STAGING_DIR)/usr/include/mac80211/uapi \ | ||||
| 	-I$(STAGING_DIR)/usr/include/mac80211 \ | ||||
| 	-include backport/autoconf.h \ | ||||
| 	-include backport/backport.h | ||||
|  | ||||
| ifeq ($(CONFIG_MORSE_DEBUG_LOGGING),y) | ||||
|   NOSTDINC_FLAGS += -DDYNAMIC_DEBUG_MODULE | ||||
|   NOSTDINC_FLAGS += -DDEBUG | ||||
| endif | ||||
|  | ||||
| MORSE_MAKEDEFS += CONFIG_WLAN_VENDOR_MORSE=m | ||||
| MORSE_MAKEDEFS += V=1 | ||||
|  | ||||
| NOSTDINC_FLAGS += -DMORSE_TRACE_PATH=. | ||||
|  | ||||
| include $(INCLUDE_DIR)/kernel-defaults.mk | ||||
|  | ||||
| define Build/Compile | ||||
| 	$(MAKE) $(MORSE_MAKEDEFS) $(PKG_JOBS) -C "$(LINUX_DIR)" \ | ||||
| 		$(KERNEL_MAKE_FLAGS) \ | ||||
| 		M="$(PKG_BUILD_DIR)" \ | ||||
| 		NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \ | ||||
| 		modules | ||||
| endef | ||||
|  | ||||
| $(eval $(call KernelPackage,morse)) | ||||
| @@ -0,0 +1,15 @@ | ||||
| --- a/watchdog.c | ||||
| +++ b/watchdog.c | ||||
| @@ -54,12 +54,7 @@ static enum hrtimer_restart morse_watchd | ||||
|  static void watchdog_timer_start(struct morse *mors) | ||||
|  { | ||||
|  	ktime_t interval = ktime_set(mors->watchdog.interval_secs, 0); | ||||
| - | ||||
| -#if defined(MAC80211_BACKPORT_VERSION_CODE) && (KERNEL_VERSION(4, 10, 0) <= MAC80211_VERSION_CODE) | ||||
| -	hrtimer_start(&mors->watchdog.timer, interval.tv64, HRTIMER_MODE_REL); | ||||
| -#else | ||||
|  	hrtimer_start(&mors->watchdog.timer, interval, HRTIMER_MODE_REL); | ||||
| -#endif | ||||
|  } | ||||
|  | ||||
|  int morse_watchdog_start(struct morse *mors) | ||||
							
								
								
									
										60
									
								
								feeds/morse/kernel/mm61xx/patches/003-ekh01-spi-fix.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								feeds/morse/kernel/mm61xx/patches/003-ekh01-spi-fix.patch
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,60 @@ | ||||
| --- a/spi.c | ||||
| +++ b/spi.c | ||||
| @@ -175,10 +175,12 @@ static int morse_spi_setup(struct spi_de | ||||
|  	spi->bits_per_word = 8; | ||||
|  	spi->max_speed_hz = max_speed_hz; | ||||
|   | ||||
| +#if 0 | ||||
|  	if (spi->max_speed_hz > MAX_SPI_CLK_SPEED) { | ||||
|  		dev_err(&spi->dev, "SPI clocks above 50MHz are not supported by Morse chip\n"); | ||||
|  		return -EPERM; | ||||
|  	} | ||||
| +#endif | ||||
|   | ||||
|  	ret = spi_setup(spi); | ||||
|  	if (ret < 0) { | ||||
| @@ -432,7 +434,7 @@ static u8 *morse_spi_find_data_ack(struc | ||||
|  { | ||||
|  	u8 *cp = data; | ||||
|   | ||||
| -	while (cp < end && *cp == 0xff) | ||||
| +	while (cp < end && (SPI_MMC_RESPONSE_CODE(*cp) != SPI_RESPONSE_ACCEPTED)) | ||||
|  		cp++; | ||||
|   | ||||
|  	if (cp == end) | ||||
| @@ -529,13 +531,10 @@ static int morse_spi_cmd53_read(struct m | ||||
|  	cp += 4; | ||||
|   | ||||
|  	if (!block) { | ||||
| -		/* Scale bytes delay to block */ | ||||
| -		u32 extra_bytes = (count * mspi->inter_block_delay_bytes) / MMC_SPI_BLOCKSIZE; | ||||
| - | ||||
|  		/* Allow 4 bytes for CRC and another 10 bytes for start block token & chip delays | ||||
|  		 * (usually comes in 2). | ||||
|  		 */ | ||||
| -		data_size = count + 4 + 4 + extra_bytes; | ||||
| +		data_size = count + 4 + 4 + mspi->inter_block_delay_bytes; | ||||
|  		if (is_rk3288) | ||||
|  			/* Short transactions are sometimes delayed. These extra bytes give enough | ||||
|  			 * cycles to receive all the data. This could be optimised to a lower | ||||
| @@ -601,6 +600,7 @@ static int morse_spi_cmd53_write(struct | ||||
|  	u8 *resp; | ||||
|  	u8 *end; | ||||
|  	u8 *ack = cp; | ||||
| +	u8 *test_ack; | ||||
|  	u32 data_size; | ||||
|  	int i; | ||||
|   | ||||
| @@ -656,10 +656,11 @@ static int morse_spi_cmd53_write(struct | ||||
|  		/* crc */ | ||||
|  		*cp = (crc & 0xFF00) >> 8; | ||||
|  		*(cp + 1) = (crc & 0xFF); | ||||
| +		test_ack = cp + 2; | ||||
|  		cp += sizeof(crc); | ||||
|   | ||||
|  		/* Allow more bytes for status and chip processing (depends on CLK) */ | ||||
| -		cp += block ? mspi->inter_block_delay_bytes : 4; | ||||
| +		cp += mspi->inter_block_delay_bytes; | ||||
|  	} | ||||
|   | ||||
|  	/* Do the actual transfer */ | ||||
| @@ -0,0 +1,13 @@ | ||||
| Index: morse_driver-rel_1_12_3_2024_May_23/sdio.c | ||||
| =================================================================== | ||||
| --- morse_driver-rel_1_12_3_2024_May_23.orig/sdio.c | ||||
| +++ morse_driver-rel_1_12_3_2024_May_23/sdio.c | ||||
| @@ -572,7 +572,7 @@ static int morse_sdio_reset(int reset_pi | ||||
|   | ||||
|  	sdio_claim_host(func); | ||||
|  	sdio_disable_func(func); | ||||
| -#if KERNEL_VERSION(5, 18, 0) > LINUX_VERSION_CODE | ||||
| +#if KERNEL_VERSION(5, 18, 0) > MAC80211_VERSION_CODE | ||||
|  	mmc_hw_reset(func->card->host); | ||||
|  #else | ||||
|  	mmc_hw_reset(func->card); | ||||
| @@ -0,0 +1,160 @@ | ||||
| From 9ebc9a01e90f65f058ed21d3190800dc130b6ef4 Mon Sep 17 00:00:00 2001 | ||||
| From: Arien Judge <arien.judge@morsemicro.com> | ||||
| Date: Wed, 28 Feb 2024 13:29:28 +1100 | ||||
| Subject: [PATCH] sysfs: add sysfs to export board type as a device attribute | ||||
|  | ||||
| The driver reads the board type from OTP to decide which bcf file to load, | ||||
| but doesn't report this information anywhere useful. | ||||
|  | ||||
| Read the value read from OTP as a sysfs device attribute to allow userspace | ||||
| applications to reliably report the module type on chip. | ||||
|  | ||||
| Opted for creating a proper sysfs device attribute here instead of using | ||||
| debugfs as we shouldn't expect user tooling to have such a hard dependency | ||||
|  | ||||
| cache board id on firmware init for sysfs reporting | ||||
| --- | ||||
|  Makefile   |  1 + | ||||
|  firmware.c |  3 +++ | ||||
|  mac.c      |  6 ++++++ | ||||
|  morse.h    |  1 + | ||||
|  sysfs.c    | 46 ++++++++++++++++++++++++++++++++++++++++++++++ | ||||
|  sysfs.h    |  9 +++++++++ | ||||
|  6 files changed, 66 insertions(+) | ||||
|  create mode 100644 sysfs.c | ||||
|  create mode 100644 sysfs.h | ||||
|  | ||||
| Index: morse_driver-rel_1_12_3_2024_May_23/Makefile | ||||
| =================================================================== | ||||
| --- morse_driver-rel_1_12_3_2024_May_23.orig/Makefile | ||||
| +++ morse_driver-rel_1_12_3_2024_May_23/Makefile | ||||
| @@ -96,6 +96,7 @@ endif | ||||
|  obj-$(CONFIG_WLAN_VENDOR_MORSE) += morse.o dot11ah/ | ||||
|   | ||||
|  morse-y = mac.o | ||||
| +morse-y += sysfs.o | ||||
|  morse-y += init.o | ||||
|  morse-y += skbq.o | ||||
|  morse-y += debug.o | ||||
| Index: morse_driver-rel_1_12_3_2024_May_23/firmware.c | ||||
| =================================================================== | ||||
| --- morse_driver-rel_1_12_3_2024_May_23.orig/firmware.c | ||||
| +++ morse_driver-rel_1_12_3_2024_May_23/firmware.c | ||||
| @@ -881,6 +881,9 @@ int morse_firmware_init(struct morse *mo | ||||
|  	if (mors->cfg->get_board_type && enable_otp_check) | ||||
|  		board_id = mors->cfg->get_board_type(mors); | ||||
|   | ||||
| +	/* store the board id for sysfs reporting. Propagate the error */ | ||||
| +	mors->board_id = board_id; | ||||
| + | ||||
|  	if (strlen(board_config_file) > 0) { | ||||
|  		n = snprintf(bcf_path, sizeof(bcf_path), "%s/%s", MORSE_FW_DIR, board_config_file); | ||||
|  	} else if (strlen(mors->board_serial) > 0) { | ||||
| Index: morse_driver-rel_1_12_3_2024_May_23/mac.c | ||||
| =================================================================== | ||||
| --- morse_driver-rel_1_12_3_2024_May_23.orig/mac.c | ||||
| +++ morse_driver-rel_1_12_3_2024_May_23/mac.c | ||||
| @@ -14,6 +14,7 @@ | ||||
|  #include "mac.h" | ||||
|  #include "s1g_ies.h" | ||||
|  #include "bus.h" | ||||
| +#include "sysfs.h" | ||||
|  #include "debug.h" | ||||
|  #include "command.h" | ||||
|  #include "vendor.h" | ||||
| @@ -6422,6 +6423,10 @@ int morse_mac_register(struct morse *mor | ||||
|  	INIT_WORK(&mors->driver_restart, morse_mac_restart_work); | ||||
|  	INIT_WORK(&mors->health_check, morse_health_check_work); | ||||
|   | ||||
| +	ret = morse_sysfs_init(mors); | ||||
| +	if (ret) | ||||
| +		MORSE_ERR(mors, "Unable to initialise sysfs\n"); | ||||
| + | ||||
|  	ret = morse_init_debug(mors); | ||||
|  	if (ret) | ||||
|  		MORSE_ERR(mors, "Unable to create debugfs files\n"); | ||||
| @@ -6593,6 +6598,7 @@ static void morse_mac_deinit(struct mors | ||||
|   | ||||
|  void morse_mac_unregister(struct morse *mors) | ||||
|  { | ||||
| +	morse_sysfs_free(mors); | ||||
|  	morse_deinit_debug(mors); | ||||
|  	morse_ps_disable(mors); | ||||
|   | ||||
| Index: morse_driver-rel_1_12_3_2024_May_23/morse.h | ||||
| =================================================================== | ||||
| --- morse_driver-rel_1_12_3_2024_May_23.orig/morse.h | ||||
| +++ morse_driver-rel_1_12_3_2024_May_23/morse.h | ||||
| @@ -979,6 +979,7 @@ struct morse { | ||||
|  	struct morse_debug debug; | ||||
|   | ||||
|  	char *board_serial; | ||||
| +	int board_id; | ||||
|   | ||||
|  	/* Stored Channel Information, sta_type, enc_mode, RAW */ | ||||
|  	struct morse_custom_configs custom_configs; | ||||
| Index: morse_driver-rel_1_12_3_2024_May_23/sysfs.c | ||||
| =================================================================== | ||||
| --- /dev/null | ||||
| +++ morse_driver-rel_1_12_3_2024_May_23/sysfs.c | ||||
| @@ -0,0 +1,46 @@ | ||||
| +/* | ||||
| + * Copyright 2024 Morse Micro | ||||
| + * | ||||
| + */ | ||||
| + | ||||
| +#include <linux/sysfs.h> | ||||
| +#include "morse.h" | ||||
| +#include "sysfs.h" | ||||
| +#include "debug.h" | ||||
| + | ||||
| +static ssize_t board_type_show(struct device *dev, | ||||
| +					   struct device_attribute *attr, | ||||
| +					   char *buf) | ||||
| +{ | ||||
| +	struct morse *mors = dev_get_drvdata(dev); | ||||
| + | ||||
| +	if (!mors) | ||||
| +		return -EINVAL; | ||||
| + | ||||
| +	if (mors->board_id < 0) | ||||
| +		return mors->board_id; | ||||
| + | ||||
| +#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE | ||||
| +	return sysfs_emit(buf, "%d\n", mors->board_id); | ||||
| +#else | ||||
| +	return snprintf(buf, PAGE_SIZE, "%d\n", mors->board_id); | ||||
| +#endif | ||||
| +} | ||||
| + | ||||
| +static DEVICE_ATTR_RO(board_type); | ||||
| + | ||||
| +int morse_sysfs_init(struct morse *mors) | ||||
| +{ | ||||
| +	int ret; | ||||
| + | ||||
| +	ret = device_create_file(mors->dev, &dev_attr_board_type); | ||||
| +	if (ret < 0) | ||||
| +		MORSE_ERR(mors, "failed to create sysfs file board_type"); | ||||
| + | ||||
| +	return ret; | ||||
| +} | ||||
| + | ||||
| +void morse_sysfs_free(struct morse *mors) | ||||
| +{ | ||||
| +	device_remove_file(mors->dev, &dev_attr_board_type); | ||||
| +} | ||||
| Index: morse_driver-rel_1_12_3_2024_May_23/sysfs.h | ||||
| =================================================================== | ||||
| --- /dev/null | ||||
| +++ morse_driver-rel_1_12_3_2024_May_23/sysfs.h | ||||
| @@ -0,0 +1,9 @@ | ||||
| +/* | ||||
| + * Copyright 2024 Morse Micro | ||||
| + * | ||||
| + */ | ||||
| + | ||||
| +#pragma once | ||||
| + | ||||
| +int morse_sysfs_init(struct morse *mors); | ||||
| +void morse_sysfs_free(struct morse *mors); | ||||
							
								
								
									
										13
									
								
								feeds/morse/kernel/mm61xx/patches/010-fix-sdio-error.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								feeds/morse/kernel/mm61xx/patches/010-fix-sdio-error.patch
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| --- a/sdio.c | ||||
| +++ b/sdio.c | ||||
| @@ -587,9 +587,5 @@ static int morse_sdio_reset(int reset_pi | ||||
| 	sdio_claim_host(func); | ||||
| 	sdio_disable_func(func); | ||||
| -#if KERNEL_VERSION(5, 18, 0) > MAC80211_VERSION_CODE | ||||
| 	mmc_hw_reset(func->card->host); | ||||
| -#else | ||||
| -	mmc_hw_reset(func->card); | ||||
| -#endif | ||||
| 	sdio_enable_func(func); | ||||
| 	sdio_release_host(func); | ||||
|  | ||||
							
								
								
									
										73
									
								
								feeds/morse/kernel/mm61xx/patches/011-update-spi.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								feeds/morse/kernel/mm61xx/patches/011-update-spi.patch
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | ||||
| --- a/spi.c	2025-01-10 18:08:57.753837165 +0800 | ||||
| +++ b/spi.c	2025-01-13 14:17:01.746850459 +0800 | ||||
| @@ -1057,7 +1057,7 @@ static irqreturn_t morse_spi_irq_handler | ||||
| 	struct morse *mors = spi_get_drvdata(mspi->spi); | ||||
|  | ||||
| 	MORSE_WARN_ON(FEATURE_ID_SPI, !mors); | ||||
| -	if (irq == gpio_to_irq(mors->cfg->mm_spi_irq_gpio)) { | ||||
| + | ||||
| 		/* | ||||
| 		 * If we are using edge interrupts, we need to continuously service the IRQ until | ||||
| 		 * either the chip has cleared all its IRQ bits, or the pin goes high again. | ||||
| @@ -1067,8 +1067,7 @@ static irqreturn_t morse_spi_irq_handler | ||||
| 		} while (spi_use_edge_irq && ret && !gpio_get_value(mors->cfg->mm_spi_irq_gpio)); | ||||
|  | ||||
| 		return IRQ_HANDLED; | ||||
| -	} | ||||
| -	return IRQ_NONE; | ||||
| + | ||||
|  } | ||||
|  | ||||
|  static void morse_spi_enable_irq(struct morse_spi *mspi) | ||||
| @@ -1311,10 +1310,15 @@ static int morse_spi_probe(struct spi_de | ||||
| 		ret = morse_spi_cmd(mspi, SD_IO_MORSE_INIT, 0x00000000); | ||||
| 		if (!ret) | ||||
| 			break; | ||||
| -		pr_info("%s: SD_IO_RESET\n", __func__); | ||||
| +		MORSE_DBG(mors, "%s: SD_IO_RESET\n", __func__); | ||||
| 		morse_spi_cmd(mspi, SD_IO_RESET, 0x00000000); | ||||
| 	} | ||||
|  | ||||
| +	if (ret) { | ||||
| +		MORSE_SPI_ERR(mors, "failed initialise SPI: %d\n", ret); | ||||
| +		goto err_cfg; | ||||
| +	} | ||||
| + | ||||
| 	ret = morse_chip_cfg_detect_and_init(mors, mors_chip_series); | ||||
| 	if (ret) { | ||||
| 		MORSE_SPI_ERR(mors, "morse_chip_cfg_detect_and_init failed: %d\n", ret); | ||||
| @@ -1327,7 +1331,11 @@ static int morse_spi_probe(struct spi_de | ||||
| 	mors->cfg->mm_ps_gpios_supported = true; | ||||
| 	ret = morse_spi_reg32_read(mors, MORSE_REG_CHIP_ID(mors), &mors->chip_id); | ||||
|  | ||||
| -	if (!ret) { | ||||
| +	if (ret) { | ||||
| +		MORSE_SPI_ERR(mors, "failed to read chip id: %d\n", ret); | ||||
| +		goto err_cfg; | ||||
| +	} | ||||
| + | ||||
| 		/* Find out if the chip id matches our records */ | ||||
| 		if (!morse_hw_is_valid_chip_id(mors->chip_id, mors->cfg->valid_chip_ids)) { | ||||
| 			MORSE_SPI_ERR(mors, "%s Morse chip (ChipId=0x%x) not supported\n", | ||||
| @@ -1357,9 +1365,6 @@ static int morse_spi_probe(struct spi_de | ||||
| 								mspi->inter_block_delay_bytes); | ||||
| 			} | ||||
| 		} | ||||
| -	} else { | ||||
| -		goto err_cfg; | ||||
| -	} | ||||
|  | ||||
| 	MORSE_SPI_INFO(mors, "Morse Micro SPI device found, chip ID=0x%04x\n", mors->chip_id); | ||||
| 	MORSE_SPI_INFO(mors, "Board serial: %s\n", mors->board_serial); | ||||
| @@ -1442,6 +1447,11 @@ static int morse_spi_probe(struct spi_de | ||||
|  #ifdef CONFIG_MORSE_ENABLE_TEST_MODES | ||||
| 	if (test_mode == MORSE_CONFIG_TEST_MODE_BUS) | ||||
| 		ret = morse_bus_test(mors, "SPI"); | ||||
| + | ||||
| +	if (test_mode == MORSE_CONFIG_TEST_MODE_BUS_PROFILE) { | ||||
| +		morse_bus_throughput_profiler(mors); | ||||
| +		morse_spi_disable_irq(mspi); | ||||
| +	} | ||||
|  #endif | ||||
|   | ||||
|  	return ret; | ||||
							
								
								
									
										125
									
								
								feeds/morse/kernel/morse-fw/LICENSE.binaries
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										125
									
								
								feeds/morse/kernel/morse-fw/LICENSE.binaries
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,125 @@ | ||||
|                                   MORSE MICRO | ||||
|                      BINARY DISTRIBUTION LICENSE AGREEMENT | ||||
|  | ||||
| 1. Parties. | ||||
| This Software License Agreement (SLA) is between Morse Micro Pty. Ltd. and the | ||||
| user of the Software set forth (“you”, “user”, “customer”), and is effective as | ||||
| of the date of first access or download of the software by you. Morse Micro is | ||||
| licensing this software to you free of charge upon the condition that you | ||||
| accept all the terms of this SLA and only use this Software in conjunction with | ||||
| Morse Micro products. ANY USE, REPRODUCTION, OR DISTRIBUTION OF THE SOFTWARE | ||||
| CONSTITUTES YOUR ACCEPTANCE OF THIS AGREEMENT. | ||||
|  | ||||
| 2. Definitions. | ||||
| "Software" means any binary or source code that you have received from Morse | ||||
| Micro or its authorized licensees and/or those portions of such software | ||||
| produced by Program’s code within the Software, as well as any other machine | ||||
| readable materials (including, but not limited to, libraries, source files, | ||||
| header files, and data files), any updates or error corrections provided by | ||||
| Morse Micro, and any user manuals, programming guides and other documentation | ||||
| provided to you by Morse Micro under this SLA. | ||||
|  | ||||
| 3. License and Restrictions. | ||||
| Morse Micro grants you a non-exclusive, non-transferable, limited license | ||||
| without license fees to: | ||||
|  | ||||
|     a. use the software solely with a hardware product that includes one of the | ||||
|     Morse Micro Wi-Fi HaLow chips, including | ||||
|     wireless modules or evaluation kits; | ||||
|  | ||||
|     b. to reproduce and distribute the Software complete, unmodified, and as | ||||
|     provided by Morse Micro, solely for use with a hardware product that | ||||
|     includes one of the Morse Micro Wi-Fi HaLow chips, including wireless | ||||
|     modules or evaluation kits. | ||||
|  | ||||
| 4. Reservation of Rights. | ||||
| You should distribute Software with a copy of this SLA. Software is | ||||
| copyrighted. Title to Software and all associated intellectual property rights | ||||
| is retained by Morse Micro. Except as expressly provided herein, no license or | ||||
| right, express or implied, is hereby conveyed or granted to you by Morse Micro. | ||||
| You must retain all copyright notices on all Software, derivative works and | ||||
| documentation. The intellectual property and proprietary rights of whatever | ||||
| nature in the Software and derivative works are and will remain the exclusive | ||||
| property of Morse Micro or its suppliers. Nothing in this Agreement should be | ||||
| construed as transferring any aspects of such rights to you or any third party. | ||||
| Morse Micro and its suppliers reserve any and all rights not expressly granted | ||||
| in this Agreement. You may not sell, assign, sublicense, lease, or otherwise | ||||
| transfer any part of this license. You must not: | ||||
|  | ||||
|     a. use, license, sell or otherwise distribute the Software except as | ||||
|     provided in this SLA; | ||||
|  | ||||
|     b. attempt to modify in any way, reverse engineer, decompile or disassemble | ||||
|     any portion of the Software; | ||||
|  | ||||
|     c. use the Software or other material in violation of any applicable law or | ||||
|     regulation, including but not limited to any regulatory agency. | ||||
|  | ||||
| 5. Ownership. | ||||
| The Software is licensed and not sold.  Title to and ownership of the Software, | ||||
| including all intellectual property rights thereto, and any portion thereof | ||||
| remain with Morse Micro or its licensors. You hereby covenant that you will not | ||||
| assert any claim that the Software created by or for Morse Micro infringe any | ||||
| intellectual property right owned or controlled by you. | ||||
|  | ||||
| 6. Termination. | ||||
| This SLA will terminate immediately without notice from Morse Micro if you fail | ||||
| to comply with any of its provisions, including the export laws provisions and | ||||
| Section 10 that may govern the export of the Software from certain | ||||
| jurisdictions, including technical data. | ||||
|  | ||||
| 7. Disclaimer and Limitation of Liability. | ||||
| THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MORSE MICRO | ||||
| FURTHER DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT | ||||
| LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||
| PURPOSE OR NON-INFRINGEMENT. IN NO EVENT SHALL MORSE MICRO BE LIABLE FOR ANY | ||||
| INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE OR CONSEQUENTIAL DAMAGES, OR DAMAGES | ||||
| FOR LOSS OF PROFITS, REVENUE, DATA OR DATA USE, INCURRED BY YOU OR ANY THIRD | ||||
| PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT, EVEN IF MORSE MICRO HAS BEEN | ||||
| ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THE SOFTWARE IS NOT INTENDED FOR | ||||
| USE IN ENVIRONMENTS OR APPLICATIONS WHERE EXTRAORDINARILY HIGH LEVELS OF | ||||
| QUALITY, RELIABILITY, AND FAILURE TOLERANCE ARE DEMANDED, AND/OR WHERE A | ||||
| MALFUNCTION OR FAILURE COULD LEAD TO SIGNIFICANT HARM TO LIFE, HEALTH, | ||||
| PROPERTY, OR RESULT IN SEVERE SOCIETAL REPERCUSSIONS ("CRITICAL APPLICATIONS"). | ||||
| CRITICAL APPLICATIONS ENCOMPASS, BUT ARE NOT LIMITED TO, EQUIPMENT UTILIZED IN | ||||
| NUCLEAR FACILITIES, AVIATION AND SPACE EQUIPMENT, MEDICAL DEVICES, AUTOMOTIVE, | ||||
| TRAIN, MARINE, AND OTHER TRANSPORTATION EQUIPMENT, DEVICES INVOLVED IN | ||||
| CONTROLLING COMBUSTION OR EXPLOSIONS, SAFETY DEVICES, ELEVATORS AND ESCALATORS, | ||||
| DEVICES ASSOCIATED WITH ELECTRIC POWER, AND EQUIPMENT USED IN FINANCE-RELATED | ||||
| FIELDS. | ||||
|  | ||||
| 8. Survival. | ||||
| Sections 4, 5, 6, 7 and 10 will survive termination or expiration of this SLA. | ||||
|  | ||||
| 9. Privacy. | ||||
| Some features of the Software, if activated, may transmit a limited amount of | ||||
| data to Morse Micro (or its service provider) about the status of the system | ||||
| before a crash event. Morse Micro does not associate the data with personally | ||||
| identifiable information. | ||||
|  | ||||
| 10. Export Laws. | ||||
| YOU UNDERSTAND AND AGREE THAT THE SOFTWARE IS SUBJECT TO ALL APPLICABLE EXPORT- | ||||
| RELATED LAWS AND REGULATIONS AND THAT YOU MAY NOT EXPORT, RE-EXPORT OR TRANSFER | ||||
| THE SOFTWARE OR ANY DIRECT PRODUCT OF THE SOFTWARE EXCEPT AS PERMITTED UNDER | ||||
| THOSE LAWS. WITHOUT LIMITING THE FOREGOING, EXPORT, RE-EXPORT, OR TRANSFER OF | ||||
| THE SOFTWARE TO CUBA, IRAN, NORTH KOREA, SUDAN, AND SYRIA IS PROHIBITED. | ||||
|  | ||||
| 11. Governing Law. | ||||
| The laws of New South Wales, Australia, govern all matters arising out of or | ||||
| relating to this SLA without giving effect to any conflict of law principles. | ||||
| If any provision of this SLA is held to be unenforceable, this SLA will remain | ||||
| in effect with the provision omitted, unless omission would frustrate the | ||||
| intent of the parties, in which case this Agreement will immediately terminate. | ||||
|  | ||||
| 12. Entire Agreement. | ||||
| This Agreement constitutes the entire agreement between the parties and | ||||
| supersedes all prior and contemporaneous agreements, proposals or | ||||
| representations, written or oral, concerning its subject matter. No | ||||
| modification, amendment, or waiver of any provision of this Agreement will be | ||||
| effective unless in writing and either signed or accepted electronically by the | ||||
| party against whom the modification, amendment or waiver is to be asserted. A | ||||
| waiver of any breach under this Agreement does not constitute a waiver of any | ||||
| other breach or future breach. | ||||
|  | ||||
|  | ||||
| MORSE MICRO | ||||
							
								
								
									
										53
									
								
								feeds/morse/kernel/morse-fw/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								feeds/morse/kernel/morse-fw/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,53 @@ | ||||
| # | ||||
| # Copyright 2022 Morse Micro | ||||
| # | ||||
| # This is free software, licensed under the MIT License. | ||||
| # | ||||
| # This package installs Morse Micro firmware binaries, which are | ||||
| # distributed under the Morse Micro Binary Distribution License. | ||||
| # This license is available in LICENSE.binaries. | ||||
| # | ||||
|  | ||||
| include $(TOPDIR)/rules.mk | ||||
|  | ||||
| PKG_NAME:=morse-fw | ||||
| PKG_RELEASE=2 | ||||
|  | ||||
| PKG_VERSION:=rel_1_11_4_2024_Jul_09 | ||||
|  | ||||
| PKG_SOURCE:=morsemicro-fw-rel_1_11_4_2024_Jul_09.tar | ||||
| PKG_SOURCE_URL:=https://github.com/MorseMicro/firmware_binaries/releases/download/v1.11.4/ | ||||
| PKG_HASH:=6df1e39655278adf140776b3e76b8faced41828a9d482363aed0795e96f5d241 | ||||
|  | ||||
| PKG_MAINTAINER:=Morse Micro <info@morsemicro.com> | ||||
| PKG_BUILD_PARALLEL:=1 | ||||
|  | ||||
| RSTRIP:=: | ||||
|  | ||||
| include $(INCLUDE_DIR)/kernel.mk | ||||
| include $(INCLUDE_DIR)/package.mk | ||||
|  | ||||
| define Package/morse-fw | ||||
|   SECTION:=firmware | ||||
|   CATEGORY:=Firmware | ||||
|   URL:=$(PKG_SOURCE_URL) | ||||
|   TITLE:=Morse Micro WIFI HaLow firmware | ||||
|   PROVIDES:=morse-fw | ||||
| endef | ||||
|  | ||||
| TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS) | ||||
|  | ||||
| define Build/Compile | ||||
|  | ||||
| endef | ||||
|  | ||||
| define Package/morse-fw/install | ||||
| 	$(INSTALL_DIR) $(1)/lib/firmware/morse/. | ||||
| 	if [ -e ./files/lib/firmware/morse/mm6108.bin ]; then \ | ||||
| 		$(INSTALL_DATA) ./files/lib/firmware/morse/mm6108.bin $(1)/lib/firmware/morse/; \ | ||||
| 	else \ | ||||
| 		$(INSTALL_DATA) $(PKG_BUILD_DIR)/lib/firmware/morse/mm6108.bin $(1)/lib/firmware/morse/; \ | ||||
| 	fi | ||||
| endef | ||||
|  | ||||
| $(eval $(call BuildPackage,morse-fw)) | ||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										68
									
								
								feeds/morse/morse-regdb/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								feeds/morse/morse-regdb/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,68 @@ | ||||
| # | ||||
| # Copyright 2023 Morse Micro | ||||
| # | ||||
| # This is free software, licensed under the 3-Clause BSD License. | ||||
| # | ||||
|  | ||||
| # Because the contents of morse_regdb are private, this package does | ||||
| # some tricky things to _avoid_ downloading under normal circumstances, | ||||
| # instead using a cached file stored in this repository. If you'd like | ||||
| # to regenerate the cached file, do: | ||||
| # | ||||
| #   make package/morse-regdb/clean package/morse-regdb/download package/morse-regdb/compile V=sc REGENERATE=1 | ||||
| # | ||||
| include $(TOPDIR)/rules.mk | ||||
|  | ||||
|  | ||||
| PKG_NAME:=morse-regdb | ||||
| PKG_RELEASE:=1 | ||||
| PKG_BUILD_DEPENDS:=python3/host | ||||
|  | ||||
| PKG_SOURCE_VERSION:=v2.1.1 | ||||
| PKG_SOURCE_URL:=https://github.com/MorseMicro/morse_regdb.git | ||||
| PKG_SOURCE_PROTO:=git | ||||
| PKG_MIRROR_HASH:=0d074d2810f520c138427ab63ce0b8ab61f0f073cf7cd91177ad840a3322540a | ||||
|  | ||||
| PKG_VERSION:=$(PKG_SOURCE_VERSION) | ||||
|  | ||||
| include $(INCLUDE_DIR)/package.mk | ||||
|  | ||||
| # Skip download unless REGENERATE is on. | ||||
| # This must occur after including package.mk, as PKG_SKIP_DOWNLOAD is defined there. | ||||
| PKG_SKIP_DOWNLOAD=$(USE_SOURCE_DIR)$(USE_GIT_TREE)$(USE_GIT_SRC_CHECKOUT)$(if $(REGENERATE),,1) | ||||
|  | ||||
| define Package/morse-regdb | ||||
|   SECTION:=net | ||||
|   CATEGORY:=Network | ||||
|   TITLE:=Regulatory data for 802.11ah | ||||
|   URL:=https://bitbucket.org/morsemicro/morse_regdb/src/master/ | ||||
|   PKGARCH:=all | ||||
| endef | ||||
|  | ||||
| define Package/morse-regdb/description | ||||
| 	Regulatory data for 802.11ah in a csv. | ||||
| endef | ||||
|  | ||||
| define Build/Prepare | ||||
| 	$(if $(REGENERATE),$(call Build/Prepare/Default)) | ||||
| endef | ||||
|  | ||||
| define Build/Compile | ||||
| 	$(if $(REGENERATE), | ||||
| 		mkdir -p artefacts | ||||
| 		python3 $(PKG_BUILD_DIR)/regdbconverter.py -v -f csv $(PKG_BUILD_DIR)/regdb_Sub-1_GHz.tsv > artefacts/repo_channels.csv | ||||
| 	) | ||||
| 	mkdir -p $(PKG_BUILD_DIR)/artefacts | ||||
| 	# Mash the 5g shim channels in. | ||||
| 	python3 add_5g_shim_channels.py < artefacts/repo_channels.csv > $(PKG_BUILD_DIR)/artefacts/channels.csv | ||||
| endef | ||||
|  | ||||
| define Package/morse-regdb/install | ||||
| 	$(INSTALL_DIR) $(1)/usr/share/morse-regdb | ||||
| 	$(INSTALL_DATA) $(PKG_BUILD_DIR)/artefacts/* $(1)/usr/share/morse-regdb | ||||
| 	# Make channels.csv accessible from the web. | ||||
| 	$(INSTALL_DIR) $(1)/www | ||||
| 	ln -sf /usr/share/morse-regdb/channels.csv $(1)/www/halow-channels.csv | ||||
| endef | ||||
|  | ||||
| $(eval $(call BuildPackage,morse-regdb)) | ||||
							
								
								
									
										88
									
								
								feeds/morse/morse-regdb/add_5g_shim_channels.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										88
									
								
								feeds/morse/morse-regdb/add_5g_shim_channels.py
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,88 @@ | ||||
| #!/usr/bin/env python3 | ||||
|  | ||||
|  | ||||
| import csv | ||||
| import sys | ||||
|  | ||||
| # Fake 5g channels reported by netlink instead of 1g channels. | ||||
| S1G_TO_5G= { | ||||
|     1: 132, | ||||
|     2: 134, | ||||
|     3: 136, | ||||
|     4: 'NA', | ||||
|     5: 36, | ||||
|     6: 38, | ||||
|     7: 40, | ||||
|     8: 42, | ||||
|     9: 44, | ||||
|     10: 46, | ||||
|     11: 48, | ||||
|     12: 50, | ||||
|     13: 52, | ||||
|     14: 54, | ||||
|     15: 56, | ||||
|     16: 58, | ||||
|     17: 60, | ||||
|     18: 62, | ||||
|     19: 64, | ||||
|     20: 'NA', | ||||
|     21: 100, | ||||
|     22: 102, | ||||
|     23: 104, | ||||
|     24: 106, | ||||
|     25: 108, | ||||
|     26: 110, | ||||
|     27: 112, | ||||
|     28: 114, | ||||
|     29: 116, | ||||
|     30: 118, | ||||
|     31: 120, | ||||
|     32: 122, | ||||
|     33: 124, | ||||
|     34: 126, | ||||
|     35: 128, | ||||
|     36: 'NA', | ||||
|     37: 149, | ||||
|     38: 151, | ||||
|     39: 153, | ||||
|     40: 155, | ||||
|     41: 157, | ||||
|     42: 159, | ||||
|     43: 161, | ||||
|     44: 163, | ||||
|     45: 165, | ||||
|     46: 167, | ||||
|     47: 169, | ||||
|     48: 171, | ||||
|     49: 173, | ||||
|     50: 175, | ||||
|     51: 177, | ||||
| } | ||||
|  | ||||
| # Japanese channels are... different. | ||||
| JAPAN_S1G_TO_5G = { | ||||
|     9: 108, | ||||
|     13: 36, | ||||
|     15: 40, | ||||
|     17: 44, | ||||
|     19: 48, | ||||
|     21: 64, | ||||
|     2: 38, | ||||
|     6: 46, | ||||
|     4: 54, | ||||
|     8: 62, | ||||
|     36: 42, | ||||
|     38: 58, | ||||
| } | ||||
|  | ||||
|  | ||||
| dr = csv.DictReader(sys.stdin) | ||||
| dw = csv.DictWriter(sys.stdout, dr.fieldnames + ['5g_chan'], lineterminator='\n') | ||||
| dw.writeheader() | ||||
| for row in dr: | ||||
|      m = JAPAN_S1G_TO_5G if row['country_code'] == 'JP' else S1G_TO_5G | ||||
|      row['5g_chan'] = m.get(int(row['s1g_chan'])) | ||||
|  | ||||
|      assert row['5g_chan'], f'Missing 5G chan map for Channel {row["s1g_chan"]} in {row["country_code"]}' | ||||
|  | ||||
|      dw.writerow(row) | ||||
							
								
								
									
										473
									
								
								feeds/morse/morse-regdb/artefacts/repo_channels.csv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										473
									
								
								feeds/morse/morse-regdb/artefacts/repo_channels.csv
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,473 @@ | ||||
| country_code,bw,s1g_chan,s1g_op_class,global_op_class,centre_freq_mhz,duty_cycle_ap,duty_cycle_sta,country,tx_power_max,duty_cycle_omit_ctrl_resp,pkt_spacing_ms,airtime_min_ms,airtime_max_ms,usable_banff_c | ||||
| AL,1,1,6,66,863.5,10.0,2.8,Albania,16.13,False,0.0,0.0,0.0,1 | ||||
| AL,1,3,6,66,864.5,10.0,2.8,Albania,16.13,False,0.0,0.0,0.0,1 | ||||
| AL,1,5,6,66,865.5,10.0,2.8,Albania,16.13,False,0.0,0.0,0.0,1 | ||||
| AL,1,7,6,66,866.5,10.0,2.8,Albania,16.13,False,0.0,0.0,0.0,1 | ||||
| AL,1,9,6,66,867.5,10.0,2.8,Albania,16.13,False,0.0,0.0,0.0,1 | ||||
| AR,1,27,1,68,915.5,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,1,29,1,68,916.5,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,1,31,1,68,917.5,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,1,33,1,68,918.5,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,1,35,1,68,919.5,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,1,37,1,68,920.5,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,1,39,1,68,921.5,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,1,41,1,68,922.5,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,1,43,1,68,923.5,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,1,45,1,68,924.5,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,1,47,1,68,925.5,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,1,49,1,68,926.5,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,1,51,1,68,927.5,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,2,30,2,69,917.0,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,2,34,2,69,919.0,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,2,38,2,69,921.0,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,2,42,2,69,923.0,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,2,46,2,69,925.0,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,2,50,2,69,927.0,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,4,32,3,70,918.0,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,4,40,3,70,922.0,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,4,48,3,70,926.0,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AR,8,44,4,71,924.0,100.0,100.0,Argentina,36.0,False,0.0,0.0,0.0,1 | ||||
| AT,1,1,6,66,863.5,10.0,2.8,Austria,16.13,False,0.0,0.0,0.0,1 | ||||
| AT,1,3,6,66,864.5,10.0,2.8,Austria,16.13,False,0.0,0.0,0.0,1 | ||||
| AT,1,5,6,66,865.5,10.0,2.8,Austria,16.13,False,0.0,0.0,0.0,1 | ||||
| AT,1,7,6,66,866.5,10.0,2.8,Austria,16.13,False,0.0,0.0,0.0,1 | ||||
| AT,1,9,6,66,867.5,10.0,2.8,Austria,16.13,False,0.0,0.0,0.0,1 | ||||
| AU,1,27,22,68,915.5,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,1,29,22,68,916.5,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,1,31,22,68,917.5,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,1,33,22,68,918.5,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,1,35,22,68,919.5,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,1,37,22,68,920.5,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,1,39,22,68,921.5,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,1,41,22,68,922.5,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,1,43,22,68,923.5,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,1,45,22,68,924.5,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,1,47,22,68,925.5,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,1,49,22,68,926.5,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,1,51,22,68,927.5,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,2,30,23,69,917.0,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,2,34,23,69,919.0,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,2,38,23,69,921.0,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,2,42,23,69,923.0,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,2,46,23,69,925.0,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,2,50,23,69,927.0,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,4,32,24,70,918.0,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,4,40,24,70,922.0,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,4,48,24,70,926.0,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| AU,8,44,25,71,924.0,100.0,100.0,Australia,30.0,False,0.0,0.0,0.0,1 | ||||
| BA,1,1,6,66,863.5,10.0,2.8,Bosnia and Herzegovina,16.13,False,0.0,0.0,0.0,1 | ||||
| BA,1,3,6,66,864.5,10.0,2.8,Bosnia and Herzegovina,16.13,False,0.0,0.0,0.0,1 | ||||
| BA,1,5,6,66,865.5,10.0,2.8,Bosnia and Herzegovina,16.13,False,0.0,0.0,0.0,1 | ||||
| BA,1,7,6,66,866.5,10.0,2.8,Bosnia and Herzegovina,16.13,False,0.0,0.0,0.0,1 | ||||
| BA,1,9,6,66,867.5,10.0,2.8,Bosnia and Herzegovina,16.13,False,0.0,0.0,0.0,1 | ||||
| BE,1,1,6,66,863.5,10.0,2.8,Belgium,16.13,False,0.0,0.0,0.0,1 | ||||
| BE,1,3,6,66,864.5,10.0,2.8,Belgium,16.13,False,0.0,0.0,0.0,1 | ||||
| BE,1,5,6,66,865.5,10.0,2.8,Belgium,16.13,False,0.0,0.0,0.0,1 | ||||
| BE,1,7,6,66,866.5,10.0,2.8,Belgium,16.13,False,0.0,0.0,0.0,1 | ||||
| BE,1,9,6,66,867.5,10.0,2.8,Belgium,16.13,False,0.0,0.0,0.0,1 | ||||
| BE,1,31,30,77,916.9,10.0,2.8,Belgium,16.13,False,0.0,0.0,0.0,1 | ||||
| BE,1,33,30,77,917.9,10.0,2.8,Belgium,16.13,False,0.0,0.0,0.0,1 | ||||
| BE,1,35,30,77,918.9,10.0,2.8,Belgium,16.13,False,0.0,0.0,0.0,1 | ||||
| BG,1,1,6,66,863.5,10.0,2.8,Bulgaria,16.13,False,0.0,0.0,0.0,1 | ||||
| BG,1,3,6,66,864.5,10.0,2.8,Bulgaria,16.13,False,0.0,0.0,0.0,1 | ||||
| BG,1,5,6,66,865.5,10.0,2.8,Bulgaria,16.13,False,0.0,0.0,0.0,1 | ||||
| BG,1,7,6,66,866.5,10.0,2.8,Bulgaria,16.13,False,0.0,0.0,0.0,1 | ||||
| BG,1,9,6,66,867.5,10.0,2.8,Bulgaria,16.13,False,0.0,0.0,0.0,1 | ||||
| BG,1,33,30,77,917.9,10.0,2.8,Bulgaria,16.13,False,0.0,0.0,0.0,1 | ||||
| BG,1,35,30,77,918.9,10.0,2.8,Bulgaria,16.13,False,0.0,0.0,0.0,1 | ||||
| BR,1,1,1,68,902.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,0 | ||||
| BR,1,3,1,68,903.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,5,1,68,904.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,7,1,68,905.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,9,1,68,906.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,2,2,2,69,903.0,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,0 | ||||
| BR,2,6,2,69,905.0,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,27,1,68,915.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,29,1,68,916.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,31,1,68,917.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,33,1,68,918.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,35,1,68,919.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,37,1,68,920.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,39,1,68,921.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,41,1,68,922.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,43,1,68,923.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,45,1,68,924.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,47,1,68,925.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,49,1,68,926.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,1,51,1,68,927.5,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,2,30,2,69,917.0,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,2,34,2,69,919.0,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,2,38,2,69,921.0,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,2,42,2,69,923.0,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,2,46,2,69,925.0,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,2,50,2,69,927.0,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,4,32,3,70,918.0,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,4,40,3,70,922.0,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,4,48,3,70,926.0,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| BR,8,44,4,71,924.0,100.0,100.0,Brazil,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,1,1,68,902.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,0 | ||||
| CA,1,3,1,68,903.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,5,1,68,904.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,7,1,68,905.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,9,1,68,906.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,11,1,68,907.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,13,1,68,908.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,15,1,68,909.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,17,1,68,910.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,19,1,68,911.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,21,1,68,912.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,23,1,68,913.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,25,1,68,914.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,27,1,68,915.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,29,1,68,916.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,31,1,68,917.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,33,1,68,918.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,35,1,68,919.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,37,1,68,920.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,39,1,68,921.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,41,1,68,922.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,43,1,68,923.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,45,1,68,924.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,47,1,68,925.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,49,1,68,926.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,1,51,1,68,927.5,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,2,2,2,69,903.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,0 | ||||
| CA,2,6,2,69,905.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,2,10,2,69,907.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,2,14,2,69,909.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,2,18,2,69,911.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,2,22,2,69,913.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,2,26,2,69,915.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,2,30,2,69,917.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,2,34,2,69,919.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,2,38,2,69,921.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,2,42,2,69,923.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,2,46,2,69,925.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,2,50,2,69,927.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,4,8,3,70,906.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,4,16,3,70,910.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,4,24,3,70,914.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,4,32,3,70,918.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,4,40,3,70,922.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,4,48,3,70,926.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,8,12,4,71,908.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,8,28,4,71,916.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CA,8,44,4,71,924.0,100.0,100.0,Canada,36.0,False,0.0,0.0,0.0,1 | ||||
| CH,1,1,6,66,863.5,10.0,2.8,Switzerland,16.13,False,0.0,0.0,0.0,1 | ||||
| CH,1,3,6,66,864.5,10.0,2.8,Switzerland,16.13,False,0.0,0.0,0.0,1 | ||||
| CH,1,5,6,66,865.5,10.0,2.8,Switzerland,16.13,False,0.0,0.0,0.0,1 | ||||
| CH,1,7,6,66,866.5,10.0,2.8,Switzerland,16.13,False,0.0,0.0,0.0,1 | ||||
| CH,1,9,6,66,867.5,10.0,2.8,Switzerland,16.13,False,0.0,0.0,0.0,1 | ||||
| CY,1,1,6,66,863.5,10.0,2.8,Cypress,16.13,False,0.0,0.0,0.0,1 | ||||
| CY,1,3,6,66,864.5,10.0,2.8,Cypress,16.13,False,0.0,0.0,0.0,1 | ||||
| CY,1,5,6,66,865.5,10.0,2.8,Cypress,16.13,False,0.0,0.0,0.0,1 | ||||
| CY,1,7,6,66,866.5,10.0,2.8,Cypress,16.13,False,0.0,0.0,0.0,1 | ||||
| CY,1,9,6,66,867.5,10.0,2.8,Cypress,16.13,False,0.0,0.0,0.0,1 | ||||
| CZ,1,1,6,66,863.5,10.0,2.8,Czech Republic,16.13,False,0.0,0.0,0.0,1 | ||||
| CZ,1,3,6,66,864.5,10.0,2.8,Czech Republic,16.13,False,0.0,0.0,0.0,1 | ||||
| CZ,1,5,6,66,865.5,10.0,2.8,Czech Republic,16.13,False,0.0,0.0,0.0,1 | ||||
| CZ,1,7,6,66,866.5,10.0,2.8,Czech Republic,16.13,False,0.0,0.0,0.0,1 | ||||
| CZ,1,9,6,66,867.5,10.0,2.8,Czech Republic,16.13,False,0.0,0.0,0.0,1 | ||||
| DD,1,1,6,66,863.5,10.0,2.8,Germany,16.13,False,0.0,0.0,0.0,1 | ||||
| DD,1,3,6,66,864.5,10.0,2.8,Germany,16.13,False,0.0,0.0,0.0,1 | ||||
| DD,1,5,6,66,865.5,10.0,2.8,Germany,16.13,False,0.0,0.0,0.0,1 | ||||
| DD,1,7,6,66,866.5,10.0,2.8,Germany,16.13,False,0.0,0.0,0.0,1 | ||||
| DD,1,9,6,66,867.5,10.0,2.8,Germany,16.13,False,0.0,0.0,0.0,1 | ||||
| DK,1,1,6,66,863.5,10.0,2.8,Denmark,16.13,False,0.0,0.0,0.0,1 | ||||
| DK,1,3,6,66,864.5,10.0,2.8,Denmark,16.13,False,0.0,0.0,0.0,1 | ||||
| DK,1,5,6,66,865.5,10.0,2.8,Denmark,16.13,False,0.0,0.0,0.0,1 | ||||
| DK,1,7,6,66,866.5,10.0,2.8,Denmark,16.13,False,0.0,0.0,0.0,1 | ||||
| DK,1,9,6,66,867.5,10.0,2.8,Denmark,16.13,False,0.0,0.0,0.0,1 | ||||
| EE,1,1,6,66,863.5,10.0,2.8,Estonia,16.13,False,0.0,0.0,0.0,1 | ||||
| EE,1,3,6,66,864.5,10.0,2.8,Estonia,16.13,False,0.0,0.0,0.0,1 | ||||
| EE,1,5,6,66,865.5,10.0,2.8,Estonia,16.13,False,0.0,0.0,0.0,1 | ||||
| EE,1,7,6,66,866.5,10.0,2.8,Estonia,16.13,False,0.0,0.0,0.0,1 | ||||
| EE,1,9,6,66,867.5,10.0,2.8,Estonia,16.13,False,0.0,0.0,0.0,1 | ||||
| ES,1,1,6,66,863.5,10.0,2.8,Spain,16.13,False,0.0,0.0,0.0,1 | ||||
| ES,1,3,6,66,864.5,10.0,2.8,Spain,16.13,False,0.0,0.0,0.0,1 | ||||
| ES,1,5,6,66,865.5,10.0,2.8,Spain,16.13,False,0.0,0.0,0.0,1 | ||||
| ES,1,7,6,66,866.5,10.0,2.8,Spain,16.13,False,0.0,0.0,0.0,1 | ||||
| ES,1,9,6,66,867.5,10.0,2.8,Spain,16.13,False,0.0,0.0,0.0,1 | ||||
| EU,1,1,6,66,863.5,10.0,2.8,EU,16.13,False,0.0,0.0,0.0,1 | ||||
| EU,1,3,6,66,864.5,10.0,2.8,EU,16.13,False,0.0,0.0,0.0,1 | ||||
| EU,1,5,6,66,865.5,10.0,2.8,EU,16.13,False,0.0,0.0,0.0,1 | ||||
| EU,1,7,6,66,866.5,10.0,2.8,EU,16.13,False,0.0,0.0,0.0,1 | ||||
| EU,1,9,6,66,867.5,10.0,2.8,EU,16.13,False,0.0,0.0,0.0,1 | ||||
| FI,1,1,6,66,863.5,10.0,2.8,Finland,16.13,False,0.0,0.0,0.0,1 | ||||
| FI,1,3,6,66,864.5,10.0,2.8,Finland,16.13,False,0.0,0.0,0.0,1 | ||||
| FI,1,5,6,66,865.5,10.0,2.8,Finland,16.13,False,0.0,0.0,0.0,1 | ||||
| FI,1,7,6,66,866.5,10.0,2.8,Finland,16.13,False,0.0,0.0,0.0,1 | ||||
| FI,1,9,6,66,867.5,10.0,2.8,Finland,16.13,False,0.0,0.0,0.0,1 | ||||
| FI,1,33,30,77,917.9,10.0,2.8,Finland,16.13,False,0.0,0.0,0.0,1 | ||||
| FI,1,35,30,77,918.9,10.0,2.8,Finland,16.13,False,0.0,0.0,0.0,1 | ||||
| FL,1,1,6,66,863.5,10.0,2.8,Liechtenstein,16.13,False,0.0,0.0,0.0,1 | ||||
| FL,1,3,6,66,864.5,10.0,2.8,Liechtenstein,16.13,False,0.0,0.0,0.0,1 | ||||
| FL,1,5,6,66,865.5,10.0,2.8,Liechtenstein,16.13,False,0.0,0.0,0.0,1 | ||||
| FL,1,7,6,66,866.5,10.0,2.8,Liechtenstein,16.13,False,0.0,0.0,0.0,1 | ||||
| FL,1,9,6,66,867.5,10.0,2.8,Liechtenstein,16.13,False,0.0,0.0,0.0,1 | ||||
| FR,1,1,6,66,863.5,10.0,2.8,France,16.13,False,0.0,0.0,0.0,1 | ||||
| FR,1,3,6,66,864.5,10.0,2.8,France,16.13,False,0.0,0.0,0.0,1 | ||||
| FR,1,5,6,66,865.5,10.0,2.8,France,16.13,False,0.0,0.0,0.0,1 | ||||
| FR,1,7,6,66,866.5,10.0,2.8,France,16.13,False,0.0,0.0,0.0,1 | ||||
| FR,1,9,6,66,867.5,10.0,2.8,France,16.13,False,0.0,0.0,0.0,1 | ||||
| FR,1,33,30,77,917.9,10.0,2.8,France,16.13,False,0.0,0.0,0.0,1 | ||||
| FR,1,35,30,77,918.9,10.0,2.8,France,16.13,False,0.0,0.0,0.0,1 | ||||
| GR,1,1,6,66,863.5,10.0,2.8,Greece,16.13,False,0.0,0.0,0.0,1 | ||||
| GR,1,3,6,66,864.5,10.0,2.8,Greece,16.13,False,0.0,0.0,0.0,1 | ||||
| GR,1,5,6,66,865.5,10.0,2.8,Greece,16.13,False,0.0,0.0,0.0,1 | ||||
| GR,1,7,6,66,866.5,10.0,2.8,Greece,16.13,False,0.0,0.0,0.0,1 | ||||
| GR,1,9,6,66,867.5,10.0,2.8,Greece,16.13,False,0.0,0.0,0.0,1 | ||||
| HR,1,1,6,66,863.5,10.0,2.8,Croatia,16.13,False,0.0,0.0,0.0,1 | ||||
| HR,1,3,6,66,864.5,10.0,2.8,Croatia,16.13,False,0.0,0.0,0.0,1 | ||||
| HR,1,5,6,66,865.5,10.0,2.8,Croatia,16.13,False,0.0,0.0,0.0,1 | ||||
| HR,1,7,6,66,866.5,10.0,2.8,Croatia,16.13,False,0.0,0.0,0.0,1 | ||||
| HR,1,9,6,66,867.5,10.0,2.8,Croatia,16.13,False,0.0,0.0,0.0,1 | ||||
| HU,1,1,6,66,863.5,10.0,2.8,Hungary,16.13,False,0.0,0.0,0.0,1 | ||||
| HU,1,3,6,66,864.5,10.0,2.8,Hungary,16.13,False,0.0,0.0,0.0,1 | ||||
| HU,1,5,6,66,865.5,10.0,2.8,Hungary,16.13,False,0.0,0.0,0.0,1 | ||||
| HU,1,7,6,66,866.5,10.0,2.8,Hungary,16.13,False,0.0,0.0,0.0,1 | ||||
| HU,1,9,6,66,867.5,10.0,2.8,Hungary,16.13,False,0.0,0.0,0.0,1 | ||||
| IE,1,1,6,66,863.5,10.0,2.8,Ireland,16.13,False,0.0,0.0,0.0,1 | ||||
| IE,1,3,6,66,864.5,10.0,2.8,Ireland,16.13,False,0.0,0.0,0.0,1 | ||||
| IE,1,5,6,66,865.5,10.0,2.8,Ireland,16.13,False,0.0,0.0,0.0,1 | ||||
| IE,1,7,6,66,866.5,10.0,2.8,Ireland,16.13,False,0.0,0.0,0.0,1 | ||||
| IE,1,9,6,66,867.5,10.0,2.8,Ireland,16.13,False,0.0,0.0,0.0,1 | ||||
| IE,1,31,30,77,916.9,10.0,2.8,Ireland,16.13,False,0.0,0.0,0.0,1 | ||||
| IE,1,33,30,77,917.9,10.0,2.8,Ireland,16.13,False,0.0,0.0,0.0,1 | ||||
| IE,1,35,30,77,918.9,10.0,2.8,Ireland,16.13,False,0.0,0.0,0.0,1 | ||||
| IN,1,5,6,66,865.5,10.0,2.8,India,16.13,False,0.0,0.0,0.0,1 | ||||
| IN,1,7,6,66,866.5,10.0,2.8,India,16.13,False,0.0,0.0,0.0,1 | ||||
| IN,1,9,6,66,867.5,10.0,2.8,India,16.13,False,0.0,0.0,0.0,1 | ||||
| IS,1,1,6,66,863.5,10.0,2.8,Iceland,16.13,False,0.0,0.0,0.0,1 | ||||
| IS,1,3,6,66,864.5,10.0,2.8,Iceland,16.13,False,0.0,0.0,0.0,1 | ||||
| IS,1,5,6,66,865.5,10.0,2.8,Iceland,16.13,False,0.0,0.0,0.0,1 | ||||
| IS,1,7,6,66,866.5,10.0,2.8,Iceland,16.13,False,0.0,0.0,0.0,1 | ||||
| IS,1,9,6,66,867.5,10.0,2.8,Iceland,16.13,False,0.0,0.0,0.0,1 | ||||
| IS,1,31,30,77,916.9,10.0,2.8,Iceland,16.13,False,0.0,0.0,0.0,1 | ||||
| IS,1,33,30,77,917.9,10.0,2.8,Iceland,16.13,False,0.0,0.0,0.0,1 | ||||
| IS,1,35,30,77,918.9,10.0,2.8,Iceland,16.13,False,0.0,0.0,0.0,1 | ||||
| IT,1,1,6,66,863.5,10.0,2.8,Italy,16.13,False,0.0,0.0,0.0,1 | ||||
| IT,1,3,6,66,864.5,10.0,2.8,Italy,16.13,False,0.0,0.0,0.0,1 | ||||
| IT,1,5,6,66,865.5,10.0,2.8,Italy,16.13,False,0.0,0.0,0.0,1 | ||||
| IT,1,7,6,66,866.5,10.0,2.8,Italy,16.13,False,0.0,0.0,0.0,1 | ||||
| IT,1,9,6,66,867.5,10.0,2.8,Italy,16.13,False,0.0,0.0,0.0,1 | ||||
| IT,1,33,30,77,917.9,10.0,2.8,Italy,16.13,False,0.0,0.0,0.0,1 | ||||
| IT,1,35,30,77,918.9,10.0,2.8,Italy,16.13,False,0.0,0.0,0.0,1 | ||||
| JP,1,9,8,73,921.0,10.0,10.0,Japan,16.0,True,2.0,2.0,100.0,1 | ||||
| JP,1,13,8,73,923.0,10.0,10.0,Japan,16.0,True,2.0,2.0,100.0,1 | ||||
| JP,1,15,8,73,924.0,10.0,10.0,Japan,16.0,True,2.0,2.0,100.0,1 | ||||
| JP,1,17,8,73,925.0,10.0,10.0,Japan,16.0,True,2.0,2.0,100.0,1 | ||||
| JP,1,19,8,73,926.0,10.0,10.0,Japan,16.0,True,2.0,2.0,100.0,1 | ||||
| JP,1,21,8,73,927.0,10.0,10.0,Japan,16.0,True,2.0,2.0,100.0,1 | ||||
| JP,2,2,9,64,923.5,10.0,10.0,Japan,16.0,True,2.0,2.0,100.0,1 | ||||
| JP,2,4,10,64,924.5,10.0,10.0,Japan,16.0,True,2.0,2.0,100.0,1 | ||||
| JP,2,6,9,64,925.5,10.0,10.0,Japan,16.0,True,2.0,2.0,100.0,1 | ||||
| JP,2,8,10,64,926.5,10.0,10.0,Japan,16.0,True,2.0,2.0,100.0,1 | ||||
| JP,4,36,11,65,924.5,10.0,10.0,Japan,16.0,True,2.0,2.0,100.0,1 | ||||
| JP,4,38,12,65,925.5,10.0,10.0,Japan,16.0,True,2.0,2.0,100.0,1 | ||||
| KE,1,1,6,66,863.5,10.0,2.8,Kenya,16.13,False,0.0,0.0,0.0,1 | ||||
| KE,1,3,6,66,864.5,10.0,2.8,Kenya,16.13,False,0.0,0.0,0.0,1 | ||||
| KE,1,5,6,66,865.5,10.0,2.8,Kenya,16.13,False,0.0,0.0,0.0,1 | ||||
| KE,1,7,6,66,866.5,10.0,2.8,Kenya,16.13,False,0.0,0.0,0.0,1 | ||||
| KE,1,9,6,66,867.5,10.0,2.8,Kenya,16.13,False,0.0,0.0,0.0,1 | ||||
| KR,1,1,14,74,918.0,100.0,100.0,South Korea,4.77,False,50.0,0.0,4000.0,1 | ||||
| KR,1,3,14,74,919.0,100.0,100.0,South Korea,4.77,False,50.0,0.0,4000.0,1 | ||||
| KR,1,5,14,74,920.0,100.0,100.0,South Korea,4.77,False,50.0,0.0,4000.0,1 | ||||
| KR,1,7,14,74,921.0,100.0,100.0,South Korea,4.77,False,50.0,0.0,4000.0,1 | ||||
| KR,1,9,14,74,922.0,100.0,100.0,South Korea,10.0,False,50.0,0.0,4000.0,1 | ||||
| KR,1,11,14,74,923.0,100.0,100.0,South Korea,10.0,False,50.0,0.0,4000.0,1 | ||||
| KR,2,2,15,75,918.5,100.0,100.0,South Korea,4.77,False,50.0,0.0,4000.0,1 | ||||
| KR,2,6,15,75,920.5,100.0,100.0,South Korea,4.77,False,50.0,0.0,4000.0,1 | ||||
| KR,2,10,15,75,922.5,100.0,100.0,South Korea,10.0,False,50.0,0.0,4000.0,1 | ||||
| KR,4,8,16,76,921.5,100.0,100.0,South Korea,4.77,False,50.0,0.0,4000.0,1 | ||||
| KR,1,18,14,74,926.5,100.0,100.0,South Korea,17.0,False,0.264,0.0,220.0,0 | ||||
| KR,1,20,14,74,927.5,100.0,100.0,South Korea,17.0,False,0.264,0.0,220.0,0 | ||||
| KR,1,22,14,74,928.5,100.0,100.0,South Korea,17.0,False,0.264,0.0,220.0,0 | ||||
| KR,1,24,14,74,929.5,100.0,100.0,South Korea,17.0,False,0.264,0.0,220.0,0 | ||||
| KR,2,19,15,75,927.0,100.0,100.0,South Korea,20.0,False,0.264,0.0,220.0,0 | ||||
| KR,2,23,15,75,929.0,100.0,100.0,South Korea,20.0,False,0.264,0.0,220.0,0 | ||||
| LT,1,1,6,66,863.5,10.0,2.8,Lithuania,16.13,False,0.0,0.0,0.0,1 | ||||
| LT,1,3,6,66,864.5,10.0,2.8,Lithuania,16.13,False,0.0,0.0,0.0,1 | ||||
| LT,1,5,6,66,865.5,10.0,2.8,Lithuania,16.13,False,0.0,0.0,0.0,1 | ||||
| LT,1,7,6,66,866.5,10.0,2.8,Lithuania,16.13,False,0.0,0.0,0.0,1 | ||||
| LT,1,9,6,66,867.5,10.0,2.8,Lithuania,16.13,False,0.0,0.0,0.0,1 | ||||
| LT,1,31,30,77,916.9,10.0,2.8,Lithuania,16.13,False,0.0,0.0,0.0,1 | ||||
| LT,1,33,30,77,917.9,10.0,2.8,Lithuania,16.13,False,0.0,0.0,0.0,1 | ||||
| LT,1,35,30,77,918.9,10.0,2.8,Lithuania,16.13,False,0.0,0.0,0.0,1 | ||||
| LU,1,1,6,66,863.5,10.0,2.8,Luxembourg,16.13,False,0.0,0.0,0.0,1 | ||||
| LU,1,3,6,66,864.5,10.0,2.8,Luxembourg,16.13,False,0.0,0.0,0.0,1 | ||||
| LU,1,5,6,66,865.5,10.0,2.8,Luxembourg,16.13,False,0.0,0.0,0.0,1 | ||||
| LU,1,7,6,66,866.5,10.0,2.8,Luxembourg,16.13,False,0.0,0.0,0.0,1 | ||||
| LU,1,9,6,66,867.5,10.0,2.8,Luxembourg,16.13,False,0.0,0.0,0.0,1 | ||||
| LV,1,1,6,66,863.5,10.0,2.8,Latvia,16.13,False,0.0,0.0,0.0,1 | ||||
| LV,1,3,6,66,864.5,10.0,2.8,Latvia,16.13,False,0.0,0.0,0.0,1 | ||||
| LV,1,5,6,66,865.5,10.0,2.8,Latvia,16.13,False,0.0,0.0,0.0,1 | ||||
| LV,1,7,6,66,866.5,10.0,2.8,Latvia,16.13,False,0.0,0.0,0.0,1 | ||||
| LV,1,9,6,66,867.5,10.0,2.8,Latvia,16.13,False,0.0,0.0,0.0,1 | ||||
| MD,1,1,6,66,863.5,10.0,2.8,Moldova,16.13,False,0.0,0.0,0.0,1 | ||||
| MD,1,3,6,66,864.5,10.0,2.8,Moldova,16.13,False,0.0,0.0,0.0,1 | ||||
| MD,1,5,6,66,865.5,10.0,2.8,Moldova,16.13,False,0.0,0.0,0.0,1 | ||||
| MD,1,7,6,66,866.5,10.0,2.8,Moldova,16.13,False,0.0,0.0,0.0,1 | ||||
| MD,1,9,6,66,867.5,10.0,2.8,Moldova,16.13,False,0.0,0.0,0.0,1 | ||||
| MD,1,31,30,77,916.9,10.0,2.8,Moldova,16.13,False,0.0,0.0,0.0,1 | ||||
| MD,1,33,30,77,917.9,10.0,2.8,Moldova,16.13,False,0.0,0.0,0.0,1 | ||||
| MD,1,35,30,77,918.9,10.0,2.8,Moldova,16.13,False,0.0,0.0,0.0,1 | ||||
| MK,1,1,6,66,863.5,10.0,2.8,North Macedonia,16.13,False,0.0,0.0,0.0,1 | ||||
| MK,1,3,6,66,864.5,10.0,2.8,North Macedonia,16.13,False,0.0,0.0,0.0,1 | ||||
| MK,1,5,6,66,865.5,10.0,2.8,North Macedonia,16.13,False,0.0,0.0,0.0,1 | ||||
| MK,1,7,6,66,866.5,10.0,2.8,North Macedonia,16.13,False,0.0,0.0,0.0,1 | ||||
| MK,1,9,6,66,867.5,10.0,2.8,North Macedonia,16.13,False,0.0,0.0,0.0,1 | ||||
| MK,1,31,30,77,916.9,10.0,2.8,North Macedonia,16.13,False,0.0,0.0,0.0,1 | ||||
| MK,1,33,30,77,917.9,10.0,2.8,North Macedonia,16.13,False,0.0,0.0,0.0,1 | ||||
| MK,1,35,30,77,918.9,10.0,2.8,North Macedonia,16.13,False,0.0,0.0,0.0,1 | ||||
| MT,1,1,6,66,863.5,10.0,2.8,Malta,16.13,False,0.0,0.0,0.0,1 | ||||
| MT,1,3,6,66,864.5,10.0,2.8,Malta,16.13,False,0.0,0.0,0.0,1 | ||||
| MT,1,5,6,66,865.5,10.0,2.8,Malta,16.13,False,0.0,0.0,0.0,1 | ||||
| MT,1,7,6,66,866.5,10.0,2.8,Malta,16.13,False,0.0,0.0,0.0,1 | ||||
| MT,1,9,6,66,867.5,10.0,2.8,Malta,16.13,False,0.0,0.0,0.0,1 | ||||
| NL,1,1,6,66,863.5,10.0,2.8,Netherlands,16.13,False,0.0,0.0,0.0,1 | ||||
| NL,1,3,6,66,864.5,10.0,2.8,Netherlands,16.13,False,0.0,0.0,0.0,1 | ||||
| NL,1,5,6,66,865.5,10.0,2.8,Netherlands,16.13,False,0.0,0.0,0.0,1 | ||||
| NL,1,7,6,66,866.5,10.0,2.8,Netherlands,16.13,False,0.0,0.0,0.0,1 | ||||
| NL,1,9,6,66,867.5,10.0,2.8,Netherlands,16.13,False,0.0,0.0,0.0,1 | ||||
| NO,1,1,6,66,863.5,10.0,2.8,Norway,16.13,False,0.0,0.0,0.0,1 | ||||
| NO,1,3,6,66,864.5,10.0,2.8,Norway,16.13,False,0.0,0.0,0.0,1 | ||||
| NO,1,5,6,66,865.5,10.0,2.8,Norway,16.13,False,0.0,0.0,0.0,1 | ||||
| NO,1,7,6,66,866.5,10.0,2.8,Norway,16.13,False,0.0,0.0,0.0,1 | ||||
| NO,1,9,6,66,867.5,10.0,2.8,Norway,16.13,False,0.0,0.0,0.0,1 | ||||
| NZ,1,27,26,68,915.5,100.0,100.0,New Zealand,30.0,False,0.0,0.0,0.0,1 | ||||
| NZ,1,29,26,68,916.5,100.0,100.0,New Zealand,30.0,False,0.0,0.0,0.0,1 | ||||
| NZ,1,31,26,68,917.5,100.0,100.0,New Zealand,30.0,False,0.0,0.0,0.0,1 | ||||
| NZ,1,33,26,68,918.5,100.0,100.0,New Zealand,30.0,False,0.0,0.0,0.0,1 | ||||
| NZ,1,35,26,68,919.5,100.0,100.0,New Zealand,30.0,False,0.0,0.0,0.0,1 | ||||
| NZ,1,37,26,68,920.5,100.0,100.0,New Zealand,36.0,False,0.0,0.0,0.0,1 | ||||
| NZ,1,39,26,68,921.5,100.0,100.0,New Zealand,36.0,False,0.0,0.0,0.0,1 | ||||
| NZ,1,41,26,68,922.5,100.0,100.0,New Zealand,36.0,False,0.0,0.0,0.0,1 | ||||
| NZ,1,43,26,68,923.5,100.0,100.0,New Zealand,36.0,False,0.0,0.0,0.0,1 | ||||
| NZ,1,45,26,68,924.5,100.0,100.0,New Zealand,36.0,False,0.0,0.0,0.0,1 | ||||
| NZ,1,47,26,68,925.5,100.0,100.0,New Zealand,36.0,False,0.0,0.0,0.0,1 | ||||
| NZ,1,49,26,68,926.5,100.0,100.0,New Zealand,36.0,False,0.0,0.0,0.0,1 | ||||
| NZ,1,51,26,68,927.5,100.0,100.0,New Zealand,36.0,False,0.0,0.0,0.0,1 | ||||
| NZ,2,30,27,69,917.0,100.0,100.0,New Zealand,30.0,False,0.0,0.0,0.0,1 | ||||
| NZ,2,34,27,69,919.0,100.0,100.0,New Zealand,30.0,False,0.0,0.0,0.0,1 | ||||
| NZ,2,38,27,69,921.0,100.0,100.0,New Zealand,36.0,False,0.0,0.0,0.0,1 | ||||
| NZ,2,42,27,69,923.0,100.0,100.0,New Zealand,36.0,False,0.0,0.0,0.0,1 | ||||
| NZ,2,46,27,69,925.0,100.0,100.0,New Zealand,36.0,False,0.0,0.0,0.0,1 | ||||
| NZ,2,50,27,69,927.0,100.0,100.0,New Zealand,36.0,False,0.0,0.0,0.0,1 | ||||
| NZ,4,32,28,70,918.0,100.0,100.0,New Zealand,30.0,False,0.0,0.0,0.0,1 | ||||
| NZ,4,40,28,70,922.0,100.0,100.0,New Zealand,36.0,False,0.0,0.0,0.0,1 | ||||
| NZ,4,48,28,70,926.0,100.0,100.0,New Zealand,36.0,False,0.0,0.0,0.0,1 | ||||
| NZ,8,44,29,71,924.0,100.0,100.0,New Zealand,36.0,False,0.0,0.0,0.0,1 | ||||
| PL,1,1,6,66,863.5,10.0,2.8,Poland,16.13,False,0.0,0.0,0.0,1 | ||||
| PL,1,3,6,66,864.5,10.0,2.8,Poland,16.13,False,0.0,0.0,0.0,1 | ||||
| PL,1,5,6,66,865.5,10.0,2.8,Poland,16.13,False,0.0,0.0,0.0,1 | ||||
| PL,1,7,6,66,866.5,10.0,2.8,Poland,16.13,False,0.0,0.0,0.0,1 | ||||
| PL,1,9,6,66,867.5,10.0,2.8,Poland,16.13,False,0.0,0.0,0.0,1 | ||||
| PT,1,1,6,66,863.5,10.0,2.8,Portugal,16.13,False,0.0,0.0,0.0,1 | ||||
| PT,1,3,6,66,864.5,10.0,2.8,Portugal,16.13,False,0.0,0.0,0.0,1 | ||||
| PT,1,5,6,66,865.5,10.0,2.8,Portugal,16.13,False,0.0,0.0,0.0,1 | ||||
| PT,1,7,6,66,866.5,10.0,2.8,Portugal,16.13,False,0.0,0.0,0.0,1 | ||||
| PT,1,9,6,66,867.5,10.0,2.8,Portugal,16.13,False,0.0,0.0,0.0,1 | ||||
| PT,1,31,30,77,916.9,10.0,2.8,Portugal,16.13,False,0.0,0.0,0.0,1 | ||||
| PT,1,33,30,77,917.9,10.0,2.8,Portugal,16.13,False,0.0,0.0,0.0,1 | ||||
| PT,1,35,30,77,918.9,10.0,2.8,Portugal,16.13,False,0.0,0.0,0.0,1 | ||||
| RO,1,1,6,66,863.5,10.0,2.8,Romania,16.13,False,0.0,0.0,0.0,1 | ||||
| RO,1,3,6,66,864.5,10.0,2.8,Romania,16.13,False,0.0,0.0,0.0,1 | ||||
| RO,1,5,6,66,865.5,10.0,2.8,Romania,16.13,False,0.0,0.0,0.0,1 | ||||
| RO,1,7,6,66,866.5,10.0,2.8,Romania,16.13,False,0.0,0.0,0.0,1 | ||||
| RO,1,9,6,66,867.5,10.0,2.8,Romania,16.13,False,0.0,0.0,0.0,1 | ||||
| SE,1,1,6,66,863.5,10.0,2.8,Sweden,16.13,False,0.0,0.0,0.0,1 | ||||
| SE,1,3,6,66,864.5,10.0,2.8,Sweden,16.13,False,0.0,0.0,0.0,1 | ||||
| SE,1,5,6,66,865.5,10.0,2.8,Sweden,16.13,False,0.0,0.0,0.0,1 | ||||
| SE,1,7,6,66,866.5,10.0,2.8,Sweden,16.13,False,0.0,0.0,0.0,1 | ||||
| SE,1,9,6,66,867.5,10.0,2.8,Sweden,16.13,False,0.0,0.0,0.0,1 | ||||
| SE,1,31,30,77,916.9,10.0,2.8,Sweden,16.13,False,0.0,0.0,0.0,1 | ||||
| SE,1,33,30,77,917.9,10.0,2.8,Sweden,16.13,False,0.0,0.0,0.0,1 | ||||
| SE,1,35,30,77,918.9,10.0,2.8,Sweden,16.13,False,0.0,0.0,0.0,1 | ||||
| SG,1,7,17,66,866.5,2.77,2.77,Singapore,29.14,False,100.0,0.0,1000.0,1 | ||||
| SG,1,9,17,66,867.5,2.77,2.77,Singapore,29.14,False,100.0,0.0,1000.0,1 | ||||
| SG,1,11,17,66,868.5,2.77,2.77,Singapore,29.14,False,100.0,0.0,1000.0,1 | ||||
| SG,2,10,19,67,868.0,2.77,2.77,Singapore,29.14,False,100.0,0.0,1000.0,1 | ||||
| SG,1,37,18,68,920.5,100.0,100.0,Singapore,22.15,False,0.0,0.0,0.0,1 | ||||
| SG,1,39,18,68,921.5,100.0,100.0,Singapore,22.15,False,0.0,0.0,0.0,1 | ||||
| SG,1,41,18,68,922.5,100.0,100.0,Singapore,22.15,False,0.0,0.0,0.0,1 | ||||
| SG,1,43,18,68,923.5,100.0,100.0,Singapore,22.15,False,0.0,0.0,0.0,1 | ||||
| SG,1,45,18,68,924.5,100.0,100.0,Singapore,22.15,False,0.0,0.0,0.0,1 | ||||
| SG,2,38,20,69,921.0,100.0,100.0,Singapore,22.15,False,0.0,0.0,0.0,1 | ||||
| SG,2,42,20,69,923.0,100.0,100.0,Singapore,22.15,False,0.0,0.0,0.0,1 | ||||
| SG,4,40,21,70,922.0,100.0,100.0,Singapore,22.15,False,0.0,0.0,0.0,1 | ||||
| SI,1,1,6,66,863.5,10.0,2.8,Slovenia,16.13,False,0.0,0.0,0.0,1 | ||||
| SI,1,3,6,66,864.5,10.0,2.8,Slovenia,16.13,False,0.0,0.0,0.0,1 | ||||
| SI,1,5,6,66,865.5,10.0,2.8,Slovenia,16.13,False,0.0,0.0,0.0,1 | ||||
| SI,1,7,6,66,866.5,10.0,2.8,Slovenia,16.13,False,0.0,0.0,0.0,1 | ||||
| SI,1,9,6,66,867.5,10.0,2.8,Slovenia,16.13,False,0.0,0.0,0.0,1 | ||||
| SI,1,31,30,77,916.9,10.0,2.8,Slovenia,16.13,False,0.0,0.0,0.0,1 | ||||
| SI,1,33,30,77,917.9,10.0,2.8,Slovenia,16.13,False,0.0,0.0,0.0,1 | ||||
| SI,1,35,30,77,918.9,10.0,2.8,Slovenia,16.13,False,0.0,0.0,0.0,1 | ||||
| SK,1,1,6,66,863.5,10.0,2.8,Slovakia,16.13,False,0.0,0.0,0.0,1 | ||||
| SK,1,3,6,66,864.5,10.0,2.8,Slovakia,16.13,False,0.0,0.0,0.0,1 | ||||
| SK,1,5,6,66,865.5,10.0,2.8,Slovakia,16.13,False,0.0,0.0,0.0,1 | ||||
| SK,1,7,6,66,866.5,10.0,2.8,Slovakia,16.13,False,0.0,0.0,0.0,1 | ||||
| SK,1,9,6,66,867.5,10.0,2.8,Slovakia,16.13,False,0.0,0.0,0.0,1 | ||||
| TR,1,1,6,66,863.5,10.0,2.8,Turkey,16.13,False,0.0,0.0,0.0,1 | ||||
| TR,1,3,6,66,864.5,10.0,2.8,Turkey,16.13,False,0.0,0.0,0.0,1 | ||||
| TR,1,5,6,66,865.5,10.0,2.8,Turkey,16.13,False,0.0,0.0,0.0,1 | ||||
| TR,1,7,6,66,866.5,10.0,2.8,Turkey,16.13,False,0.0,0.0,0.0,1 | ||||
| TR,1,9,6,66,867.5,10.0,2.8,Turkey,16.13,False,0.0,0.0,0.0,1 | ||||
| TR,1,33,30,77,917.9,10.0,2.8,Turkey,16.13,False,0.0,0.0,0.0,1 | ||||
| TR,1,35,30,77,918.9,10.0,2.8,Turkey,16.13,False,0.0,0.0,0.0,1 | ||||
| UK,1,1,6,66,863.5,10.0,2.8,United Kingdom,16.13,False,0.0,0.0,0.0,1 | ||||
| UK,1,3,6,66,864.5,10.0,2.8,United Kingdom,16.13,False,0.0,0.0,0.0,1 | ||||
| UK,1,5,6,66,865.5,10.0,2.8,United Kingdom,16.13,False,0.0,0.0,0.0,1 | ||||
| UK,1,7,6,66,866.5,10.0,2.8,United Kingdom,16.13,False,0.0,0.0,0.0,1 | ||||
| UK,1,9,6,66,867.5,10.0,2.8,United Kingdom,16.13,False,0.0,0.0,0.0,1 | ||||
| UK,1,33,30,77,917.9,10.0,2.8,United Kingdom,16.13,False,0.0,0.0,0.0,1 | ||||
| UK,1,35,30,77,918.9,10.0,2.8,United Kingdom,16.13,False,0.0,0.0,0.0,1 | ||||
| US,1,1,1,68,902.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,0 | ||||
| US,1,3,1,68,903.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,5,1,68,904.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,7,1,68,905.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,9,1,68,906.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,11,1,68,907.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,13,1,68,908.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,15,1,68,909.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,17,1,68,910.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,19,1,68,911.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,21,1,68,912.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,23,1,68,913.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,25,1,68,914.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,27,1,68,915.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,29,1,68,916.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,31,1,68,917.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,33,1,68,918.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,35,1,68,919.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,37,1,68,920.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,39,1,68,921.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,41,1,68,922.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,43,1,68,923.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,45,1,68,924.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,47,1,68,925.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,49,1,68,926.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,1,51,1,68,927.5,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,2,2,2,69,903.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,0 | ||||
| US,2,6,2,69,905.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,2,10,2,69,907.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,2,14,2,69,909.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,2,18,2,69,911.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,2,22,2,69,913.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,2,26,2,69,915.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,2,30,2,69,917.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,2,34,2,69,919.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,2,38,2,69,921.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,2,42,2,69,923.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,2,46,2,69,925.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,2,50,2,69,927.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,4,8,3,70,906.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,4,16,3,70,910.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,4,24,3,70,914.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,4,32,3,70,918.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,4,40,3,70,922.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,4,48,3,70,926.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,8,12,4,71,908.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,8,28,4,71,916.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| US,8,44,4,71,924.0,100.0,100.0,USA,36.0,False,0.0,0.0,0.0,1 | ||||
| 
 | 
| @@ -0,0 +1,36 @@ | ||||
| From 6c0733b125434b846bec2a744a812c890c82518d Mon Sep 17 00:00:00 2001 | ||||
| From: Takura Mapani <takura.mapani@morsemicro.com> | ||||
| Date: Tue, 19 Sep 2023 03:25:45 +0000 | ||||
| Subject: [PATCH] Merged in APP-1819_add_usable_by_bannf_column (pull request | ||||
|  #17) | ||||
|  | ||||
| APP-1819 add a new column usable bannfC for the csv output | ||||
|  | ||||
| * added new column usable bannfC for the csv output | ||||
|  | ||||
|  | ||||
| Approved-by: Arien Judge | ||||
| Approved-by: David Goodall | ||||
| Approved-by: Matthew Forgie | ||||
| Approved-by: Thomas Flynn | ||||
| Approved-by: Matt Jervis | ||||
| --- | ||||
|  regdbconverter.py | 2 +- | ||||
|  1 file changed, 1 insertion(+), 1 deletion(-) | ||||
|  | ||||
| diff --git a/regdbconverter.py b/regdbconverter.py | ||||
| index 883f281..4bd44b1 100755 | ||||
| --- a/regdbconverter.py | ||||
| +++ b/regdbconverter.py | ||||
| @@ -311,7 +311,7 @@ def _output_channels_python(channels, out_file, args): | ||||
|   | ||||
|  def _output_channels_csv(channels, out_file, args): | ||||
|      fields = ['country_code', 'bw', 's1g_chan', 's1g_op_class', 'global_op_class', 'centre_freq_mhz', 'duty_cycle_ap', 'duty_cycle_sta', | ||||
| -              'country', 'tx_power_max', 'duty_cycle_omit_ctrl_resp', 'pkt_spacing_ms', 'airtime_min_ms', 'airtime_max_ms'] | ||||
| +              'country', 'tx_power_max', 'duty_cycle_omit_ctrl_resp', 'pkt_spacing_ms', 'airtime_min_ms', 'airtime_max_ms', 'usable_banff_c'] | ||||
|   | ||||
|      dw = DictWriter(out_file, fields, extrasaction='ignore', lineterminator='\n') | ||||
|      dw.writeheader() | ||||
| --  | ||||
| 2.25.1 | ||||
|  | ||||
							
								
								
									
										41
									
								
								feeds/morse/netifd-morse/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								feeds/morse/netifd-morse/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | ||||
| # | ||||
| # Copyright 2022 Morse Micro | ||||
| # | ||||
| # This is free software, licensed under the GNU General Public License v2. | ||||
| # See /LICENSE for more information. | ||||
| # | ||||
|  | ||||
| include $(TOPDIR)/rules.mk | ||||
|  | ||||
| PKG_NAME:=netifd-morse | ||||
| PKG_RELEASE=1 | ||||
|  | ||||
| PKG_LICENSE:=GPLv2 | ||||
| PKG_LICENSE_FILES:= | ||||
|  | ||||
| PKG_MAINTAINER:=Morse Micro <info@morsemicro.com> | ||||
|  | ||||
| include $(INCLUDE_DIR)/package.mk | ||||
|  | ||||
| define Package/netifd-morse | ||||
|   SECTION:=net | ||||
|   CATEGORY:=Network | ||||
|   TITLE:=Morse Micro HaLow support for netifd | ||||
|   DEPENDS:= netifd \ | ||||
| 	+@BUSYBOX_CONFIG_USLEEP +@BUSYBOX_CONFIG_BASE64 +@BUSYBOX_CONFIG_XXD \ | ||||
| 	+kmod-morse +kmod-cfg80211 \ | ||||
| 	+morse-regdb +wpa_event_listener +wpa_supplicant_s1g +hostapd_s1g +morsecli | ||||
| endef | ||||
|  | ||||
| define Build/Compile | ||||
| endef | ||||
|  | ||||
| define Package/netifd-morse/install | ||||
| 	$(INSTALL_DIR) $(1)/lib/ | ||||
| 	$(INSTALL_DIR) $(1)/etc/uci-defaults | ||||
| 	$(INSTALL_DIR) $(1)/etc/init.d | ||||
| 	$(CP) ./lib/* $(1)/lib/ | ||||
| 	$(INSTALL_BIN) ./etc/init.d/halow-gpio-reset $(1)/etc/init.d/ | ||||
| endef | ||||
|  | ||||
| $(eval $(call BuildPackage,netifd-morse)) | ||||
							
								
								
									
										28
									
								
								feeds/morse/netifd-morse/etc/init.d/halow-gpio-reset
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										28
									
								
								feeds/morse/netifd-morse/etc/init.d/halow-gpio-reset
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| #!/bin/sh /etc/rc.common | ||||
| # Copyright (C) 2006-2011 OpenWrt.org | ||||
|  | ||||
| START=09 | ||||
|  | ||||
| . /lib/functions.sh | ||||
| . /lib/functions/uci-defaults.sh | ||||
| . /lib/functions/system.sh | ||||
|  | ||||
| boot() { | ||||
| 	. /lib/functions.sh | ||||
| 	. /lib/functions/uci-defaults.sh | ||||
| 	. /lib/functions/system.sh | ||||
|  | ||||
| 	board=$(board_name) | ||||
|  | ||||
| 	case "$board" in | ||||
| 	edgecore,eap112) | ||||
|     | ||||
| 		echo 486 > /sys/class/gpio/export | ||||
| 		echo "out" > /sys/class/gpio/gpio486/direction | ||||
| 		echo 0 > /sys/class/gpio/gpio486/value | ||||
| 		sleep 1 | ||||
| 		echo "in" > /sys/class/gpio/gpio486/direction | ||||
| 		echo 486 > /sys/class/gpio/unexport     | ||||
|  | ||||
| 	esac | ||||
| } | ||||
							
								
								
									
										1170
									
								
								feeds/morse/netifd-morse/lib/netifd/morse/morse_overrides.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1170
									
								
								feeds/morse/netifd-morse/lib/netifd/morse/morse_overrides.sh
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										161
									
								
								feeds/morse/netifd-morse/lib/netifd/morse/morse_utils.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										161
									
								
								feeds/morse/netifd-morse/lib/netifd/morse/morse_utils.sh
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,161 @@ | ||||
| kill_wait() | ||||
| { | ||||
| 	local names=$* | ||||
| 	local count=30 | ||||
|  | ||||
| 	for pid in $(pidof $names) | ||||
| 	do | ||||
| 		kill $pid &> /dev/null | ||||
| 	done | ||||
|  | ||||
| 	while pidof $names &> /dev/null; | ||||
| 	do | ||||
| 		usleep 100000 | ||||
| 		let "count--" | ||||
| 		if [ $count -eq 0 ] | ||||
| 		then | ||||
| 			echo "$names failed to terminate normally, force quitting" >&2 | ||||
| 			kill -9 $(pidof $names) | ||||
| 			return 1 | ||||
| 		fi | ||||
| 	done | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| _list_phy_interfaces() { | ||||
| 	local phy="$1" | ||||
| 	if [ -d "/sys/class/ieee80211/${phy}/device/net" ]; then | ||||
| 		ls "/sys/class/ieee80211/${phy}/device/net" 2>/dev/null; | ||||
| 	else | ||||
| 		ls "/sys/class/ieee80211/${phy}/device" 2>/dev/null | grep net: | sed -e 's,net:,,g' | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| list_phy_interfaces() { | ||||
| 	local phy="$1" | ||||
|  | ||||
| 	for dev in $(_list_phy_interfaces "$phy"); do | ||||
| 		readlink "/sys/class/net/${dev}/phy80211" | grep -q "/${phy}\$" || continue | ||||
| 	done | ||||
| } | ||||
|  | ||||
| num_test() | ||||
| { | ||||
| 	case $1 in | ||||
| 		''|*[!0-9]*) | ||||
| 			return 1 | ||||
| 			;; | ||||
| 		*) | ||||
| 			;; | ||||
| 	esac | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| _get_regulatory() { | ||||
| 	local _mode=$1 | ||||
| 	local _country=$2 | ||||
| 	local _channel=$3 | ||||
| 	local _op_class=$4 | ||||
|  | ||||
| 	local dc_min="0.01" | ||||
| 	local dc_max="100.00" | ||||
| 	local cc; local bw; local l_op; local g_op; | ||||
| 	local freq; local dc_ap; local dc_sta; | ||||
|  | ||||
| 	oIFS=$IFS | ||||
| 	HEADER=1 | ||||
| 	while IFS=, read -r cc bw ch l_op g_op freq remainder; do | ||||
| 		if [ $HEADER = 1 ]; then | ||||
| 			HEADER=0 | ||||
| 			continue | ||||
| 		fi | ||||
| 		num_test $bw | ||||
| 		[ $? -eq 1 ] 		&& continue | ||||
| 		num_test $ch | ||||
| 		[ $? -eq 1 ] 		&& continue | ||||
| 		num_test $l_op | ||||
| 		[ $? -eq 1 ] 		&& continue | ||||
| 		num_test $g_op | ||||
| 		[ $? -eq 1 ] 		&& continue | ||||
|  | ||||
| 		if [ "$cc" == "$_country" ] && [ "$ch" -eq "$_channel" ]; then | ||||
| 			if [ -z "$_op_class" ]; then | ||||
| 				halow_bw=$bw | ||||
| 				center_freq=$freq | ||||
| 				# If you didn't pass op_class, set it from this data. | ||||
| 				op_class="$g_op" | ||||
| 				IFS=$oIFS | ||||
| 				return 0; | ||||
| 			elif [ "$l_op" -eq "$_op_class" ] || [ "$g_op" -eq "$_op_class" ]; then | ||||
| 				halow_bw=$bw | ||||
| 				center_freq=$freq | ||||
| 				IFS=$oIFS | ||||
| 				return 0; | ||||
| 			fi | ||||
| 		fi | ||||
| 	done < /usr/share/morse-regdb/channels.csv | ||||
|  | ||||
| 	IFS=$oIFS | ||||
| 	return 1; | ||||
| } | ||||
|  | ||||
|  | ||||
| morse_find_ifname() | ||||
| { | ||||
| 	for file in "/sys/class/net/wlan"*; | ||||
| 	do | ||||
| 		if [ -d "$file"/device/morse ] | ||||
| 		then | ||||
| 			ifname=$(basename $file) | ||||
| 			break | ||||
| 		fi | ||||
| 	done | ||||
| } | ||||
|  | ||||
| # this function checks if an macaddr is burnt into the device. | ||||
| # if so, returns it, otherwise returns an empty string | ||||
| morse_get_chip_macaddr() | ||||
| { | ||||
| 	ifname= | ||||
| 	morse_find_ifname | ||||
| 	local state=$(cat /sys/class/net/${ifname}/operstate 2>/dev/null) | ||||
| 	[ $? -ne 0 ] && return | ||||
|  | ||||
| 	if [ "$state" == "down" ]; then | ||||
| 		ip link set ${ifname} up | ||||
| 		[ $? -ne 0 ] && return | ||||
| 	fi | ||||
|  | ||||
| 	local chip_macaddr="$(morse_cli -i ${ifname} macaddr 2>/dev/null)" | ||||
| 	[ $? -ne 0 ] && printf "" | ||||
| 	chip_macaddr=${chip_macaddr##"Chip MAC address: "} | ||||
|  | ||||
| 	#make sure (using regex) that the we got a macaddr | ||||
| 	if [[ "$chip_macaddr" =~ ^\([0-9A-Fa-f]{2}[:]\){5}\([0-9A-Fa-f]{2}\)$ ]]; then | ||||
| 		[ "$chip_macaddr" = "00:00:00:00:00:00" ] && printf "" || printf "$chip_macaddr" | ||||
| 	else | ||||
| 		printf "" | ||||
| 	fi | ||||
|  | ||||
| 	if [ "$state" == "down" ]; then | ||||
| 		ip link set ${ifname} down | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| update_dpp_qrcode() | ||||
| { | ||||
| 	local uci_changes_path="$(mktemp -d)" | ||||
| 	local private_key_path=$1 | ||||
| 	#remove ':' from the macaddress | ||||
| 	local mac_address=$(echo "$2" | sed -r 's/://g') | ||||
| 	#generate the public key string from the private key. | ||||
| 	#unfortunately, there is no way to quiet the 'read EC key' messages without redirecting stderr. | ||||
| 	local pubkey=$(openssl ec -in $private_key_path -pubout -conv_form compressed -outform DER 2> /dev/null | hexdump -e '16/1 "%02x " "\n"' | xxd -r -p | base64 -w0) | ||||
| 	#save qrcode string into /www | ||||
| 	qrencode --inline --8bit --type=SVG --output=/tmp/dpp_qrcode.svg "DPP:V:2;M:$mac_address;K:$pubkey;;" | ||||
| 	#only write if necessary | ||||
| 	if ! cmp -s /tmp/dpp_qrcode.svg /www/dpp_qrcode.svg; then | ||||
| 		cp /tmp/dpp_qrcode.svg /www/dpp_qrcode.svg | ||||
| 	fi | ||||
| 	rm /tmp/dpp_qrcode.svg | ||||
| } | ||||
							
								
								
									
										111
									
								
								feeds/morse/netifd-morse/lib/netifd/morse/wpa_s1g_dpp_action.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										111
									
								
								feeds/morse/netifd-morse/lib/netifd/morse/wpa_s1g_dpp_action.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,111 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
|  | ||||
| . /lib/functions.sh | ||||
| . /usr/share/libubox/jshn.sh | ||||
| . /lib/netifd/netifd-wireless.sh | ||||
| . /etc/diag.sh | ||||
|  | ||||
| #returns 0 if config is complete | ||||
| is_config_complete() | ||||
| { | ||||
|     [ -z "$encryption" ] && return 1 | ||||
|  | ||||
|     #if encryption is sae, check if we have psk | ||||
|     if [ "$encryption" = "sae" ]; then | ||||
|         [ -z "$psk" ] && return 1 | ||||
|     fi | ||||
|  | ||||
|     #check if we have ssid | ||||
|     [ -z "$ssid" ] && return 1 | ||||
|  | ||||
|     return 0 | ||||
| } | ||||
|  | ||||
| get_uci_section() | ||||
| { | ||||
|     local target_iface=$1 | ||||
|     local dpp_wifi_iface= | ||||
|  | ||||
|     check_interface() { | ||||
|         json_get_vars section ifname | ||||
|         [ "$ifname" = "$target_iface" ] && [ -n "$section" ] && [ -z "$dpp_wifi_iface" ] && dpp_wifi_iface=$section | ||||
|     } | ||||
|  | ||||
|     wireless_status=$(ubus call network.wireless status) | ||||
|  | ||||
|     json_init | ||||
|     json_load "$wireless_status" | ||||
|     json_get_keys radios | ||||
|  | ||||
|     for radio in $radios; do | ||||
|         json_select $radio | ||||
|         for_each_interface "sta" check_interface | ||||
|         json_select .. | ||||
|     done | ||||
|     echo "$dpp_wifi_iface" | ||||
| } | ||||
|  | ||||
| save_and_reload() | ||||
| { | ||||
|     logger "Saving Received AP Credentials." | ||||
|     local uci_section=$(get_uci_section $iface_name) | ||||
|     if [ -z "$uci_section" ]; then | ||||
|         logger "FATAL: unable to find the correct wifi interface in configs." | ||||
|         exit 0 | ||||
|     fi | ||||
|  | ||||
|     uci set wireless.$uci_section.encryption="$encryption" | ||||
|  | ||||
|     #if encryption is sae, check if we have psk | ||||
|     if [ "$encryption" = "sae" ]; then | ||||
|         uci set wireless.$uci_section.key="$psk" | ||||
|     fi | ||||
|  | ||||
|     uci set wireless.$uci_section.ssid="$ssid" | ||||
|  | ||||
|     uci set wireless.$uci_section.dpp='0' | ||||
|  | ||||
|     uci commit | ||||
|     ubus call service event "{ \"type\": \"config.change\", \"data\": { \"package\": \"wireless\" }}" | ||||
| } | ||||
|  | ||||
| # Do not name 'config'; will clash with uci functions. | ||||
| do_config() { | ||||
|     # convert password from hex string to string. | ||||
|     psk="$(echo "$psk" | xxd -r -p)" | ||||
|  | ||||
|     # if the file contains all the necessary stuff, then save and reload. | ||||
|     is_config_complete && save_and_reload | ||||
| } | ||||
|  | ||||
| failed() { | ||||
|     set_state dpp_failed | ||||
| } | ||||
|  | ||||
| finished() { | ||||
|     set_state done | ||||
| } | ||||
|  | ||||
| started() { | ||||
|     set_state dpp_started | ||||
| } | ||||
|  | ||||
| case "$1" in | ||||
|     config) | ||||
|         do_config | ||||
|     ;; | ||||
|     failed) | ||||
|         failed | ||||
|     ;; | ||||
|     finished) | ||||
|         finished | ||||
|     ;; | ||||
|     started) | ||||
|         started | ||||
|     ;; | ||||
|     *) | ||||
|         echo "Usage: $0 {config|failed|finished|started}" | ||||
|         exit 1 | ||||
|     ;; | ||||
| esac | ||||
							
								
								
									
										1097
									
								
								feeds/morse/netifd-morse/lib/netifd/wireless/morse.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										1097
									
								
								feeds/morse/netifd-morse/lib/netifd/wireless/morse.sh
									
									
									
									
									
										Executable file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										139
									
								
								feeds/morse/netifd-morse/lib/wifi/morse.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										139
									
								
								feeds/morse/netifd-morse/lib/wifi/morse.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,139 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| # This script is copied and modified from | ||||
| # package/kernel/mac80211/files/lib/wifi/mac80211.sh | ||||
| # and modified (simplified) to work with morse devices. | ||||
|  | ||||
| append DRIVERS "morse" | ||||
|  | ||||
| # Find and set $phy for this $device (a wifi-device section name) | ||||
| lookup_phy() { | ||||
| 	[ -n "$phy" ] && { | ||||
| 		[ -d /sys/class/ieee80211/$phy ] && return | ||||
| 	} | ||||
|  | ||||
| 	local devpath | ||||
| 	config_get devpath "$device" path | ||||
| 	[ -n "$devpath" ] && { | ||||
| 		phy="$(iwinfo dot11ah phyname "path=$devpath")" | ||||
| 		[ -n "$phy" ] && return | ||||
| 	} | ||||
|  | ||||
| 	local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')" | ||||
| 	[ -n "$macaddr" ] && { | ||||
| 		for _phy in /sys/class/ieee80211/*; do | ||||
| 			[ -e "$_phy" ] || continue | ||||
|  | ||||
| 			[ "$macaddr" = "$(cat ${_phy}/macaddress)" ] || continue | ||||
| 			phy="${_phy##*/}" | ||||
| 			return | ||||
| 		done | ||||
| 	} | ||||
| 	phy= | ||||
| 	return | ||||
| } | ||||
|  | ||||
| # Find and save the phy and macaddr for this $device (a wifi-device section name) | ||||
| find_morse_phy() { | ||||
| 	local device="$1" | ||||
|  | ||||
| 	config_get phy "$device" phy | ||||
| 	lookup_phy | ||||
| 	[ -n "$phy" -a -d "/sys/class/ieee80211/$phy" ] || { | ||||
| 		echo "PHY for wifi device $1 not found" | ||||
| 		return 1 | ||||
| 	} | ||||
| 	config_set "$device" phy "$phy" | ||||
|  | ||||
| 	config_get macaddr "$device" macaddr | ||||
| 	[ -z "$macaddr" ] && { | ||||
| 		config_set "$device" macaddr "$(cat /sys/class/ieee80211/${phy}/macaddress)" | ||||
| 	} | ||||
|  | ||||
| 	return 0 | ||||
| } | ||||
|  | ||||
| # Set found=1 if the $phy for this $device (a wifi-device section name) is the same as $dev | ||||
| check_morse_device() { | ||||
| 	config_get phy "$1" phy | ||||
| 	[ -z "$phy" ] && { | ||||
| 		find_morse_phy "$1" >/dev/null || return 0 | ||||
| 		config_get phy "$1" phy | ||||
| 	} | ||||
| 	[ "$phy" = "$dev" ] && found=1 | ||||
| } | ||||
|  | ||||
| detect_morse() { | ||||
| 	devidx=0 | ||||
| 	config_load wireless | ||||
| 	while :; do | ||||
| 		config_get type "radio$devidx" type | ||||
| 		[ -n "$type" ] || break | ||||
| 		devidx=$(($devidx + 1)) | ||||
| 	done | ||||
|  | ||||
| 	for _dev in /sys/class/ieee80211/*; do | ||||
| 		[ -e "$_dev" ] || continue | ||||
|  | ||||
| 		# Only configure morse devices. | ||||
| 		basename "$(readlink -f "$_dev/device/driver/")" | grep '^morse_' || continue | ||||
|  | ||||
| 		dev="${_dev##*/}" | ||||
|  | ||||
| 		# Skip already configured devices. | ||||
| 		# The path or macaddr are used to find the corresponding phy. | ||||
| 		found=0 | ||||
| 		config_foreach check_morse_device wifi-device | ||||
| 		[ "$found" -gt 0 ] && continue | ||||
|  | ||||
| 		path="$(iwinfo dot11ah path "$dev")" | ||||
| 		if [ -n "$path" ]; then | ||||
| 			dev_id="set wireless.radio${devidx}.path='$path'" | ||||
| 		else | ||||
| 			dev_id="set wireless.radio${devidx}.macaddr=$(cat /sys/class/ieee80211/${dev}/macaddress)" | ||||
| 		fi | ||||
|  | ||||
| 		uci -q batch <<-EOF | ||||
| 			set wireless.radio${devidx}=wifi-device | ||||
| 			set wireless.radio${devidx}.type=morse | ||||
| 			${dev_id} | ||||
| 			set wireless.radio${devidx}.band=s1g | ||||
| 			set wireless.radio${devidx}.hwmode=11ah | ||||
| 			set wireless.radio${devidx}.reconf=0 | ||||
| 			set wireless.radio${devidx}.disabled=1 | ||||
|  | ||||
| 			set wireless.default_radio${devidx}=wifi-iface | ||||
| 			set wireless.default_radio${devidx}.mode=ap | ||||
| 			set wireless.default_radio${devidx}.wds=1 | ||||
| 			set wireless.default_radio${devidx}.device=radio${devidx} | ||||
| 			set wireless.default_radio${devidx}.network=lan | ||||
| 			set wireless.default_radio${devidx}.ssid=MorseMicro | ||||
| 			set wireless.default_radio${devidx}.encryption=sae | ||||
| 			set wireless.default_radio${devidx}.key=12345678 | ||||
| EOF | ||||
|  | ||||
| 		board=$(board_name) | ||||
|  | ||||
| 		case "$board" in | ||||
| 			morse,ekh01-03 |\ | ||||
| 			morse,ekh03v3) | ||||
| 				bcf=bcf_mf08551.bin | ||||
| 			;; | ||||
| 			morse,ekh01v1) | ||||
| 				bcf=bcf_mf03120.bin | ||||
| 			;; | ||||
| 			morse,ekh01v2) | ||||
| 				bcf=bcf_mf08251.bin | ||||
| 			;; | ||||
| 			morse,ekh04v4) | ||||
| 				bcf=bcf_ekh04_v4.bin | ||||
| 			;; | ||||
| 		esac | ||||
|  | ||||
| 		[ -n "${bcf}" ] && uci -q set wireless.radio${devidx}.bcf="${bcf}" | ||||
|  | ||||
| 		uci -q commit wireless | ||||
|  | ||||
| 		devidx=$(($devidx + 1)) | ||||
| 	done | ||||
| } | ||||
							
								
								
									
										17
									
								
								feeds/morse/utils/hostapd_s1g/Config.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								feeds/morse/utils/hostapd_s1g/Config.in
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| if PACKAGE_hostapd_s1g | ||||
|  | ||||
| 	config MORSE_HOSTAPD_S1G_EAP | ||||
| 		bool | ||||
| 		default n | ||||
| 		prompt "Enable Extensible Authentication Protocol (EAP) support" | ||||
|  | ||||
| 	config MORSE_HOSTAPD_S1G_ACS | ||||
| 		bool | ||||
| 		default n | ||||
| 		prompt "Enable automatic channel selection (ACS) support" | ||||
| 		help | ||||
| 			This will allow hostapd to pick the channel automatically when channel is set | ||||
| 			to "acs_survey" or "0". Eventually, other ACS algorithms can be added in | ||||
| 			similar way. | ||||
|  | ||||
| endif | ||||
							
								
								
									
										167
									
								
								feeds/morse/utils/hostapd_s1g/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										167
									
								
								feeds/morse/utils/hostapd_s1g/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,167 @@ | ||||
| # | ||||
| # Copyright 2022 Morse Micro | ||||
| # | ||||
| # This is free software, licensed under the 3-Clause BSD License. | ||||
| # See /LICENSE for more information. | ||||
| # | ||||
|  | ||||
| include $(TOPDIR)/rules.mk | ||||
|  | ||||
| PKG_NAME:=hostapd_s1g | ||||
| PKG_RELEASE=2 | ||||
|  | ||||
| PKG_VERSION:=1.12.4 | ||||
|  | ||||
| PKG_LICENSE:=BSD-3-Clause | ||||
|  | ||||
| PKG_SOURCE_VERSION:=$(PKG_VERSION) | ||||
| PKG_SOURCE_URL:=https://github.com/MorseMicro/hostap.git | ||||
| PKG_HASH:=a2f17ce3d2fe25d45cc2d6869e9ea644bcac441ec9b541972034768d4fc63608 | ||||
| PKG_SOURCE_PROTO:=git | ||||
|  | ||||
| PKG_MAINTAINER:=Morse Micro <info@morsemicro.com> | ||||
| PKG_BUILD_PARALLEL:=1 | ||||
|  | ||||
| PKG_CONFIG_DEPENDS:= \ | ||||
| 	CONFIG_PACKAGE_kmod-morse \ | ||||
| 	CONFIG_PACKAGE_kmod-cfg80211 \ | ||||
| 	CONFIG_PACKAGE_hostapd \ | ||||
| 	CONFIG_PACKAGE_hostapd-basic \ | ||||
| 	CONFIG_PACKAGE_hostapd-mini \ | ||||
| 	CONFIG_WPA_RFKILL_SUPPORT \ | ||||
| 	CONFIG_DRIVER_WEXT_SUPPORT \ | ||||
| 	CONFIG_DRIVER_11N_SUPPORT \ | ||||
| 	CONFIG_DRIVER_11AC_SUPPORT \ | ||||
| 	CONFIG_DRIVER_11AX_SUPPORT \ | ||||
| 	CONFIG_WPA_ENABLE_WEP | ||||
|  | ||||
| include $(INCLUDE_DIR)/package.mk | ||||
|  | ||||
| MAKE_FLAGS += \ | ||||
| 	MORSEHOSTAPD_VERSION_STRING=$(PKG_VERSION) | ||||
|  | ||||
| MMHOSTAPD_CONFIG_ENABLE = \ | ||||
| 	CONFIG_INTERNAL_LIBTOMMATH \ | ||||
| 	CONFIG_DEBUG_FILE \ | ||||
| 	CONFIG_DEBUG_SYSLOG \ | ||||
| 	CONFIG_PMKSA_CACHE_EXTERNAL \ | ||||
| 	CONFIG_SAE \ | ||||
| 	CONFIG_TESTING_OPTIONS \ | ||||
| 	CONFIG_WNM \ | ||||
| 	CONFIG_DRIVER_ACS \ | ||||
| 	CONFIG_DRIVER_HOSTAP \ | ||||
| 	CONFIG_DRIVER_NL80211 \ | ||||
| 	CONFIG_HS20 \ | ||||
| 	CONFIG_IEEE80211AC \ | ||||
| 	CONFIG_IEEE80211N \ | ||||
| 	CONFIG_IEEE80211AH \ | ||||
| 	CONFIG_IEEE80211R \ | ||||
| 	CONFIG_INTERWORKING \ | ||||
| 	CONFIG_FULL_DYNAMIC_VLAN \ | ||||
| 	CONFIG_VLAN_NETLINK \ | ||||
| 	CONFIG_OWE \ | ||||
| 	CONFIG_LIBNL32 \ | ||||
| 	CONFIG_DPP \ | ||||
| 	CONFIG_DPP2 \ | ||||
| 	CONFIG_WPS | ||||
|  | ||||
| MMHOSTAPD_CONFIG_SET = \ | ||||
| 	NEED_LINUX_IOCTL \ | ||||
| 	CONFIG_DPP \ | ||||
| 	CONFIG_SAE | ||||
|  | ||||
| MMHOSTAPD_CONFIG_DISABLE = \ | ||||
|     CONFIG_DRIVER_NONE \ | ||||
| 	CONFIG_DRIVER_RTW \ | ||||
| 	CONFIG_DRIVER_WIRED | ||||
|  | ||||
| MMHOSTAPD_CONFIG_EDITS += 's/\#\(CONFIG_TLS=openssl\)/\1/' | ||||
|  | ||||
| ifeq ($(CONFIG_MORSE_HOSTAPD_S1G_ACS),y) | ||||
| 	MMHOSTAPD_CONFIG_ENABLE += CONFIG_ACS | ||||
| endif | ||||
|  | ||||
| ifeq ($(CONFIG_MORSE_HOSTAPD_S1G_EAP),y) | ||||
| 	MMHOSTAPD_CONFIG_ENABLE += \ | ||||
| 		CONFIG_EAP \ | ||||
| 		CONFIG_RADIUS_SERVER \ | ||||
| 		CONFIG_TLSV1 | ||||
| else | ||||
| 	MMHOSTAPD_CONFIG_DISABLE += CONFIG_HOSTAPD_EAP | ||||
| 	MMHOSTAPD_CONFIG_ENABLE += \ | ||||
| 		CONFIG_NO_ACCOUNTING \ | ||||
| 		CONFIG_NO_RADIUS | ||||
| endif | ||||
|  | ||||
| define Package/hostapd_s1g | ||||
|   SECTION:=net | ||||
|   CATEGORY:=Network | ||||
|   SUBMENU:=WirelessAPD | ||||
|   TITLE:=Morse Micro HaLow hostapd | ||||
|   DEPENDS:= +kmod-morse +libnl +libopenssl +libubus | ||||
|   USERID:=network=101:network=101 | ||||
|   PROVIDES:=hostapd_s1g | ||||
| endef | ||||
|  | ||||
| define Package/hostapd_s1g/description | ||||
|  This package contains a full featured Morse Micro patched | ||||
|  Authenticator. | ||||
| endef | ||||
|  | ||||
| define Package/hostapd_s1g/config | ||||
|     source "$(SOURCE)/Config.in" | ||||
| endef | ||||
|  | ||||
| MMHOSTAPD_CONFIG = $(PKG_BUILD_DIR)/hostapd/.config | ||||
|  | ||||
| define Build/Prepare | ||||
|     $(call Build/Prepare/Default) | ||||
| 	$(CP) $(PKG_BUILD_DIR)/hostapd/defconfig $(MMHOSTAPD_CONFIG) | ||||
| 	sed -i $(patsubst %,-e 's/^#\(%\)/\1/',$(MMHOSTAPD_CONFIG_ENABLE)) \ | ||||
| 		$(patsubst %,-e 's/^\(%\)/#\1/',$(MMHOSTAPD_CONFIG_DISABLE)) \ | ||||
| 		$(patsubst %,-e '1i%=y',$(MMHOSTAPD_CONFIG_SET)) \ | ||||
| 		$(patsubst %,-e %,$(MMHOSTAPD_CONFIG_EDITS)) \ | ||||
| 		$(MMHOSTAPD_CONFIG) | ||||
| endef | ||||
|  | ||||
| TARGET_CPPFLAGS := \ | ||||
| 	-I$(STAGING_DIR)/usr/include/libnl3 \ | ||||
| 	-I$(PKG_BUILD_DIR)/src/crypto \ | ||||
| 	$(TARGET_CPPFLAGS) \ | ||||
| 	-DCONFIG_LIBNL20 \ | ||||
| 	-D_GNU_SOURCE | ||||
|  | ||||
| TARGET_LDFLAGS += -lnl-3 -lnl-genl-3 -lnl-route-3 | ||||
| TARGET_LDFLAGS += -lm -lpthread -lcrypto -lssl | ||||
|  | ||||
| TARGET_LDFLAGS += -lrt | ||||
| TARGET_LDFLAGS_C += -lrt | ||||
|  | ||||
| define Build/RunMake | ||||
| 	CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \ | ||||
| 	$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(1) \ | ||||
| 		$(TARGET_CONFIGURE_OPTS) \ | ||||
| 		$(DRIVER_MAKEOPTS) \ | ||||
| 		LIBS="$(TARGET_LDFLAGS)" \ | ||||
| 		LIBS_c="$(TARGET_LDFLAGS_C)" \ | ||||
| 		AR="$(TARGET_CROSS)gcc-ar" \ | ||||
| 		BCHECK= \ | ||||
| 		$(2) | ||||
| endef | ||||
|  | ||||
| define Build/Compile | ||||
| 	+$(call Build/RunMake,hostapd, \ | ||||
| 		hostapd_s1g hostapd_cli_s1g \ | ||||
| 	) | ||||
| endef | ||||
|  | ||||
| #Ian | ||||
| define Package/hostapd_s1g/install | ||||
| 	$(INSTALL_DIR) $(1)/sbin | ||||
| 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd_s1g $(1)/sbin | ||||
| 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/hostapd/hostapd_cli_s1g $(1)/sbin | ||||
| 	$(INSTALL_DIR) $(1)/lib/netifd | ||||
| 	$(INSTALL_DATA) ./files/lib/netifd/hostapd_s1g.sh $(1)/lib/netifd  | ||||
| endef | ||||
|  | ||||
| $(eval $(call BuildPackage,hostapd_s1g)) | ||||
							
								
								
									
										1603
									
								
								feeds/morse/utils/hostapd_s1g/files/lib/netifd/hostapd_s1g.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1603
									
								
								feeds/morse/utils/hostapd_s1g/files/lib/netifd/hostapd_s1g.sh
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -0,0 +1,45 @@ | ||||
| From 5433351ed5ab62c2d4fbd15a2c4d8c4aeacb93dc Mon Sep 17 00:00:00 2001 | ||||
| From: Evan Benn <evan.benn@morsemicro.com> | ||||
| Date: Thu, 29 Feb 2024 11:09:38 +1100 | ||||
| Subject: [PATCH] APP-2573: Emit a DPP PB_STATUS event when push button starts | ||||
|  | ||||
| --- | ||||
|  src/ap/dpp_hostapd.c            | 1 + | ||||
|  wpa_supplicant/dpp_supplicant.c | 2 ++ | ||||
|  2 files changed, 3 insertions(+) | ||||
|  | ||||
| diff --git a/src/ap/dpp_hostapd.c b/src/ap/dpp_hostapd.c | ||||
| index b7cca47c714b..3025eef204d2 100644 | ||||
| --- a/src/ap/dpp_hostapd.c | ||||
| +++ b/src/ap/dpp_hostapd.c | ||||
| @@ -3960,6 +3960,7 @@ int hostapd_dpp_push_button(struct hostapd_data *hapd, const char *cmd) | ||||
|  	eloop_register_timeout(100, 0, hostapd_dpp_push_button_expire, | ||||
|  			       hapd, NULL); | ||||
|   | ||||
| +	wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_PB_STATUS "started"); | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c | ||||
| index ab06ff8d32c1..24e4bb3c444d 100644 | ||||
| --- a/wpa_supplicant/dpp_supplicant.c | ||||
| +++ b/wpa_supplicant/dpp_supplicant.c | ||||
| @@ -5676,6 +5676,7 @@ static int wpas_dpp_push_button_configurator(struct wpa_supplicant *wpa_s, | ||||
|  	eloop_register_timeout(100, 0, wpas_dpp_push_button_expire, | ||||
|  			       wpa_s, NULL); | ||||
|   | ||||
| +	wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_PB_STATUS "started"); | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| @@ -5749,6 +5750,7 @@ int wpas_dpp_push_button(struct wpa_supplicant *wpa_s, const char *cmd) | ||||
|  	wpa_supplicant_req_scan(wpa_s, 0, 0); | ||||
|   | ||||
|  	res = 0; | ||||
| +	wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_PB_STATUS "started"); | ||||
|  out: | ||||
|   | ||||
|  	/* If push button mode failed to start, restart the chirp forever timer */ | ||||
| --  | ||||
| 2.42.0.530.g692be87cbba5 | ||||
|  | ||||
| @@ -0,0 +1,90 @@ | ||||
| From 25631fa387af430b8d7f03302218c66dc161cc6f Mon Sep 17 00:00:00 2001 | ||||
| From: Andrew Pope <andrew.pope@morsemicro.com> | ||||
| Date: Tue, 4 Jun 2024 23:12:37 +0000 | ||||
| Subject: [PATCH] Merged in SW-11943-dpp-does-not-associate-in-us-regdom (pull | ||||
|  request #213) | ||||
|  | ||||
| SW-11943: DPP does not associate in US regdom | ||||
|  | ||||
| Two problems contributed to the originally reported issue: | ||||
|  | ||||
| 1. The DPP-PB state machine function will unconditionally cancel any pending off-channel actions - even if the DPP PB discovery phase is over. To fix this, avoid unconditionally completing offchannel actions from DPP-PB state machine function if DPP PB discovery phase is over. | ||||
|  | ||||
| 2. Logic around PKEX retries will manually attempt to complete the exchange on adjacent non-S1G channels. These retries inevitably fail, leading to a quicker collapse of the PKEX exchange attempts and eventual downgrade from v2 to v1 (bad). To fix this, remove non-S1G frequency hopping logic from DPP PB discovery and PKEX exchange phases. | ||||
|  | ||||
| Approved-by: Neville Young | ||||
| Approved-by: Simon Wadsworth | ||||
| Approved-by: Ayman Grais | ||||
| Approved-by: James Herbert | ||||
| --- | ||||
|  src/ap/dpp_hostapd.c            |  6 ++++++ | ||||
|  wpa_supplicant/dpp_supplicant.c | 17 +++++++++++++++-- | ||||
|  2 files changed, 21 insertions(+), 2 deletions(-) | ||||
|  | ||||
| diff --git a/src/ap/dpp_hostapd.c b/src/ap/dpp_hostapd.c | ||||
| index b7cca47c7..282581fe5 100644 | ||||
| --- a/src/ap/dpp_hostapd.c | ||||
| +++ b/src/ap/dpp_hostapd.c | ||||
| @@ -260,6 +260,12 @@ static int hostapd_dpp_allow_ir(struct hostapd_data *hapd, unsigned int freq) | ||||
|  static int hostapd_dpp_pkex_next_channel(struct hostapd_data *hapd, | ||||
|  					 struct dpp_pkex *pkex) | ||||
|  { | ||||
| +	/* Following logic is not S1G compatible. Attempting PKEX on non-adjacent S1G channels | ||||
| +	 * results in guaranteed failure. | ||||
| +	 */ | ||||
| +	if (hapd->iconf->ieee80211ah) | ||||
| +		return -1; | ||||
| + | ||||
|  	if (pkex->freq == 2437) | ||||
|  		pkex->freq = 5745; | ||||
|  	else if (pkex->freq == 5745) | ||||
| diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c | ||||
| index ab06ff8d3..e90e4a163 100644 | ||||
| --- a/wpa_supplicant/dpp_supplicant.c | ||||
| +++ b/wpa_supplicant/dpp_supplicant.c | ||||
| @@ -2840,6 +2840,12 @@ static int wpas_dpp_allow_ir(struct wpa_supplicant *wpa_s, unsigned int freq) | ||||
|  static int wpas_dpp_pkex_next_channel(struct wpa_supplicant *wpa_s, | ||||
|  				      struct dpp_pkex *pkex) | ||||
|  { | ||||
| +#if defined(CONFIG_IEEE80211AH) | ||||
| +	/* Following logic is not S1G compatible. Attempting PKEX on non-adjacent S1G channels | ||||
| +	 * results in guaranteed failure. | ||||
| +	 */ | ||||
| +	return -1; | ||||
| +#endif | ||||
|  	if (pkex->freq == 2437) | ||||
|  		pkex->freq = 5745; | ||||
|  	else if (pkex->freq == 5745) | ||||
| @@ -5113,10 +5119,16 @@ static int * wpas_dpp_presence_ann_channels(struct wpa_supplicant *wpa_s, | ||||
|   | ||||
|  			if (chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_RADAR)) | ||||
|  				continue; | ||||
| +#if defined(CONFIG_IEEE80211AH) | ||||
| +			/* Adding channels 44 and 149 at end of scan list is not required | ||||
| +			 * for HaLow | ||||
| +			 */ | ||||
| +#else | ||||
|  			if (chan->freq == 5220) | ||||
|  				chan44 = 1; | ||||
|  			if (chan->freq == 5745) | ||||
|  				chan149 = 1; | ||||
| +#endif | ||||
|   | ||||
|  			/* Morse - All 5GHz channels that are mapped to 1 MHz and 2 MHz. | ||||
|  			 * Channels that aren't relevant to a regulatory domain will be | ||||
| @@ -5573,9 +5585,10 @@ static void wpas_dpp_pb_next(void *eloop_ctx, void *timeout_ctx) | ||||
|  	if (!wpa_s->dpp_pb_freqs) | ||||
|  		return; | ||||
|   | ||||
| -	os_get_reltime(&now); | ||||
| -	offchannel_send_action_done(wpa_s); | ||||
| +	if (!wpa_s->dpp_pb_discovery_done) | ||||
| +		offchannel_send_action_done(wpa_s); | ||||
|   | ||||
| +	os_get_reltime(&now); | ||||
|  	if (os_reltime_expired(&now, &wpa_s->dpp_pb_time, 100)) { | ||||
|  		wpa_printf(MSG_DEBUG, "DPP: Push button wait time expired"); | ||||
|  		wpas_dpp_push_button_stop(wpa_s); | ||||
| --  | ||||
| 2.25.1 | ||||
|  | ||||
| @@ -0,0 +1,35 @@ | ||||
| From 591ec24748525171d5647d2a35cd1da1445e7a0b Mon Sep 17 00:00:00 2001 | ||||
| From: James Haggerty <james.haggerty@morsemicro.com> | ||||
| Date: Fri, 26 Jul 2024 09:55:03 +1000 | ||||
| Subject: [PATCH] Hack out channel 50 (and typo for 51) | ||||
|  | ||||
| If we use these channels on a board with those channels disabled, | ||||
| the DPP presence announcement fails. | ||||
|  | ||||
| This is rubbish: see SW-12450 | ||||
| --- | ||||
|  wpa_supplicant/dpp_supplicant.c | 4 ++-- | ||||
|  1 file changed, 2 insertions(+), 2 deletions(-) | ||||
|  | ||||
| diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c | ||||
| index 09f8ceb07..46e4add95 100644 | ||||
| --- a/wpa_supplicant/dpp_supplicant.c | ||||
| +++ b/wpa_supplicant/dpp_supplicant.c | ||||
| @@ -5199,12 +5199,12 @@ static int * wpas_dpp_presence_ann_channels(struct wpa_supplicant *wpa_s, | ||||
|  			static const int s1g_chirp_channels[] = { | ||||
|  				/* 2MHz channels */ | ||||
|  				5190, 5230, 5270, 5310, 5510, 5550, | ||||
| -				5630, 5670, 5755, 5795, 5835, 5875, | ||||
| +				5630, 5670, 5755, 5795, 5835, | ||||
|  				/* 1MHz channels */ | ||||
|  				5660, 5680, 5180, 5200, 5240, 5260, | ||||
|  				5280, 5300, 5320, 5500, 5520, 5540, | ||||
|  				5560, 5580, 5600, 5620, 5640, 5765, | ||||
| -				5785, 5805, 5825, 5845, 5865, 5855 | ||||
| +				5785, 5805, 5825, 5845, 5865 | ||||
|  			}; | ||||
|   | ||||
|  			if (chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_RADAR)) | ||||
| --  | ||||
| 2.25.1 | ||||
|  | ||||
							
								
								
									
										73
									
								
								feeds/morse/utils/morse_mesh11sd/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								feeds/morse/utils/morse_mesh11sd/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | ||||
| # SPDX-License-Identifier: GPL-2.0-only | ||||
| # | ||||
| #The mesh11sd dameon is designed in such a way that all configuration done to 11s mesh can be directly set to the | ||||
| #mac80211 via iw utility and does not require any re-configuration of interfaces. Considering the MorseMicro design and | ||||
| #implementation of 802.11s mesh, most of the configuration needs to be applied to the wpa_supplicant.conf which requires | ||||
| #re-configuration of the interface. | ||||
| #Thus we need a reload_service section to mesh11sd that will re-configure wifi via wifi down and up. | ||||
| # | ||||
| #Openwrt provided Mesh11sd package is found in: https://github.com/openwrt/routing/tree/master/mesh11sd | ||||
| # | ||||
| # This is free software, licensed under the GNU General Public License v2. | ||||
| # See /LICENSE for more information. | ||||
| # Copyright (C) 2022 BlueWave Projects and Services  <licence@blue-wave.net> | ||||
| # | ||||
|  | ||||
| include $(TOPDIR)/rules.mk | ||||
|  | ||||
| PKG_NAME:=morse_mesh11sd | ||||
| PKG_VERSION:=1.2.0 | ||||
| PKG_RELEASE:=$(AUTORELEASE) | ||||
|  | ||||
| PKG_MAINTAINER:=Rob White <rob@blue-wave.net> | ||||
| PKG_LICENSE:=GPL-2.0-or-later | ||||
| PKG_LICENSE_FILES:=LICENSE | ||||
|  | ||||
| PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz | ||||
| PKG_SOURCE_URL:=https://codeload.github.com/opennds/mesh11sd/tar.gz/v$(PKG_VERSION)? | ||||
| PKG_HASH:=b719eaacf63eb3684d0cd6a026f4357a4f400f2339f5d5a6cf74ba3744fe30d8 | ||||
| PKG_BUILD_DIR:=$(BUILD_DIR)/mesh11sd-$(PKG_VERSION) | ||||
|  | ||||
| include $(INCLUDE_DIR)/package.mk | ||||
|  | ||||
| define Package/morse_mesh11sd | ||||
|   SUBMENU:=Captive Portals | ||||
|   SECTION:=net | ||||
|   CATEGORY:=Network | ||||
|   TITLE:=Dynamic 802.11s Mesh Configuration Daemon | ||||
|   PKGARCH:=all | ||||
|   URL:=https://github.com/opennds/mesh11sd | ||||
|   PROVIDES:=mesh11sd | ||||
| endef | ||||
|  | ||||
| define Package/morse_mesh11sd/description | ||||
|   Mesh11sd is a dynamic parameter configuration daemon for 802.11s mesh networks. | ||||
|   It was originally designed to leverage 802.11s mesh networking at Captive Portal venues. | ||||
|   This is the open source version and it enables easy and automated mesh network operation with multiple mesh nodes. | ||||
|   It allows all mesh parameters supported by the wireless driver to be set in the uci config file. | ||||
|   Settings take effect immediately without having to restart the wireless network. | ||||
|   Default settings give rapid and reliable layer 2 mesh convergence. | ||||
|   Without mesh11sd, many mesh parameters cannot be set in the uci wireless config file as the mesh interface must be up before the parameters can be set. | ||||
|   Some of those that are supported, would fail to be implemented when the network is (re)started resulting in errors or dropped nodes. | ||||
|   The mesh11sd daemon dynamically checks configured parameters and sets them as required. | ||||
|   This version does not require a Captive Portal to be running. | ||||
|   The modified morse_mesh11sd would allow reconfiguring the wpa supplicant everytime there is 11sMesh config modification. | ||||
| endef | ||||
|  | ||||
| define Package/morse_mesh11sd/install | ||||
| 	$(INSTALL_DIR) $(1)/usr/sbin | ||||
| 	$(INSTALL_DIR) $(1)/etc/config | ||||
| 	$(INSTALL_DIR) $(1)/etc/init.d | ||||
| 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/mesh11sd $(1)/usr/sbin | ||||
| 	$(INSTALL_CONF) ./files/etc/config/mesh11sd $(1)/etc/config/ | ||||
| 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/linux_openwrt/mesh11sd/files/etc/init.d/mesh11sd $(1)/etc/init.d/ | ||||
| endef | ||||
|  | ||||
| define Package/morse_mesh11sd/conffiles | ||||
| /etc/config/mesh11sd | ||||
| endef | ||||
|  | ||||
| define Build/Compile | ||||
| endef | ||||
|  | ||||
| $(eval $(call BuildPackage,morse_mesh11sd)) | ||||
							
								
								
									
										28
									
								
								feeds/morse/utils/morse_mesh11sd/files/etc/config/mesh11sd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								feeds/morse/utils/morse_mesh11sd/files/etc/config/mesh11sd
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| config mesh11sd 'setup' | ||||
|         option debuglevel '1' | ||||
|         option checkinterval '10' | ||||
|         option interface_timeout '10' | ||||
|         option enabled '0' | ||||
|  | ||||
| config mesh11sd 'mesh_params' | ||||
|         option mesh_fwding '1' | ||||
|         option mesh_max_peer_links '10' | ||||
|         option mesh_rssi_threshold '-85' | ||||
|         option mesh_ttl '31' | ||||
|         option mesh_hwmp_rootmode '0' | ||||
|         option mesh_gate_announcements '0' | ||||
|  | ||||
| config mesh11sd 'mbca' | ||||
|         option mbca_config '1' | ||||
|         option mesh_beacon_timing_report_int '10' | ||||
|         option mbss_start_scan_duration_ms '2048' | ||||
|         option mbca_min_beacon_gap_ms '25' | ||||
|         option mbca_tbtt_adj_interval_sec '60' | ||||
|  | ||||
| config mesh11sd 'mesh_beaconless' | ||||
|         option mesh_beacon_less_mode '0' | ||||
|  | ||||
| config mesh11sd 'mesh_dynamic_peering' | ||||
|         option enabled '0' | ||||
|         option mesh_rssi_margin '5' | ||||
|         option mesh_blacklist_timeout '60' | ||||
| @@ -0,0 +1,16 @@ | ||||
| Index: mesh11sd-1.2.0/linux_openwrt/mesh11sd/files/etc/init.d/mesh11sd | ||||
| =================================================================== | ||||
| --- mesh11sd-1.2.0.orig/linux_openwrt/mesh11sd/files/etc/init.d/mesh11sd | ||||
| +++ mesh11sd-1.2.0/linux_openwrt/mesh11sd/files/etc/init.d/mesh11sd | ||||
| @@ -11,3 +11,11 @@ start_service() { | ||||
|  	procd_close_instance | ||||
|  } | ||||
|   | ||||
| +reload_service() { | ||||
| +        wifi down | ||||
| +        sleep 5 | ||||
| +        wifi up | ||||
| +} | ||||
| +service_triggers() { | ||||
| +        procd_add_reload_trigger "mesh11sd" | ||||
| +} | ||||
| @@ -0,0 +1,107 @@ | ||||
| # Description: The Mesh11sd daemon expects the mesh interface name to follow the format 'mesh<index>'.  | ||||
| # If it doesn't find this format, it attempts to set it in the UCI wireless configuration.  | ||||
| # However, when operating in other modes such as AP, STA, or Ad-Hoc, the script was patched to remove  | ||||
| # the mesh interface name from UCI. This process can lead to a race condition between the UI and Mesh11sd, | ||||
| # resulting in stale interface name values. | ||||
| # This patch resolves the issue by removing the setting of the interface name from the script, as it is  | ||||
| # now managed through the UI, ensuring consistency and eliminating the race condition. | ||||
|  | ||||
| --- a/src/mesh11sd | ||||
| +++ b/src/mesh11sd | ||||
| @@ -387,45 +387,45 @@ elif [ "$1" = "daemon" ]; then | ||||
|   | ||||
|  		if [ $mode -eq 5 ]; then | ||||
|  			# startup=4, statusmode=0, enabled=1 | ||||
| +			syslogmessage="mesh11sd v$version has started: mesh management mode $mode" | ||||
|  			startup=0 | ||||
|  			statusmode=0 | ||||
|  			mode=1 | ||||
| -			syslogmessage="mesh11sd v$version has started: mesh management mode $mode" | ||||
|   | ||||
|  		elif [ $mode -eq 4 ]; then | ||||
|  			# startup=4, statusmode=0, enabled=0 | ||||
| +			syslogmessage="mesh11sd v$version has started: mesh status mode $mode" | ||||
|  			startup=0 | ||||
|  			statusmode=2 | ||||
|  			mode=0 | ||||
| -			syslogmessage="mesh11sd v$version has started: mesh status mode $mode" | ||||
|   | ||||
|  		elif [ $mode -eq 3 ]; then | ||||
|  			# startup=0, statusmode=2, enabled=1 | ||||
| +			syslogmessage="mesh11sd v$version has started: mesh management mode $mode" | ||||
|  			startup=0 | ||||
|  			statusmode=0 | ||||
|  			mode=1 | ||||
| -			syslogmessage="mesh11sd v$version has started: mesh management mode $mode" | ||||
|   | ||||
|  		elif [ $mode -eq 2 ]; then | ||||
|  			# startup=0, statusmode=2, enabled=0 | ||||
| +			syslogmessage="mesh11sd v$version has started: mesh status mode $mode" | ||||
|  			startup=0 | ||||
|  			statusmode=2 | ||||
|  			mode=0 | ||||
| -			syslogmessage="mesh11sd v$version has started: mesh status mode $mode" | ||||
|   | ||||
|  		elif [ $mode -eq 1 ]; then | ||||
|  			# startup=0, statusmode=0, enabled=1 | ||||
| +			syslogmessage="mesh11sd v$version has started, mesh management mode $mode" | ||||
|  			startup=0 | ||||
|  			statusmode=0 | ||||
|  			mode=1 | ||||
| -			syslogmessage="mesh11sd v$version has started, mesh management mode $mode" | ||||
|   | ||||
|  		elif [ $mode -eq 0 ]; then | ||||
|  			# startup=0, statusmode=0, enabled=0 | ||||
| +			syslogmessage="mesh11sd v$version has started: mesh status mode $mode" | ||||
|  			startup=0 | ||||
|  			statusmode=2 | ||||
|  			mode=0 | ||||
| -			syslogmessage="mesh11sd v$version has started: mesh status mode $mode" | ||||
|  		fi | ||||
|   | ||||
|  		if [ $mode -ne $lastmode ]; then | ||||
| @@ -441,26 +441,6 @@ elif [ "$1" = "daemon" ]; then | ||||
|  			meshconfigs=$(uci show wireless 2> /dev/null | grep "mode='mesh'" | awk -F ".mode='mesh'" '{printf "%s " $1}') | ||||
|   | ||||
|  			if [ ! -z "$meshconfigs" ]; then | ||||
| -				for meshconfig in $meshconfigs; do | ||||
| -					ifname=$(uci get $meshconfig.ifname 2> /dev/null) | ||||
| - | ||||
| -					if [ -z "$ifname" ] || [ "$ifname" != "mesh$meshindex" ]; then | ||||
| -						# No interface name in config, so add one | ||||
| -						ucibatch="set $meshconfig.ifname='mesh$meshindex'" | ||||
| -						echo "$ucibatch" | uci batch | ||||
| -						changed=1 | ||||
| -						syslogmessage="Setting mesh interface name to [ mesh$meshindex ]" | ||||
| -						write_to_syslog | ||||
| -					fi | ||||
| -					meshindex=$(($meshindex+1)) | ||||
| -				done | ||||
| - | ||||
| -				if [ "$changed" -eq 1 ]; then | ||||
| -					changed=0 | ||||
| -					restart_mesh | ||||
| -					continue | ||||
| -				fi | ||||
| - | ||||
|  				# get a list of interfaces | ||||
|  				get_mesh_iflist | ||||
|   | ||||
| @@ -482,13 +462,13 @@ elif [ "$1" = "daemon" ]; then | ||||
|  						# this is not a mesh interface | ||||
|  						continue | ||||
|  					else | ||||
| -						# Check if this interface has a uci ifname | ||||
| -						uciname=$(uci show wireless | grep "ifname='$iface'" | awk -F "." '{printf "wireless.%s" $2}') | ||||
| +						# Check if this interface mode is 'mesh' | ||||
| +						uciname=$(uci show wireless | grep "mode='mesh'" | awk -F "." '{printf "wireless.%s" $2}') | ||||
|   | ||||
|  						if [ -z "$uciname" ]; then | ||||
| -							# Error - No interface name in config, we should have added one | ||||
| +							# Error - No interface with mode as mesh | ||||
|  							debugtype="err" | ||||
| -							syslogmessage="Error getting mesh interface name" | ||||
| +							syslogmessage="Error getting mesh interface section" | ||||
|  							write_to_syslog | ||||
|  							continue | ||||
|  						fi | ||||
							
								
								
									
										49
									
								
								feeds/morse/utils/morsecli/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								feeds/morse/utils/morsecli/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,49 @@ | ||||
| # | ||||
| # Copyright 2023 Morse Micro | ||||
| # | ||||
| # This is free software, licensed under the GNU General Public License v2. | ||||
| # See /LICENSE for more information. | ||||
| # | ||||
|  | ||||
| include $(TOPDIR)/rules.mk | ||||
|  | ||||
| PKG_NAME:=morsecli | ||||
| PKG_RELEASE=5 | ||||
|  | ||||
| PKG_VERSION:=1.12.4 | ||||
|  | ||||
| PKG_LICENSE:=GPLv2 | ||||
| PKG_LICENSE_FILES:= | ||||
|  | ||||
| PKG_SOURCE_VERSION:=$(PKG_VERSION) | ||||
| PKG_SOURCE_URL:=https://github.com/MorseMicro/morse_cli.git | ||||
| PKG_HASH:=04c88a3aea99082a29eb1f84a9b62dcbb85980fa040e0e34901c1826f33ae74c | ||||
| PKG_SOURCE_PROTO:=git | ||||
|  | ||||
| PKG_MAINTAINER:=Morse Micro <info@morsemicro.com> | ||||
| PKG_BUILD_PARALLEL:=1 | ||||
|  | ||||
| include $(INCLUDE_DIR)/package.mk | ||||
|  | ||||
| define Package/morsecli | ||||
|   SECTION:=utils | ||||
|   CATEGORY:=Network | ||||
|   TITLE:=Morse Micro WIFI HaLow driver command line tool | ||||
|   DEPENDS:= +kmod-morse +libnl | ||||
|   FILES:=\ | ||||
| 	$(PKG_BUILD_DIR)/morse_cli | ||||
|   PROVIDES:=morsectrl | ||||
| endef | ||||
|  | ||||
| MAKE_FLAGS += \ | ||||
|     MORSECTRL_VERSION_STRING=$(PKG_VERSION) \ | ||||
|     CONFIG_MORSE_TRANS_NL80211=1 \ | ||||
|  | ||||
| TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/libnl3 | ||||
|  | ||||
| define Package/morsecli/install | ||||
| 	$(INSTALL_DIR) $(1)/sbin | ||||
| 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/morse_cli $(1)/sbin/ | ||||
| endef | ||||
|  | ||||
| $(eval $(call BuildPackage,morsecli)) | ||||
							
								
								
									
										33
									
								
								feeds/morse/utils/wpa_event_listener/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								feeds/morse/utils/wpa_event_listener/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| # | ||||
| # Copyright 2023 Morse Micro | ||||
| # | ||||
| # This is free software, licensed under the GNU General Public License v2. | ||||
| # See /LICENSE for more information. | ||||
| # | ||||
|  | ||||
| include $(TOPDIR)/rules.mk | ||||
|  | ||||
| PKG_NAME:=wpa_event_listener | ||||
| PKG_RELEASE:=1 | ||||
|  | ||||
| include $(INCLUDE_DIR)/package.mk | ||||
|  | ||||
| define Package/wpa_event_listener | ||||
|   SECTION:=utils | ||||
|   CATEGORY:=Base system | ||||
|   TITLE:= WPA supplicant s1g event listener | ||||
|   MAINTAINER:=Morse Micro | ||||
|   DEPENDS:= wpa_supplicant_s1g +libwpa_client | ||||
| endef | ||||
|  | ||||
| define Package/wpa_event_listener/description | ||||
|  A Daemon to listen to wpa supplicant s1g events. | ||||
| endef | ||||
|  | ||||
| define Package/wpa_event_listener/install | ||||
| 	$(INSTALL_DIR) $(1)/usr/sbin | ||||
|  | ||||
| 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/wpa_event_listener 	$(1)/usr/sbin | ||||
| endef | ||||
|  | ||||
| $(eval $(call BuildPackage,wpa_event_listener)) | ||||
							
								
								
									
										24
									
								
								feeds/morse/utils/wpa_event_listener/src/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								feeds/morse/utils/wpa_event_listener/src/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| # | ||||
| # Copyright (C) 2023-2024 Morse Micro Pty Ltd. All rights reserved | ||||
| # | ||||
| APP=wpa_event_listener | ||||
|  | ||||
| LDFLAGS+=-lwpa_client -lubox | ||||
|  | ||||
| ODIR=build | ||||
|  | ||||
| _OBJ = wpa_event_listener.o | ||||
| OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ)) | ||||
|  | ||||
|  | ||||
| $(ODIR)/%.o: %.c | ||||
| 	mkdir $(ODIR) -p | ||||
| 	$(CC) -c -o $@ $< $(CFLAGS) | ||||
|  | ||||
| $(APP): $(OBJ) | ||||
| 	$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) | ||||
|  | ||||
| .PHONY: clean | ||||
|  | ||||
| clean: | ||||
| 	rm -rf $(ODIR) $(APP) | ||||
							
								
								
									
										401
									
								
								feeds/morse/utils/wpa_event_listener/src/wpa_event_listener.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										401
									
								
								feeds/morse/utils/wpa_event_listener/src/wpa_event_listener.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,401 @@ | ||||
| /* | ||||
|  *  copyright (C) 2023-2024 Morse Micro Pty Ltd. All rights reserved. | ||||
|  */ | ||||
|  | ||||
| #include <dirent.h> | ||||
| #include <errno.h> | ||||
| #include <libubox/uloop.h> | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
| #include <sys/wait.h> | ||||
| #include <unistd.h> | ||||
| #include <wpa_ctrl.h> | ||||
|  | ||||
| #define CONFIG_CTRL_IFACE_DIR "/var/run/wpa_supplicant_s1g" | ||||
| #define wpa_el_version "V1.0.0" | ||||
|  | ||||
| enum event_value_types { | ||||
|     TYPE_CONF_RECEIVED, | ||||
|     TYPE_ENCRYPTION, | ||||
|     TYPE_SSID, | ||||
|     TYPE_PSK, | ||||
|     TYPE_CONNECTOR, | ||||
|     TYPE_C_SIGN_KEY, | ||||
|     TYPE_PP_KEY, | ||||
|     TYPE_NET_ACCESS_KEY, | ||||
|     TYPE_CTRL_EVENT_TERMINATING, | ||||
|     TYPE_PB_RESULT, | ||||
|     TYPE_PB_STATUS, | ||||
| }; | ||||
|  | ||||
| struct event { | ||||
|     const char *const event_title; | ||||
|     const enum event_value_types event_type; | ||||
| }; | ||||
|  | ||||
| /* dpp connector, c-sign-key, pp-key and net access key will be received after | ||||
|  * qrcode provisionning but they are ignored by now. | ||||
|  */ | ||||
| static struct event interresting_events[] = { | ||||
|     {"DPP-CONF-RECEIVED", TYPE_CONF_RECEIVED}, | ||||
|     {"DPP-CONFOBJ-AKM", TYPE_ENCRYPTION}, | ||||
|     {"DPP-CONFOBJ-SSID", TYPE_SSID}, | ||||
|     {"DPP-CONFOBJ-PASS", TYPE_PSK}, | ||||
|     // { "DPP-CONNECTOR"       , TYPE_CONNECTOR }, | ||||
|     // { "DPP-C-SIGN-KEY"      , TYPE_C_SIGN_KEY }, | ||||
|     // { "DPP-PP-KEY"          , TYPE_PP_KEY }, | ||||
|     // { "DPP-NET-ACCESS-KEY"  , TYPE_NET_ACCESS_KEY }, | ||||
|     {"DPP-PB-STATUS", TYPE_PB_STATUS}, | ||||
|     {"DPP-PB-RESULT", TYPE_PB_RESULT}, | ||||
|     {"CTRL-EVENT-TERMINATING", TYPE_CTRL_EVENT_TERMINATING}, | ||||
| }; | ||||
|  | ||||
| static struct { | ||||
|     char *encryption; | ||||
|     char *ssid; | ||||
|     char *psk; | ||||
|     // char* connector; | ||||
|     // char* c_sign_key; | ||||
|     // char* pp_key; | ||||
|     // char* net_access_key; | ||||
| } cached_confs; | ||||
|  | ||||
| static struct wpa_ctrl *ctrl_conn; | ||||
| static struct uloop_fd listener; | ||||
|  | ||||
| static void led_timeout_cb(struct uloop_timeout*); | ||||
| static struct uloop_timeout led_timeout = { | ||||
|     .cb = led_timeout_cb, | ||||
| }; | ||||
| static void led_failed_cb(struct uloop_timeout *); | ||||
| static struct uloop_timeout failed_timeout = { | ||||
|     .cb = led_failed_cb, | ||||
| }; | ||||
|  | ||||
| static char *ctrl_ifname = NULL; | ||||
| static char *action_script = NULL; | ||||
| static const char *ctrl_iface_dir = CONFIG_CTRL_IFACE_DIR; | ||||
| static const char *pid_file = NULL; | ||||
| static int exit_on_config_receive = 1; | ||||
|  | ||||
| void cache_received_confs(char **config, const char *const value) { | ||||
|     // check if the config is already allocated. | ||||
|     if (*config) | ||||
|         free(*config); | ||||
|     *config = strdup(value); | ||||
| } | ||||
|  | ||||
| void clean_pointer(char **ptr) { | ||||
|     if (*ptr) { | ||||
|         free(*ptr); | ||||
|         *ptr = NULL; | ||||
|     } | ||||
| } | ||||
|  | ||||
| void clear_cached_confs() { | ||||
|     clean_pointer(&cached_confs.encryption); | ||||
|     clean_pointer(&cached_confs.ssid); | ||||
|     clean_pointer(&cached_confs.psk); | ||||
| } | ||||
|  | ||||
| void clear_env() { | ||||
|     unsetenv("iface_name"); | ||||
|     unsetenv("encryption"); | ||||
|     unsetenv("ssid"); | ||||
|     unsetenv("psk"); | ||||
| } | ||||
|  | ||||
| void apply_cached_confs() { | ||||
|     // make sure that all needed configs are cached. | ||||
|     if (!cached_confs.encryption || !cached_confs.ssid || !cached_confs.psk) | ||||
|         return; | ||||
|  | ||||
|     printf("Configs: \n"); | ||||
|     printf("    encryption: %s\n", cached_confs.encryption); | ||||
|     printf("    ssid: %s\n", cached_confs.ssid); | ||||
|     printf("    psk: %s\n", cached_confs.psk); | ||||
|  | ||||
|     pid_t pid = 0; | ||||
|     // only fork if we don't want to exit after receiving configs. | ||||
|     if (exit_on_config_receive == 0) { | ||||
|         pid = fork(); | ||||
|         if (pid == -1) { | ||||
|             printf("Unable to fork action script\n"); | ||||
|             return; | ||||
|         } | ||||
|         // forked process will have pid=0. | ||||
|         if (pid > 0) | ||||
|             return; | ||||
|     } | ||||
|  | ||||
|     setenv("iface_name", ctrl_ifname, 1); | ||||
|     setenv("encryption", cached_confs.encryption, 1); | ||||
|     setenv("ssid", cached_confs.ssid, 1); | ||||
|     setenv("psk", cached_confs.psk, 1); | ||||
|     if (execl(action_script, action_script, "config", (char *)NULL) == -1) { | ||||
|         perror("Could not execv"); | ||||
|         clear_env(); | ||||
|         return; | ||||
|     } | ||||
|     clear_env(); | ||||
| } | ||||
|  | ||||
| void call_action_script(const char *arg) { | ||||
|     pid_t pid = fork(); | ||||
|     if (pid == -1) { | ||||
|         printf("Unable to fork action script"); | ||||
|         return; | ||||
|     } | ||||
|     if (pid > 0) { | ||||
|         int status; | ||||
|         waitpid(pid, &status, 0); | ||||
|     } else if (execl(action_script, action_script, arg, (char *)NULL) == -1) { | ||||
|         perror("Could not execv"); | ||||
|         exit(1); | ||||
|     } | ||||
| } | ||||
|  | ||||
| static void led_timeout_cb(struct uloop_timeout *t) { | ||||
|     printf("led timeout\n"); | ||||
|     call_action_script("finished"); | ||||
| } | ||||
|  | ||||
| static void led_finished() { | ||||
|     // Stop the blink. | ||||
|     printf("Stopping led blink\n"); | ||||
|     uloop_timeout_cancel(&led_timeout); | ||||
|     call_action_script("finished"); | ||||
| } | ||||
|  | ||||
| static void led_failed_cb(struct uloop_timeout *t) { | ||||
|     // Start the fail blink with a short timeout. | ||||
|     printf("Starting led fail blink\n"); | ||||
|     uloop_timeout_set(&led_timeout, 5000); | ||||
|     call_action_script("failed"); | ||||
| } | ||||
|  | ||||
| static void led_failed() { | ||||
|     // Issue the failed command after a small delay. This is because | ||||
|     // wpa_supplicant emits back to back failed and started events when a | ||||
|     // dpp_push_button occurs while another is still running, so save some time | ||||
|     // for led_started to cancel the failed_timeout. | ||||
|     uloop_timeout_set(&failed_timeout, 1000); | ||||
| } | ||||
|  | ||||
| static void led_started() { | ||||
|     // Start the blink. Set a long timeout for the blink in case we don't see hostapd PB_RESULT event. | ||||
|     printf("Starting led blink\n"); | ||||
|     uloop_timeout_cancel(&failed_timeout); | ||||
|     uloop_timeout_set(&led_timeout, 120000); | ||||
|     call_action_script("started"); | ||||
| } | ||||
|  | ||||
| static void message_process(char *const message) { | ||||
|     const int good_events_count = sizeof(interresting_events) / sizeof(struct event); | ||||
|  | ||||
|     for (int i = 0; i < good_events_count; i++) { | ||||
|         char *ptr = strstr(message, interresting_events[i].event_title); | ||||
|         if (ptr) { | ||||
|             const char *const value = ptr + strlen(interresting_events[i].event_title) + | ||||
|                                       1; // 1 for the space between title and value | ||||
|             switch (interresting_events[i].event_type) { | ||||
|             case TYPE_CONF_RECEIVED: | ||||
|                 clear_cached_confs(); | ||||
|                 break; | ||||
|             case TYPE_ENCRYPTION: | ||||
|                 cache_received_confs(&cached_confs.encryption, value); | ||||
|                 break; | ||||
|             case TYPE_SSID: | ||||
|                 cache_received_confs(&cached_confs.ssid, value); | ||||
|                 break; | ||||
|             case TYPE_PSK: | ||||
|                 cache_received_confs(&cached_confs.psk, value); | ||||
|                 break; | ||||
|             case TYPE_PB_RESULT: | ||||
|                 // AP side we wont have confs, so apply_cached_confs does nothing. | ||||
|                 if (strstr(value, "success")) { | ||||
|                     led_finished(); | ||||
|                     apply_cached_confs(); | ||||
|                     clear_cached_confs(); | ||||
|                 } else if (strstr(value, "failed")) { | ||||
|                     led_failed(); | ||||
|                 } | ||||
|                 break; | ||||
|             case TYPE_PB_STATUS: | ||||
|                 if (strcmp(value, "started") == 0) { | ||||
|                     led_started(); | ||||
|                 } | ||||
|                 break; | ||||
|             case TYPE_CTRL_EVENT_TERMINATING: | ||||
|                 printf("Connection to wpa_supplicant lost - exiting\n"); | ||||
|                 uloop_end(); | ||||
|                 break; | ||||
|             default: | ||||
|                 break; | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| static void listener_cb(struct uloop_fd *fd, unsigned int events) { | ||||
|     while (wpa_ctrl_pending(ctrl_conn) > 0) { | ||||
|         char buf[4096]; | ||||
|         size_t len = sizeof(buf) - 1; | ||||
|         if (wpa_ctrl_recv(ctrl_conn, buf, &len) == 0) { | ||||
|             buf[len] = '\0'; | ||||
|             printf("New Message:%s\n", buf); | ||||
|             message_process(buf); | ||||
|         } else { | ||||
|             printf("Could not read pending message.\n"); | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
|     if (wpa_ctrl_pending(ctrl_conn) < 0) { | ||||
|         printf("Connection to wpa_supplicant lost - exiting\n"); | ||||
|         uloop_end(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| static char *wpa_cli_get_default_ifname(void) { | ||||
|     char *ifname = NULL; | ||||
|  | ||||
|     struct dirent *dent; | ||||
|     DIR *dir = opendir(ctrl_iface_dir); | ||||
|     if (!dir) { | ||||
|         return NULL; | ||||
|     } | ||||
|     while ((dent = readdir(dir))) { | ||||
| #ifdef _DIRENT_HAVE_D_TYPE | ||||
|         /* | ||||
|          * Skip the file if it is not a socket. Also accept | ||||
|          * DT_UNKNOWN (0) in case the C library or underlying | ||||
|          * file system does not support d_type. | ||||
|          */ | ||||
|         if (dent->d_type != DT_SOCK && dent->d_type != DT_UNKNOWN) | ||||
|             continue; | ||||
| #endif /* _DIRENT_HAVE_D_TYPE */ | ||||
|         /* Skip current/previous directory and special P2P Device | ||||
|          * interfaces. */ | ||||
|         if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0 || | ||||
|             strncmp(dent->d_name, "p2p-dev-", 8) == 0) | ||||
|             continue; | ||||
|         printf("Selected interface '%s'\n", dent->d_name); | ||||
|         ifname = strdup(dent->d_name); | ||||
|         break; | ||||
|     } | ||||
|     closedir(dir); | ||||
|  | ||||
|     return ifname; | ||||
| } | ||||
|  | ||||
| static void usage(void) { | ||||
|     printf("wpa_event_listener  [-p<path to ctrl socket dir>] -i<ifname> [-hvBN] " | ||||
|            "-a<action file> \\\n" | ||||
|            "                    [-P<pid file>] " | ||||
|            "\\\n" | ||||
|            "        " | ||||
|            "  -h = help (show this usage text)\n" | ||||
|            "  -v = shown version information\n" | ||||
|            "  -N = No Exit: don't exit after the configs are received.\n" | ||||
|            "  -a = run in daemon mode executing the action file based on " | ||||
|            "events from\n" | ||||
|            "  -B = run a daemon in the background\n" | ||||
|            "  default path: " CONFIG_CTRL_IFACE_DIR "\n" | ||||
|            "  default interface: first interface found in socket path\n"); | ||||
| } | ||||
|  | ||||
| int main(int argc, char *argv[]) { | ||||
|     int c; | ||||
|     int daemonize = 0; | ||||
|     for (;;) { | ||||
|         c = getopt(argc, argv, "a:Bg:G:hNi:p:P:rs:v"); | ||||
|         if (c < 0) | ||||
|             break; | ||||
|         switch (c) { | ||||
|         case 'a': | ||||
|             action_script = optarg; | ||||
|             break; | ||||
|         case 'B': | ||||
|             daemonize = 1; | ||||
|             break; | ||||
|         case 'h': | ||||
|             usage(); | ||||
|             return 0; | ||||
|         case 'v': | ||||
|             printf("%s\n", wpa_el_version); | ||||
|             return 0; | ||||
|         case 'i': | ||||
|             ctrl_ifname = strdup(optarg); | ||||
|             break; | ||||
|         case 'p': | ||||
|             ctrl_iface_dir = optarg; | ||||
|             break; | ||||
|         case 'P': | ||||
|             pid_file = optarg; | ||||
|             break; | ||||
|         case 'N': | ||||
|             printf("No exit after receive config.\n"); | ||||
|             exit_on_config_receive = 0; | ||||
|             break; | ||||
|         default: | ||||
|             usage(); | ||||
|             return -1; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     if (ctrl_ifname == NULL) | ||||
|         ctrl_ifname = wpa_cli_get_default_ifname(); | ||||
|     if (ctrl_ifname == NULL) { | ||||
|         printf("No WPA supplicant ctrl interface found.\n"); | ||||
|         return -1; | ||||
|     } | ||||
|  | ||||
|     if (daemonize) { | ||||
|         if (!action_script) { | ||||
|             printf("Daemonizing requires an action script.\n"); | ||||
|             return -1; | ||||
|         } | ||||
|  | ||||
|         if (daemon(0, 0)) { | ||||
|             perror("daemon"); | ||||
|             return -1; | ||||
|         } | ||||
|         if (pid_file) { | ||||
|             FILE *f = fopen(pid_file, "w"); | ||||
|             if (f) { | ||||
|                 fprintf(f, "%u\n", getpid()); | ||||
|                 fclose(f); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     char *path = malloc(strlen(ctrl_iface_dir) + strlen(ctrl_ifname) + 2); | ||||
|     sprintf(path, "%s/%s", ctrl_iface_dir, ctrl_ifname); | ||||
|  | ||||
|     if (!(ctrl_conn = wpa_ctrl_open(path))) { | ||||
|         printf("unable to open control interface on %s.\n", path); | ||||
|         return -1; | ||||
|     } | ||||
|  | ||||
|     uloop_init(); | ||||
|  | ||||
|     if (wpa_ctrl_attach(ctrl_conn) == 0) { | ||||
|         listener.cb = listener_cb; | ||||
|         listener.fd = wpa_ctrl_get_fd(ctrl_conn); | ||||
|         uloop_fd_add(&listener, ULOOP_READ); | ||||
|         listener_cb(NULL, 0); | ||||
|     } else { | ||||
|         printf("Failed to attach to wpa_supplicant.\n"); | ||||
|         wpa_ctrl_close(ctrl_conn); | ||||
|         return -1; | ||||
|     } | ||||
|  | ||||
|     uloop_run(); | ||||
|     printf("Exiting\n"); | ||||
|     if (pid_file) | ||||
|         remove(pid_file); | ||||
|  | ||||
|     return 0; | ||||
| } | ||||
							
								
								
									
										13
									
								
								feeds/morse/utils/wpa_supplicant_s1g/Config.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								feeds/morse/utils/wpa_supplicant_s1g/Config.in
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| if PACKAGE_wpa_supplicant_s1g | ||||
|  | ||||
| 	config MORSE_WPA_SUPPLICANT_S1G_MESH_NETWORKING | ||||
| 		bool | ||||
| 		default n | ||||
| 		prompt "Enable mesh networking support" | ||||
|  | ||||
| 	config MORSE_WPA_SUPPLICANT_S1G_EAP | ||||
| 		bool | ||||
| 		default n | ||||
| 		prompt "Enable Extensible Authentication Protocol (EAP) support" | ||||
|  | ||||
| endif | ||||
							
								
								
									
										178
									
								
								feeds/morse/utils/wpa_supplicant_s1g/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										178
									
								
								feeds/morse/utils/wpa_supplicant_s1g/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,178 @@ | ||||
| # | ||||
| # Copyright 2022 Morse Micro | ||||
| # | ||||
| # This is free software, licensed under the 3-Clause BSD License. | ||||
| # See /LICENSE for more information. | ||||
| # | ||||
|  | ||||
| include $(TOPDIR)/rules.mk | ||||
|  | ||||
| PKG_NAME:=wpa_supplicant_s1g | ||||
| PKG_RELEASE=2 | ||||
|  | ||||
| PKG_VERSION:=1.12.4 | ||||
|  | ||||
| PKG_LICENSE:=BSD-3-Clause | ||||
|  | ||||
| PKG_SOURCE_VERSION:=$(PKG_VERSION) | ||||
| PKG_SOURCE_URL:=https://github.com/MorseMicro/hostap.git | ||||
| PKG_HASH:=c342d1489d03363b79b5b4e185ccbceca53aab9e634daefb81180ad1012b77b7 | ||||
| PKG_SOURCE_PROTO:=git | ||||
|  | ||||
| PKG_MAINTAINER:=Morse Micro <info@morsemicro.com> | ||||
| PKG_BUILD_PARALLEL:=1 | ||||
|  | ||||
| include $(INCLUDE_DIR)/package.mk | ||||
|  | ||||
| MAKE_FLAGS += \ | ||||
| 	MORSEWPA_SUPPLICANT_VERSION_STRING=$(PKG_VERSION) | ||||
|  | ||||
| # Add support for simple background scan | ||||
| MMWPA_SUPPLICANT_CONFIG_SET = \ | ||||
| 	CONFIG_UBUS | ||||
|  | ||||
|  | ||||
| MMWPA_SUPPLICANT_CONFIG_ENABLE = \ | ||||
| 	CONFIG_IEEE80211AC \ | ||||
| 	CONFIG_IEEE80211N \ | ||||
| 	CONFIG_IEEE80211R \ | ||||
| 	CONFIG_INTERNAL_LIBTOMMATH \ | ||||
| 	CONFIG_DEBUG_FILE \ | ||||
| 	CONFIG_MATCH_IFACE \ | ||||
| 	CONFIG_LIBNL32 \ | ||||
| 	CONFIG_DRIVER_WEXT \ | ||||
| 	CONFIG_DRIVER_NL80211 \ | ||||
| 	CONFIG_DRIVER_WIRED \ | ||||
| 	CONFIG_IEEE8021X_EAPOL \ | ||||
| 	CONFIG_WPS \ | ||||
| 	CONFIG_PKCS12 \ | ||||
| 	CONFIG_CTRL_IFACE \ | ||||
| 	CONFIG_READLINE \ | ||||
| 	CONFIG_IEEE80211W \ | ||||
| 	CONFIG_INTERNAL_LIBTOMMATH_FAST \ | ||||
| 	CONFIG_CTRL_IFACE_DBUS_INTRO \ | ||||
| 	CONFIG_DEBUG_SYSLOG \ | ||||
| 	CONFIG_INTERWORKING \ | ||||
| 	CONFIG_HS20 \ | ||||
| 	CONFIG_MATCH_IFACE \ | ||||
| 	CONFIG_AP \ | ||||
| 	CONFIG_P2P \ | ||||
| 	CONFIG_IBSS_RSN \ | ||||
| 	CONFIG_OWE \ | ||||
| 	CONFIG_DPP \ | ||||
| 	CONFIG_SAE \ | ||||
| 	CONFIG_TESTING_OPTIONS \ | ||||
| 	CONFIG_PMKSA_CACHE_EXTERNAL \ | ||||
| 	CONFIG_WNM | ||||
|  | ||||
| MMWPA_SUPPLICANT_CONFIG_DISABLE = \ | ||||
| 	CONFIG_BGSCAN_SIMPLE \ | ||||
| 	CONFIG_SMARTCARD \ | ||||
| 	CONFIG_CTRL_IFACE_DBUS_NEW \ | ||||
| 	CONFIG_CTRL_IFACE_DBUS_INTRO \ | ||||
| 	CONFIG_READLINE | ||||
|  | ||||
| MMWPA_SUPPLICANT_CONFIG_EDITS += 's/\#\(CONFIG_TLS=openssl\)/\1/' | ||||
|  | ||||
| ifeq ($(CONFIG_MORSE_WPA_SUPPLICANT_S1G_MESH_NETWORKING),y) | ||||
| 	MMWPA_SUPPLICANT_CONFIG_ENABLE += CONFIG_MESH | ||||
| endif | ||||
|  | ||||
| ifeq ($(CONFIG_MORSE_WPA_SUPPLICANT_S1G_EAP),y) | ||||
| 	MMWPA_SUPPLICANT_CONFIG_ENABLE += \ | ||||
| 		CONFIG_EAP_PEAP \ | ||||
| 		CONFIG_EAP_MD5 \ | ||||
| 		CONFIG_EAP_MSCHAPV2 \ | ||||
| 		CONFIG_EAP_TLS \ | ||||
| 		CONFIG_EAP_TTLS \ | ||||
| 		CONFIG_EAP_GTC \ | ||||
| 		CONFIG_EAP_PWD | ||||
| endif | ||||
|  | ||||
| define Package/wpa_supplicant_s1g | ||||
|   SECTION:=net | ||||
|   CATEGORY:=Network | ||||
|   SUBMENU:=WirelessAPD | ||||
|   TITLE:=Morse Micro HaLow wpa_supplicant | ||||
|   DEPENDS:= +kmod-morse +libnl +libopenssl +libubus | ||||
|   USERID:=network=101:network=101 | ||||
|   PROVIDES:=wpa_supplicant_s1g | ||||
| endef | ||||
|  | ||||
| define Package/libwpa_client | ||||
|   SECTION:=net | ||||
|   CATEGORY:=Network | ||||
|   SUBMENU:=WirelessAPD | ||||
|   TITLE:=libwpa_client | ||||
|   DEPENDS:=wpa_supplicant_s1g | ||||
| endef | ||||
|  | ||||
| define Package/libwpa_client/description | ||||
|   wpa_supplicant_s1g client liberary | ||||
| endef | ||||
|  | ||||
| define Package/wpa_supplicant_s1g/config | ||||
|     source "$(SOURCE)/Config.in" | ||||
| endef | ||||
|  | ||||
| MMWPA_SUPPLICANT_CONFIG = $(PKG_BUILD_DIR)/wpa_supplicant/.config | ||||
|  | ||||
| define Build/Prepare | ||||
| 	$(call Build/Prepare/Default) | ||||
| 	$(CP) $(PKG_BUILD_DIR)/wpa_supplicant/defconfig $(MMWPA_SUPPLICANT_CONFIG) | ||||
| 	sed -i $(patsubst %,-e 's/^#\(%\)/\1/',$(MMWPA_SUPPLICANT_CONFIG_ENABLE)) \ | ||||
| 		$(patsubst %,-e 's/^\(%\)/#\1/',$(MMWPA_SUPPLICANT_CONFIG_DISABLE)) \ | ||||
| 		$(patsubst %,-e '1i%=y',$(MMWPA_SUPPLICANT_CONFIG_SET)) \ | ||||
| 		$(patsubst %,-e %,$(MMWPA_SUPPLICANT_CONFIG_EDITS)) \ | ||||
| 		$(MMWPA_SUPPLICANT_CONFIG) | ||||
| endef | ||||
|  | ||||
| TARGET_CPPFLAGS := \ | ||||
| 	-I$(STAGING_DIR)/usr/include/libnl3 \ | ||||
| 	-I$(PKG_BUILD_DIR)/src/crypto \ | ||||
| 	$(TARGET_CPPFLAGS) \ | ||||
| 	-DCONFIG_LIBNL20 \ | ||||
| 	-D_GNU_SOURCE | ||||
|  | ||||
| TARGET_LDFLAGS += -lnl-3 -lnl-genl-3 -lnl-route-3 | ||||
| TARGET_LDFLAGS += -lm -lpthread -lcrypto -lssl | ||||
|  | ||||
| define Build/RunMake | ||||
| 	CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \ | ||||
| 	$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(1) \ | ||||
| 		$(TARGET_CONFIGURE_OPTS) \ | ||||
| 		$(DRIVER_MAKEOPTS) \ | ||||
| 		LIBS="$(TARGET_LDFLAGS)" \ | ||||
| 		LIBS_c="$(TARGET_LDFLAGS_C)" \ | ||||
| 		AR="$(TARGET_CROSS)gcc-ar" \ | ||||
| 		BCHECK= \ | ||||
| 		$(2) | ||||
| endef | ||||
|  | ||||
| define Build/Compile | ||||
| 	+$(call Build/RunMake,wpa_supplicant, \ | ||||
| 		wpa_supplicant_s1g wpa_cli_s1g \ | ||||
| 	) | ||||
| 	+$(call Build/RunMake,wpa_supplicant, libwpa_client.so) | ||||
| endef | ||||
|  | ||||
| define Package/wpa_supplicant_s1g/install | ||||
| 	$(INSTALL_DIR) $(1)/sbin | ||||
| 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/wpa_supplicant/wpa_supplicant_s1g $(1)/sbin/ | ||||
| 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/wpa_supplicant/wpa_cli_s1g $(1)/sbin/ | ||||
| endef | ||||
|  | ||||
| define Package/libwpa_client/install | ||||
| 	$(INSTALL_DIR) $(1)/usr/lib/ | ||||
| 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/wpa_supplicant/libwpa_client.so $(1)/usr/lib/ | ||||
| endef | ||||
|  | ||||
| define Build/InstallDev | ||||
| 	$(INSTALL_DIR) $(1)/usr/lib/ | ||||
| 	$(INSTALL_DIR) $(1)/usr/include/ | ||||
| 	$(CP) $(PKG_BUILD_DIR)/wpa_supplicant/libwpa_client.so		$(1)/usr/lib/ | ||||
| 	$(CP) $(PKG_BUILD_DIR)/src/common/wpa_ctrl.h				$(1)/usr/include/wpa_ctrl.h | ||||
| endef | ||||
|  | ||||
| $(eval $(call BuildPackage,wpa_supplicant_s1g)) | ||||
| $(eval $(call BuildPackage,libwpa_client)) | ||||
| @@ -0,0 +1,45 @@ | ||||
| From 5433351ed5ab62c2d4fbd15a2c4d8c4aeacb93dc Mon Sep 17 00:00:00 2001 | ||||
| From: Evan Benn <evan.benn@morsemicro.com> | ||||
| Date: Thu, 29 Feb 2024 11:09:38 +1100 | ||||
| Subject: [PATCH] APP-2573: Emit a DPP PB_STATUS event when push button starts | ||||
|  | ||||
| --- | ||||
|  src/ap/dpp_hostapd.c            | 1 + | ||||
|  wpa_supplicant/dpp_supplicant.c | 2 ++ | ||||
|  2 files changed, 3 insertions(+) | ||||
|  | ||||
| diff --git a/src/ap/dpp_hostapd.c b/src/ap/dpp_hostapd.c | ||||
| index b7cca47c714b..3025eef204d2 100644 | ||||
| --- a/src/ap/dpp_hostapd.c | ||||
| +++ b/src/ap/dpp_hostapd.c | ||||
| @@ -3960,6 +3960,7 @@ int hostapd_dpp_push_button(struct hostapd_data *hapd, const char *cmd) | ||||
|  	eloop_register_timeout(100, 0, hostapd_dpp_push_button_expire, | ||||
|  			       hapd, NULL); | ||||
|   | ||||
| +	wpa_msg(hapd->msg_ctx, MSG_INFO, DPP_EVENT_PB_STATUS "started"); | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c | ||||
| index ab06ff8d32c1..24e4bb3c444d 100644 | ||||
| --- a/wpa_supplicant/dpp_supplicant.c | ||||
| +++ b/wpa_supplicant/dpp_supplicant.c | ||||
| @@ -5676,6 +5676,7 @@ static int wpas_dpp_push_button_configurator(struct wpa_supplicant *wpa_s, | ||||
|  	eloop_register_timeout(100, 0, wpas_dpp_push_button_expire, | ||||
|  			       wpa_s, NULL); | ||||
|   | ||||
| +	wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_PB_STATUS "started"); | ||||
|  	return 0; | ||||
|  } | ||||
|   | ||||
| @@ -5749,6 +5750,7 @@ int wpas_dpp_push_button(struct wpa_supplicant *wpa_s, const char *cmd) | ||||
|  	wpa_supplicant_req_scan(wpa_s, 0, 0); | ||||
|   | ||||
|  	res = 0; | ||||
| +	wpa_msg(wpa_s, MSG_INFO, DPP_EVENT_PB_STATUS "started"); | ||||
|  out: | ||||
|   | ||||
|  	/* If push button mode failed to start, restart the chirp forever timer */ | ||||
| --  | ||||
| 2.42.0.530.g692be87cbba5 | ||||
|  | ||||
| @@ -0,0 +1,90 @@ | ||||
| From 25631fa387af430b8d7f03302218c66dc161cc6f Mon Sep 17 00:00:00 2001 | ||||
| From: Andrew Pope <andrew.pope@morsemicro.com> | ||||
| Date: Tue, 4 Jun 2024 23:12:37 +0000 | ||||
| Subject: [PATCH] Merged in SW-11943-dpp-does-not-associate-in-us-regdom (pull | ||||
|  request #213) | ||||
|  | ||||
| SW-11943: DPP does not associate in US regdom | ||||
|  | ||||
| Two problems contributed to the originally reported issue: | ||||
|  | ||||
| 1. The DPP-PB state machine function will unconditionally cancel any pending off-channel actions - even if the DPP PB discovery phase is over. To fix this, avoid unconditionally completing offchannel actions from DPP-PB state machine function if DPP PB discovery phase is over. | ||||
|  | ||||
| 2. Logic around PKEX retries will manually attempt to complete the exchange on adjacent non-S1G channels. These retries inevitably fail, leading to a quicker collapse of the PKEX exchange attempts and eventual downgrade from v2 to v1 (bad). To fix this, remove non-S1G frequency hopping logic from DPP PB discovery and PKEX exchange phases. | ||||
|  | ||||
| Approved-by: Neville Young | ||||
| Approved-by: Simon Wadsworth | ||||
| Approved-by: Ayman Grais | ||||
| Approved-by: James Herbert | ||||
| --- | ||||
|  src/ap/dpp_hostapd.c            |  6 ++++++ | ||||
|  wpa_supplicant/dpp_supplicant.c | 17 +++++++++++++++-- | ||||
|  2 files changed, 21 insertions(+), 2 deletions(-) | ||||
|  | ||||
| diff --git a/src/ap/dpp_hostapd.c b/src/ap/dpp_hostapd.c | ||||
| index b7cca47c7..282581fe5 100644 | ||||
| --- a/src/ap/dpp_hostapd.c | ||||
| +++ b/src/ap/dpp_hostapd.c | ||||
| @@ -260,6 +260,12 @@ static int hostapd_dpp_allow_ir(struct hostapd_data *hapd, unsigned int freq) | ||||
|  static int hostapd_dpp_pkex_next_channel(struct hostapd_data *hapd, | ||||
|  					 struct dpp_pkex *pkex) | ||||
|  { | ||||
| +	/* Following logic is not S1G compatible. Attempting PKEX on non-adjacent S1G channels | ||||
| +	 * results in guaranteed failure. | ||||
| +	 */ | ||||
| +	if (hapd->iconf->ieee80211ah) | ||||
| +		return -1; | ||||
| + | ||||
|  	if (pkex->freq == 2437) | ||||
|  		pkex->freq = 5745; | ||||
|  	else if (pkex->freq == 5745) | ||||
| diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c | ||||
| index ab06ff8d3..e90e4a163 100644 | ||||
| --- a/wpa_supplicant/dpp_supplicant.c | ||||
| +++ b/wpa_supplicant/dpp_supplicant.c | ||||
| @@ -2840,6 +2840,12 @@ static int wpas_dpp_allow_ir(struct wpa_supplicant *wpa_s, unsigned int freq) | ||||
|  static int wpas_dpp_pkex_next_channel(struct wpa_supplicant *wpa_s, | ||||
|  				      struct dpp_pkex *pkex) | ||||
|  { | ||||
| +#if defined(CONFIG_IEEE80211AH) | ||||
| +	/* Following logic is not S1G compatible. Attempting PKEX on non-adjacent S1G channels | ||||
| +	 * results in guaranteed failure. | ||||
| +	 */ | ||||
| +	return -1; | ||||
| +#endif | ||||
|  	if (pkex->freq == 2437) | ||||
|  		pkex->freq = 5745; | ||||
|  	else if (pkex->freq == 5745) | ||||
| @@ -5113,10 +5119,16 @@ static int * wpas_dpp_presence_ann_channels(struct wpa_supplicant *wpa_s, | ||||
|   | ||||
|  			if (chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_RADAR)) | ||||
|  				continue; | ||||
| +#if defined(CONFIG_IEEE80211AH) | ||||
| +			/* Adding channels 44 and 149 at end of scan list is not required | ||||
| +			 * for HaLow | ||||
| +			 */ | ||||
| +#else | ||||
|  			if (chan->freq == 5220) | ||||
|  				chan44 = 1; | ||||
|  			if (chan->freq == 5745) | ||||
|  				chan149 = 1; | ||||
| +#endif | ||||
|   | ||||
|  			/* Morse - All 5GHz channels that are mapped to 1 MHz and 2 MHz. | ||||
|  			 * Channels that aren't relevant to a regulatory domain will be | ||||
| @@ -5573,9 +5585,10 @@ static void wpas_dpp_pb_next(void *eloop_ctx, void *timeout_ctx) | ||||
|  	if (!wpa_s->dpp_pb_freqs) | ||||
|  		return; | ||||
|   | ||||
| -	os_get_reltime(&now); | ||||
| -	offchannel_send_action_done(wpa_s); | ||||
| +	if (!wpa_s->dpp_pb_discovery_done) | ||||
| +		offchannel_send_action_done(wpa_s); | ||||
|   | ||||
| +	os_get_reltime(&now); | ||||
|  	if (os_reltime_expired(&now, &wpa_s->dpp_pb_time, 100)) { | ||||
|  		wpa_printf(MSG_DEBUG, "DPP: Push button wait time expired"); | ||||
|  		wpas_dpp_push_button_stop(wpa_s); | ||||
| --  | ||||
| 2.25.1 | ||||
|  | ||||
| @@ -0,0 +1,35 @@ | ||||
| From 591ec24748525171d5647d2a35cd1da1445e7a0b Mon Sep 17 00:00:00 2001 | ||||
| From: James Haggerty <james.haggerty@morsemicro.com> | ||||
| Date: Fri, 26 Jul 2024 09:55:03 +1000 | ||||
| Subject: [PATCH] Hack out channel 50 (and typo for 51) | ||||
|  | ||||
| If we use these channels on a board with those channels disabled, | ||||
| the DPP presence announcement fails. | ||||
|  | ||||
| This is rubbish: see SW-12450 | ||||
| --- | ||||
|  wpa_supplicant/dpp_supplicant.c | 4 ++-- | ||||
|  1 file changed, 2 insertions(+), 2 deletions(-) | ||||
|  | ||||
| diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c | ||||
| index 09f8ceb07..46e4add95 100644 | ||||
| --- a/wpa_supplicant/dpp_supplicant.c | ||||
| +++ b/wpa_supplicant/dpp_supplicant.c | ||||
| @@ -5199,12 +5199,12 @@ static int * wpas_dpp_presence_ann_channels(struct wpa_supplicant *wpa_s, | ||||
|  			static const int s1g_chirp_channels[] = { | ||||
|  				/* 2MHz channels */ | ||||
|  				5190, 5230, 5270, 5310, 5510, 5550, | ||||
| -				5630, 5670, 5755, 5795, 5835, 5875, | ||||
| +				5630, 5670, 5755, 5795, 5835, | ||||
|  				/* 1MHz channels */ | ||||
|  				5660, 5680, 5180, 5200, 5240, 5260, | ||||
|  				5280, 5300, 5320, 5500, 5520, 5540, | ||||
|  				5560, 5580, 5600, 5620, 5640, 5765, | ||||
| -				5785, 5805, 5825, 5845, 5865, 5855 | ||||
| +				5785, 5805, 5825, 5845, 5865 | ||||
|  			}; | ||||
|   | ||||
|  			if (chan->flag & (HOSTAPD_CHAN_DISABLED | HOSTAPD_CHAN_RADAR)) | ||||
| --  | ||||
| 2.25.1 | ||||
|  | ||||
| @@ -48,6 +48,16 @@ $(call Package/ath12k-wifi-default) | ||||
|     TITLE:=board-2.bin for RAP7710c_341x | ||||
| endef | ||||
|  | ||||
| define Package/ath12k-wifi-sonicfi-rap750e-h | ||||
| $(call Package/ath12k-wifi-default) | ||||
|     TITLE:=board-2.bin for RAP750e_h | ||||
| endef | ||||
|  | ||||
| define Package/ath12k-wifi-sonicfi-rap750e-s | ||||
| $(call Package/ath12k-wifi-default) | ||||
|     TITLE:=board-2.bin for RAP750E-S | ||||
| endef | ||||
|  | ||||
| define Package/ath12k-wifi-sonicfi-rap750w-311a | ||||
| $(call Package/ath12k-wifi-default) | ||||
|     TITLE:=board-2.bin for RAP750W_311a | ||||
| @@ -73,6 +83,15 @@ $(call Package/ath12k-wifi-default) | ||||
|     TITLE:=board-2.bin for AP72TIP-v4 | ||||
| endef | ||||
|  | ||||
| define Package/ath12k-wifi-zyxel-nwa130be | ||||
| $(call Package/ath12k-wifi-default) | ||||
|     TITLE:=board-2.bin for NWA130BE | ||||
| endef | ||||
|  | ||||
| define Package/ath12k-wifi-cig-wf672 | ||||
| $(call Package/ath12k-wifi-default) | ||||
|     TITLE:=board-2.bin for WF672 | ||||
| endef | ||||
|  | ||||
| define Package/ath12k-wifi-cig-wf189/install | ||||
| 	$(INSTALL_DIR) $(1)/lib/firmware/ath12k/QCN92XX/hw1.0/ | ||||
| @@ -95,6 +114,24 @@ define Package/ath12k-wifi-sonicfi-rap7110c-341x/install | ||||
| 	$(INSTALL_DATA) ./board-2.bin.rap7110c_341x.IPQ5332 $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/board-2.bin | ||||
| endef | ||||
|  | ||||
| define Package/ath12k-wifi-sonicfi-rap750e-h/install | ||||
| 	$(INSTALL_DIR) $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/ | ||||
| 	$(INSTALL_DIR) $(1)/lib/firmware/ath12k/QCN6432/hw1.0/ | ||||
| 	$(INSTALL_DATA) ./board-2.bin.rap750e_h.IPQ5332 $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/board-2.bin | ||||
| 	$(INSTALL_DATA) ./board-2.bin.rap750e_h.QCN6432 $(1)/lib/firmware/ath12k/QCN6432/hw1.0/board-2.bin | ||||
| #	$(INSTALL_DATA) ./ipq5332_qcn6432.regdb $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/regdb.bin | ||||
| 	$(INSTALL_DATA) ./ipq5332_qcn6432.regdb $(1)/lib/firmware/ath12k/QCN6432/hw1.0/regdb.bin | ||||
| endef | ||||
|  | ||||
| define Package/ath12k-wifi-sonicfi-rap750e-s/install | ||||
| 	$(INSTALL_DIR) $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/ | ||||
| 	$(INSTALL_DIR) $(1)/lib/firmware/ath12k/QCN6432/hw1.0/ | ||||
| 	$(INSTALL_DATA) ./board-2.bin.rap750e_s.IPQ5332 $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/board-2.bin | ||||
| 	$(INSTALL_DATA) ./board-2.bin.rap750e_s.QCN6432 $(1)/lib/firmware/ath12k/QCN6432/hw1.0/board-2.bin | ||||
| #	$(INSTALL_DATA) ./ipq5332_qcn6432.regdb $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/regdb.bin | ||||
| 	$(INSTALL_DATA) ./ipq5332_qcn6432.regdb $(1)/lib/firmware/ath12k/QCN6432/hw1.0/regdb.bin | ||||
| endef | ||||
|  | ||||
| define Package/ath12k-wifi-sonicfi-rap750w-311a/install | ||||
| 	$(INSTALL_DIR) $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/ | ||||
| 	$(INSTALL_DIR) $(1)/lib/firmware/ath12k/QCN6432/hw1.0/ | ||||
| @@ -135,11 +172,29 @@ define Package/ath12k-wifi-sercomm-ap72tip-v4/install | ||||
| 	$(INSTALL_DATA) ./board-2.bin.ap72tip-v4.IPQ5332 $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/board-2.bin | ||||
| endef | ||||
|  | ||||
| define Package/ath12k-wifi-zyxel-nwa130be/install | ||||
| 	$(INSTALL_DIR) $(1)/lib/firmware/ath12k/QCN92XX/hw1.0/ | ||||
| 	$(INSTALL_DIR) $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/ | ||||
| 	$(INSTALL_DATA) ./board-2.bin.nwa130be.QCN92XX $(1)/lib/firmware/ath12k/QCN92XX/hw1.0/board-2.bin | ||||
| 	$(INSTALL_DATA) ./board-2.bin.nwa130be.IPQ5332 $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/board-2.bin | ||||
| endef | ||||
|  | ||||
| define Package/ath12k-wifi-cig-wf672/install | ||||
| 	$(INSTALL_DIR) $(1)/lib/firmware/ath12k/QCN92XX/hw1.0/ | ||||
| 	$(INSTALL_DIR) $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/ | ||||
| 	$(INSTALL_DATA) ./board-2.bin.wf672.QCN92XX $(1)/lib/firmware/ath12k/QCN92XX/hw1.0/board-2.bin | ||||
| 	$(INSTALL_DATA) ./board-2.bin.wf672.IPQ5332 $(1)/lib/firmware/ath12k/IPQ5332/hw1.0/board-2.bin | ||||
| endef | ||||
|  | ||||
| $(eval $(call BuildPackage,ath12k-wifi-cig-wf189)) | ||||
| $(eval $(call BuildPackage,ath12k-wifi-edgecore-eap105)) | ||||
| $(eval $(call BuildPackage,ath12k-wifi-sonicfi-rap7110c-341x)) | ||||
| $(eval $(call BuildPackage,ath12k-wifi-sonicfi-rap750e-h)) | ||||
| $(eval $(call BuildPackage,ath12k-wifi-sonicfi-rap750e-s)) | ||||
| $(eval $(call BuildPackage,ath12k-wifi-sonicfi-rap750w-311a)) | ||||
| $(eval $(call BuildPackage,ath12k-wifi-cig-wf189w)) | ||||
| $(eval $(call BuildPackage,ath12k-wifi-cig-wf189h)) | ||||
| $(eval $(call BuildPackage,ath12k-wifi-sercomm-ap72tip)) | ||||
| $(eval $(call BuildPackage,ath12k-wifi-sercomm-ap72tip-v4)) | ||||
| $(eval $(call BuildPackage,ath12k-wifi-zyxel-nwa130be)) | ||||
| $(eval $(call BuildPackage,ath12k-wifi-cig-wf672)) | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.nwa130be.IPQ5332
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.nwa130be.IPQ5332
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.nwa130be.QCN92XX
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.nwa130be.QCN92XX
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.rap750e_h.IPQ5332
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.rap750e_h.IPQ5332
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.rap750e_h.QCN6432
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.rap750e_h.QCN6432
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.rap750e_s.IPQ5332
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.rap750e_s.IPQ5332
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.rap750e_s.QCN6432
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.rap750e_s.QCN6432
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.wf672.IPQ5332
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.wf672.IPQ5332
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.wf672.QCN92XX
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								feeds/qca-wifi-7/ath12k-wifi/board-2.bin.wf672.QCN92XX
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										30
									
								
								feeds/qca-wifi-7/cig-wifi-mode-sw/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								feeds/qca-wifi-7/cig-wifi-mode-sw/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| include $(TOPDIR)/rules.mk | ||||
| include $(INCLUDE_DIR)/kernel.mk | ||||
|  | ||||
| PKG_NAME:=cig-wifi-mode-switch | ||||
| PKG_RELEASE:=1 | ||||
| PKG_LICENSE:=GPL-2.0 | ||||
|  | ||||
| include $(INCLUDE_DIR)/package.mk | ||||
|  | ||||
| define KernelPackage/cig-wifi-mode-sw | ||||
|   SUBMENU:=Other modules | ||||
|   TITLE:=CIG wifi mode switch tool | ||||
|   FILES:=$(PKG_BUILD_DIR)/cig_rf_switch.ko | ||||
|   AUTOLOAD:=$(call AutoLoad,60,cig_rf_switch) | ||||
| endef | ||||
|  | ||||
| define KernelPackage/cig-wifi-mode-sw/description | ||||
|   CIG wifi mode switch tool for configure wifi mode 2 bands or 3 bands | ||||
| endef | ||||
|  | ||||
| define Build/Compile | ||||
| 	$(KERNEL_MAKE) M="$(PKG_BUILD_DIR)" modules | ||||
| endef | ||||
|  | ||||
| define KernelPackage/cig-wifi-mode-sw/install | ||||
| 	$(INSTALL_DIR) $(1)/usr/sbin/ | ||||
| 	$(INSTALL_BIN) ./files/cig_wifi_mode_sw $(1)/usr/sbin/cig_wms | ||||
| endef | ||||
|  | ||||
| $(eval $(call KernelPackage,cig-wifi-mode-sw)) | ||||
							
								
								
									
										11
									
								
								feeds/qca-wifi-7/cig-wifi-mode-sw/files/cig_wifi_mode_sw
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										11
									
								
								feeds/qca-wifi-7/cig-wifi-mode-sw/files/cig_wifi_mode_sw
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| band=$1 | ||||
| if [ $band -eq 2 ] || [ $band -eq 3 ]; then | ||||
| 	echo $band > /proc/rf_switch | ||||
| 	echo "reboot for switch wifi mode 2/3 bands" | ||||
| 	sleep 1 | ||||
| 	reboot | ||||
| else | ||||
| 	echo "error band param" | ||||
| fi | ||||
							
								
								
									
										1
									
								
								feeds/qca-wifi-7/cig-wifi-mode-sw/src/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								feeds/qca-wifi-7/cig-wifi-mode-sw/src/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| obj-m += cig_rf_switch.o | ||||
							
								
								
									
										276
									
								
								feeds/qca-wifi-7/cig-wifi-mode-sw/src/cig_rf_switch.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										276
									
								
								feeds/qca-wifi-7/cig-wifi-mode-sw/src/cig_rf_switch.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,276 @@ | ||||
| #include <linux/module.h> | ||||
| #include <linux/kernel.h> | ||||
| #include <linux/proc_fs.h> | ||||
| #include <linux/seq_file.h> | ||||
| #include <linux/mmc/core.h> | ||||
| #include <linux/mmc/host.h> | ||||
| #include <linux/major.h> | ||||
| #include <linux/mmc/mmc.h> | ||||
| #include <linux/mmc/card.h> | ||||
| #include <linux/slab.h> | ||||
| #include <linux/string.h> | ||||
| #include <linux/uaccess.h> | ||||
| #include <linux/list.h> | ||||
| #include <linux/pagemap.h> | ||||
|  | ||||
| #define PROC_NAME "rf_switch" | ||||
| #define PARTITION_NAME "RF_SWITCH" | ||||
| #define MAX_DATA_SIZE 2  | ||||
| #define MAX_MMC_DEVICE 2 | ||||
|  | ||||
| struct block_device *target_bdev = NULL; | ||||
| static char current_value[MAX_DATA_SIZE] = "3";  | ||||
|  | ||||
| static unsigned int __blkdev_sectors_to_bio_pages(sector_t nr_sects) | ||||
| { | ||||
| 	sector_t pages = DIV_ROUND_UP_SECTOR_T(nr_sects, PAGE_SIZE / 512); | ||||
|  | ||||
| 	return min(pages, (sector_t)BIO_MAX_VECS); | ||||
| } | ||||
|  | ||||
| struct block_device *find_mmc_partition(void) | ||||
| { | ||||
| 	struct gendisk *disk = NULL; | ||||
| 	unsigned long idx; | ||||
| 	struct block_device *bdev = NULL; | ||||
| 	unsigned int i; | ||||
| 	 | ||||
| 	for (i = 0; i < MAX_MMC_DEVICE; i++) { | ||||
| 		bdev = blkdev_get_by_dev(MKDEV(MMC_BLOCK_MAJOR, i * CONFIG_MMC_BLOCK_MINORS), FMODE_READ | FMODE_WRITE, NULL); | ||||
| 		if (IS_ERR(bdev)) { | ||||
| 			pr_err("Failed to open MMC device %u: %ld\n", i, PTR_ERR(bdev)); | ||||
| 			continue; | ||||
| 		} | ||||
| 	 | ||||
| 		disk = bdev->bd_disk; | ||||
| 		if (!disk) { | ||||
| 			blkdev_put(bdev, FMODE_READ | FMODE_WRITE); | ||||
| 			continue; | ||||
| 		} | ||||
| 	 | ||||
| 		xa_for_each_start(&disk->part_tbl, idx, bdev, 1) { | ||||
| 			if (bdev->bd_meta_info && strcmp(bdev->bd_meta_info->volname, PARTITION_NAME) == 0) { | ||||
| 				pr_info("Found RF_SWITCH partition at device %u\n", i); | ||||
| 				return bdev; | ||||
| 			} | ||||
| 		} | ||||
| 	 | ||||
| 		blkdev_put(bdev, FMODE_READ | FMODE_WRITE); | ||||
| 	} | ||||
| 	 | ||||
| 	return NULL; | ||||
| } | ||||
|  | ||||
| int read_string_from_emmc(struct block_device *bdev, size_t max_length, char *buffer) | ||||
| { | ||||
| 	struct bio *bio; | ||||
| 	struct page *page; | ||||
| 	int err = 0; | ||||
| 	void *data; | ||||
|  | ||||
| 	page = alloc_page(GFP_KERNEL); | ||||
| 	if (!page) { | ||||
| 		return -ENOMEM; | ||||
| 	} | ||||
|  | ||||
| 	bio = bio_alloc(bdev, __blkdev_sectors_to_bio_pages(1), REQ_OP_READ, GFP_KERNEL); | ||||
| 	bio_set_dev(bio, bdev); | ||||
| 	bio->bi_iter.bi_sector = 0; | ||||
| 	bio_add_page(bio, page, PAGE_SIZE, 0); | ||||
|  | ||||
| 	submit_bio_wait(bio); | ||||
|  | ||||
| 	if (bio->bi_status) { | ||||
| 		err = -EIO; | ||||
| 		goto out_bio; | ||||
| 	} | ||||
|  | ||||
| 	data = kmap(page); | ||||
| 	kunmap(page); | ||||
| 	memcpy(buffer, data, max_length - 1); | ||||
| 	buffer[max_length - 1] = '\0'; | ||||
|  | ||||
| out_bio: | ||||
| 	bio_put(bio); | ||||
| 	__free_page(page); | ||||
|  | ||||
| 	return err; | ||||
| } | ||||
|  | ||||
| static int rf_switch_proc_show(struct seq_file *m, void *v) | ||||
| { | ||||
| 	char buffer[MAX_DATA_SIZE] = {0}; | ||||
| 	int ret; | ||||
| 	 | ||||
| 	ret = read_string_from_emmc(target_bdev, MAX_DATA_SIZE, buffer); | ||||
| 	if (ret) { | ||||
| 		seq_printf(m, "%s\n", current_value); | ||||
| 		return 0; | ||||
| 	} | ||||
| 	 | ||||
| 	if (strcmp(buffer, "2") == 0 || strcmp(buffer, "3") == 0) { | ||||
| 		strncpy(current_value, buffer, MAX_DATA_SIZE); | ||||
| 		seq_printf(m, "%s\n", current_value); | ||||
| 	} else { | ||||
| 		seq_printf(m, "%s\n", current_value); | ||||
| 	} | ||||
| 	 | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static int blkdev_issue_write(struct block_device *bdev, sector_t sector, sector_t nr_sects, gfp_t gfp_mask, struct page *page) | ||||
| { | ||||
| 	int ret = 0; | ||||
| 	sector_t bs_mask; | ||||
| 	struct bio *bio; | ||||
| 	 | ||||
| 	int bi_size = 0; | ||||
| 	unsigned int sz; | ||||
| 	 | ||||
| 	if (bdev_read_only(bdev)) | ||||
| 		return -EPERM; | ||||
| 	 | ||||
| 	bs_mask = (bdev_logical_block_size(bdev) >> 9) - 1; | ||||
| 	if ((sector | nr_sects) & bs_mask) | ||||
| 		return -EINVAL; | ||||
| 	 | ||||
| 	bio = bio_alloc(bdev, __blkdev_sectors_to_bio_pages(nr_sects), | ||||
| 			REQ_OP_WRITE, gfp_mask); | ||||
| 	if (!bio) { | ||||
| 		pr_err("Couldn't alloc bio"); | ||||
| 		return -1; | ||||
| 	} | ||||
| 	 | ||||
| 	bio->bi_iter.bi_sector = sector; | ||||
| 	bio_set_dev(bio, bdev); | ||||
| 	bio_set_op_attrs(bio, REQ_OP_WRITE, 0); | ||||
| 	 | ||||
| 	sz = bdev_logical_block_size(bdev); | ||||
| 	bi_size = bio_add_page(bio, page, sz, 0); | ||||
| 	 | ||||
| 	if(bi_size != sz) { | ||||
| 		pr_err("Couldn't add page to the log block"); | ||||
| 		goto error; | ||||
| 	} | ||||
| 	if (bio) | ||||
| 	{ | ||||
| 		ret = submit_bio_wait(bio); | ||||
| 		bio_put(bio); | ||||
| 	} | ||||
| 	 | ||||
| 	return ret; | ||||
| error: | ||||
| 	bio_put(bio); | ||||
| 	return -1; | ||||
| } | ||||
|  | ||||
| static int write_data_to_emmc(struct block_device *bdev, const unsigned char *data, unsigned char fill_byte) | ||||
| { | ||||
| 	struct page *page; | ||||
| 	void *ptr; | ||||
| 	sector_t sector_offset = 0; | ||||
| 	int ret = 0; | ||||
| 	 | ||||
| 	if (!bdev || !data) | ||||
| 		return -EINVAL; | ||||
| 	 | ||||
| 	page = alloc_page(GFP_KERNEL); | ||||
| 	if (!page) { | ||||
| 		pr_err("Failed to allocate page\n"); | ||||
| 		return -ENOMEM; | ||||
| 	} | ||||
| 	 | ||||
| 	ptr = kmap_atomic(page); | ||||
| 	 | ||||
| 	memcpy(ptr, data, MAX_DATA_SIZE); | ||||
| 			 | ||||
| 	memset(ptr + MAX_DATA_SIZE, fill_byte, 512-MAX_DATA_SIZE); | ||||
| 	kunmap_atomic(ptr); | ||||
| 		 | ||||
| 	ret = blkdev_issue_write(bdev, sector_offset , 1 ,GFP_ATOMIC, page); | ||||
| 	if (ret) { | ||||
| 		pr_err("Failed to write to eMMC at offset 0: %d\n", ret); | ||||
| 		__free_page(page); | ||||
| 		return ret; | ||||
| 	} | ||||
| 	 | ||||
| 	sync_blockdev(bdev);  | ||||
| 	__free_page(page); | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| static ssize_t rf_switch_proc_write(struct file *file, const char __user *user_buffer, size_t count, loff_t *ppos) | ||||
| { | ||||
| 	unsigned char buffer[MAX_DATA_SIZE] = {0}; | ||||
| 	int ret; | ||||
| 	 | ||||
| 	if (count != MAX_DATA_SIZE) | ||||
| 		return -EINVAL; | ||||
| 	 | ||||
| 	if (copy_from_user(buffer, user_buffer, count)) | ||||
| 		return -EFAULT; | ||||
| 	 | ||||
| 	buffer[count -1] = '\0'; | ||||
| 	 | ||||
| 	if (strcmp(buffer, "2") != 0 && strcmp(buffer, "3") != 0) { | ||||
| 		pr_err("Invalid value: %s. Only '2' or '3' are allowed.\n", buffer); | ||||
| 		return -EINVAL; | ||||
| 	} | ||||
| 	 | ||||
| 	ret = write_data_to_emmc(target_bdev,  buffer, 0xFF); | ||||
| 	if (ret) { | ||||
| 		pr_err("Failed to write to RF_SWITCH\n"); | ||||
| 		return ret; | ||||
| 	} | ||||
| 	 | ||||
| 	strncpy(current_value, buffer, MAX_DATA_SIZE); | ||||
| 	 | ||||
| 	return count; | ||||
| } | ||||
|  | ||||
| static int rf_switch_proc_open(struct inode *inode, struct file *file) | ||||
| { | ||||
| 	return single_open(file, rf_switch_proc_show, NULL); | ||||
| } | ||||
|  | ||||
| static const struct proc_ops rf_switch_proc_fops = { | ||||
| 	.proc_open = rf_switch_proc_open, | ||||
| 	.proc_read = seq_read, | ||||
| 	.proc_write = rf_switch_proc_write, | ||||
| 	.proc_lseek = seq_lseek, | ||||
| 	.proc_release = single_release, | ||||
| }; | ||||
|  | ||||
| static int __init rf_switch_init(void) | ||||
| { | ||||
| 	target_bdev = find_mmc_partition(); | ||||
| 	if (!target_bdev) { | ||||
| 		pr_err("Failed to find eMMC card or RF_SWITCH partition\n"); | ||||
| 		return -ENOMEM; | ||||
| 	} | ||||
| 	 | ||||
| 	if (!proc_create(PROC_NAME, 0666, NULL, &rf_switch_proc_fops)) { | ||||
| 		pr_err("Failed to create proc entry\n"); | ||||
| 		return -ENOMEM; | ||||
| 	} | ||||
| 	 | ||||
| 	pr_info("RF_SWITCH partition proc interface created\n"); | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static void __exit rf_switch_exit(void) | ||||
| { | ||||
| 	if (target_bdev) { | ||||
| 		blkdev_put(target_bdev, FMODE_READ | FMODE_WRITE); | ||||
| 		target_bdev = NULL; | ||||
| 	} | ||||
| 	remove_proc_entry(PROC_NAME, NULL); | ||||
| 	pr_info("RF_SWITCH partition proc interface removed\n"); | ||||
| } | ||||
|  | ||||
| module_init(rf_switch_init); | ||||
| module_exit(rf_switch_exit); | ||||
|  | ||||
| MODULE_LICENSE("GPL"); | ||||
| MODULE_AUTHOR("Yunxiang Huang"); | ||||
| MODULE_DESCRIPTION("RF_SWITCH partition read/write driver"); | ||||
| @@ -1,3 +1,4 @@ | ||||
| unchanged: | ||||
| --- a/hostapd/config_file.c | ||||
| +++ b/hostapd/config_file.c | ||||
| @@ -3003,6 +3003,8 @@ static int hostapd_config_fill(struct ho | ||||
| @@ -9,12 +10,10 @@ | ||||
|  #endif /* CONFIG_IEEE80211R_AP */ | ||||
|  #ifndef CONFIG_NO_CTRL_IFACE | ||||
|  	} else if (os_strcmp(buf, "ctrl_interface") == 0) { | ||||
| @@ -4958,8 +4960,22 @@ int hostapd_set_iface(struct hostapd_con | ||||
|  		return -1; | ||||
|  	} | ||||
| @@ -4982,6 +4982,19 @@ struct hostapd_config * hostapd_config_r | ||||
|  	fclose(f); | ||||
|   | ||||
| -	for (i = 0; i < conf->num_bss; i++) | ||||
| +	for (i = 0; i < conf->num_bss; i++) { | ||||
|  	for (i = 0; i < conf->num_bss; i++) { | ||||
| +		if (*conf->bss[i]->ft_key) { | ||||
| +			u8 buffer[128]; | ||||
| +			sprintf(buffer, "%02X:%02X:%02X:%02X:%02X:%02X %02X%02X%02X%02X%02X%02X %s", MAC2STR(conf->bss[i]->bssid), MAC2STR(conf->bss[i]->bssid), conf->bss[i]->ft_key); | ||||
| @@ -25,14 +24,12 @@ | ||||
| +			add_r0kh(conf->bss[i], buffer); | ||||
| +			sprintf(buffer, "00:00:00:00:00:00 00:00:00:00:00:00 %s", conf->bss[i]->ft_key); | ||||
| +			add_r1kh(conf->bss[i], buffer); | ||||
| +			hexstr2bin(conf->bss[i]->bssid, conf->bss[i]->r1_key_holder, FT_R1KH_ID_LEN);  | ||||
| +			hexstr2bin(conf->bss[i]->bssid, conf->bss[i]->r1_key_holder, FT_R1KH_ID_LEN); | ||||
| +			conf->bss[i]->r0_key_holder_bssid = 1; | ||||
| +		} | ||||
|  		hostapd_set_security_params(conf->bss[i], 0); | ||||
| +	} | ||||
|   | ||||
|  	if (hostapd_config_check(conf, 0)) { | ||||
|  		wpa_printf(MSG_ERROR, "Configuration check failed"); | ||||
|  		hostapd_set_security_params(conf->bss[i], 1); | ||||
|  #ifdef CONFIG_IEEE80211BE | ||||
|  		if (conf->ieee80211be && conf->bss[i]->ieee80211w > 0 | ||||
| --- a/src/ap/ap_config.h | ||||
| +++ b/src/ap/ap_config.h | ||||
| @@ -398,6 +398,7 @@ struct hostapd_bss_config { | ||||
|   | ||||
| @@ -785,6 +785,7 @@ int hostapd_ucode_sta_auth(struct hostapd_data *hapd, struct sta_info *sta) | ||||
|  | ||||
| void hostapd_ucode_sta_connected(struct hostapd_data *hapd, struct sta_info *sta) | ||||
| { | ||||
| 	struct hostapd_sta_wpa_psk_short *psk = sta->psk; | ||||
| 	char addr[sizeof(MACSTR)]; | ||||
| 	uc_value_t *val, *cur; | ||||
| 	int ret = 0; | ||||
| @@ -801,6 +802,8 @@ void hostapd_ucode_sta_connected(struct hostapd_data *hapd, struct sta_info *sta | ||||
| 	val = ucv_object_new(vm); | ||||
| 	if (sta->psk_idx) | ||||
| 		ucv_object_add(val, "psk_idx", ucv_int64_new(sta->psk_idx - 1)); | ||||
| 	if (sta->psk) | ||||
| 		ucv_object_add(val, "psk", ucv_string_new(sta->psk->passphrase)); | ||||
| 	uc_value_push(ucv_get(val)); | ||||
|  | ||||
| 	val = wpa_ucode_call(3); | ||||
|   | ||||
| @@ -14,9 +14,20 @@ sercomm,ap72tip) | ||||
| 	ucidef_set_led_netdev "wan_act" "wan_act" "yellow:phy" "eth0" "rx tx" | ||||
| 	;; | ||||
| sonicfi,rap7110c-341x|\ | ||||
| sonicfi,rap750e-h|\ | ||||
| sonicfi,rap750e-s|\ | ||||
| sonicfi,rap750w-311a) | ||||
| 	ucidef_set_led_default "power" "POWER" "pwm:blue" "on" | ||||
| 	;; | ||||
| zyxel,nwa130be) | ||||
| 	#eth0: APPE: phyaddr 4  green:2.5G  orange:others | ||||
| 	ssdk_sh debug phy set 4 0x40078074 0x670 | ||||
| 	ssdk_sh debug phy set 4 0x40078078 0x8600 | ||||
|  | ||||
| 	#eth1:  MHT: phyaddr 3  green:2.5G orange:others | ||||
| 	ssdk_sh debug phy set 3 0x40078074 0x670 | ||||
| 	ssdk_sh debug phy set 3 0x40078078 0x8600 | ||||
| 	;; | ||||
| esac | ||||
|  | ||||
| board_config_flush | ||||
|   | ||||
| @@ -13,12 +13,15 @@ ipq53xx_setup_interfaces() | ||||
| 		ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4 eth5" "eth0" | ||||
| 		;; | ||||
| 	cig,wf189|\ | ||||
| 	cig,wf672|\ | ||||
| 	edgecore,eap105|\ | ||||
| 	sercomm,ap72tip|\ | ||||
| 	sonicfi,rap750w-311a) | ||||
| 		ucidef_set_interfaces_lan_wan "eth1" "eth0" | ||||
| 		;; | ||||
| 	sonicfi,rap7110c-341x) | ||||
| 	sonicfi,rap7110c-341x|\ | ||||
| 	sonicfi,rap750e-h|\ | ||||
| 	sonicfi,rap750e-s) | ||||
| 		ucidef_set_interfaces_lan_wan "" "eth0" | ||||
| 		;; | ||||
| 	cig,wf189w) | ||||
| @@ -32,6 +35,9 @@ ipq53xx_setup_interfaces() | ||||
| 	sercomm,ap72tip-v4) | ||||
| 		ucidef_set_interface_wan "eth0" | ||||
| 		;;	 | ||||
| 	zyxel,nwa130be) | ||||
| 		ucidef_set_interfaces_lan_wan "eth1" "eth0" | ||||
| 		;; | ||||
| 	esac | ||||
| } | ||||
|  | ||||
| @@ -39,21 +45,35 @@ qcom_setup_macs() | ||||
| { | ||||
|         local board="$1" | ||||
|         case $board in | ||||
| 	cig,wf189w|\ | ||||
| 	cig,wf189h|\ | ||||
|         cig,wf189w|\ | ||||
|         cig,wf189h|\ | ||||
|         cig,wf189) | ||||
| 		mtd=$(find_mtd_chardev "0:APPSBLENV") | ||||
| 		[ -z "$mtd" ] && return; | ||||
| 		mac=$(grep eth1addr= $mtd | cut -d= -f2) | ||||
|                 mtd=$(find_mtd_chardev "0:APPSBLENV") | ||||
|                 [ -z "$mtd" ] && return; | ||||
|                 mac=$(grep eth1addr= $mtd | cut -d= -f2) | ||||
|                 [ -z "$mac" ] && return; | ||||
|                 wan_mac=$(macaddr_canonicalize $mac) | ||||
|                 lan_mac=$(macaddr_add "$wan_mac" 1) | ||||
|                 ucidef_set_network_device_mac eth0 $wan_mac | ||||
|                 ucidef_set_network_device_mac eth1 $lan_mac | ||||
|                 ucidef_set_label_macaddr $wan_mac | ||||
| 		ucidef_set_wireless_macaddr_base 2g $(macaddr_add "$wan_mac" 2) | ||||
| 		ucidef_set_wireless_macaddr_base 5g $(macaddr_add "$wan_mac" 3) | ||||
| 		ucidef_set_wireless_macaddr_base 6g $(macaddr_add "$wan_mac" 4) | ||||
|                 ucidef_set_wireless_macaddr_base 2g $(macaddr_add "$wan_mac" 2) | ||||
|                 ucidef_set_wireless_macaddr_base 5g $(macaddr_add "$wan_mac" 3) | ||||
|                 ucidef_set_wireless_macaddr_base 6g $(macaddr_add "$wan_mac" 4) | ||||
|                 ;; | ||||
|         cig,wf672) | ||||
|                 mmc=$(find_mmc_part "0:APPSBLENV") | ||||
|                 [ -z "$mmc" ] && return; | ||||
|                 mac=$(grep eth1addr= $mmc | cut -d= -f2) | ||||
|                 [ -z "$mac" ] && return; | ||||
|                 wan_mac=$(macaddr_canonicalize $mac) | ||||
|                 lan_mac=$(macaddr_add "$wan_mac" 1) | ||||
|                 ucidef_set_network_device_mac eth0 $wan_mac | ||||
|                 ucidef_set_network_device_mac eth1 $lan_mac | ||||
|                 ucidef_set_label_macaddr $wan_mac | ||||
|                 ucidef_set_wireless_macaddr_base 2g $(macaddr_add "$wan_mac" 2) | ||||
|                 ucidef_set_wireless_macaddr_base 5g $(macaddr_add "$wan_mac" 3) | ||||
|                 ucidef_set_wireless_macaddr_base 6g $(macaddr_add "$wan_mac" 4) | ||||
|                 ;; | ||||
|         sercomm,ap72tip) | ||||
|                 wan_mac=$(cat /sys/class/net/eth0/address) | ||||
| @@ -65,12 +85,18 @@ qcom_setup_macs() | ||||
|         edgecore,eap105) | ||||
|                 wan_mac=$(cat /sys/class/net/eth0/address) | ||||
|                 lan_mac=$(macaddr_add "$wan_mac" 1) | ||||
|                 ucidef_set_wireless_macaddr_base 2g $(macaddr_add "$wan_mac" 2) | ||||
|                 ucidef_set_wireless_macaddr_base 5g $(macaddr_add "$wan_mac" 3) | ||||
|                 ucidef_set_wireless_macaddr_base 6g $(macaddr_add "$wan_mac" 4) | ||||
| 		;; | ||||
|         sonicfi,rap7110c-341x) | ||||
|         sonicfi,rap7110c-341x|\ | ||||
|         sonicfi,rap750e-h|\ | ||||
|         sonicfi,rap750e-s) | ||||
|                 wan_mac=$(cat /sys/class/net/eth0/address) | ||||
|                 ucidef_set_wireless_macaddr_base 2g $(macaddr_add "$wan_mac" 1) | ||||
|                 ucidef_set_wireless_macaddr_base 5g $(macaddr_add "$wan_mac" 2) | ||||
|                 ucidef_set_wireless_macaddr_base 6g $(macaddr_add "$wan_mac" 3) | ||||
|                 [ "$board" = "sonicfi,rap7110c-34x" ] && | ||||
|                     ucidef_set_wireless_macaddr_base 6g $(macaddr_add "$wan_mac" 3) | ||||
|                 ;; | ||||
|         sonicfi,rap750w-311a) | ||||
|                 wan_mac=$(cat /sys/class/net/eth0/address) | ||||
| @@ -84,6 +110,19 @@ qcom_setup_macs() | ||||
|                 ucidef_set_wireless_macaddr_base 5g $(macaddr_add "$wan_mac" 2) | ||||
|                 ucidef_set_wireless_macaddr_base 6g $(macaddr_add "$wan_mac" 3) | ||||
|                 ;; | ||||
| 	zyxel,nwa130be) | ||||
| 		wan_mac=$(cat /proc/cmdline) | ||||
| 		wan_mac="${wan_mac##*hwaddr=}" | ||||
| 		wan_mac="${wan_mac%% *}" | ||||
| 		wan_mac="$(echo ${wan_mac} | sed 's/\(..\)/\1:/g;s/:$//')" | ||||
| 		lan_mac=$(macaddr_add "$wan_mac" 1) | ||||
| 		ucidef_set_network_device_mac eth0 $wan_mac | ||||
| 		ucidef_set_network_device_mac eth1 $lan_mac | ||||
| 		ucidef_set_label_macaddr $wan_mac | ||||
| 		ucidef_set_wireless_macaddr_base 2g $(macaddr_add "$wan_mac" 2) | ||||
| 		ucidef_set_wireless_macaddr_base 5g $(macaddr_add "$wan_mac" 3) | ||||
| 		ucidef_set_wireless_macaddr_base 6g $(macaddr_add "$wan_mac" 4) | ||||
| 		;; | ||||
|         *) | ||||
|                 wan_mac=$(cat /sys/class/net/eth1/address) | ||||
|                 lan_mac=$(macaddr_add "$wan_mac" 1) | ||||
|   | ||||
| @@ -23,6 +23,39 @@ caldata_extract() { | ||||
|                 caldata_die "failed to extract calibration data from $mtd" | ||||
| } | ||||
|  | ||||
| cig_ipq5322_cal() { | ||||
| 	local ext_ant=0 | ||||
|  | ||||
| 	[ -f /sys/firmware/devicetree/base/soc@0/wifi@c0000000/ext_antenna ] && ext_ant=1	 | ||||
|  | ||||
| 	if [ "$ext_ant" = "0" ]; then | ||||
| 		caldata_extract_mmc "0:ART" 0x1000 0x20000 | ||||
| 	else | ||||
| 		caldata_extract_mmc "0:ART" 0xbd800 0x20000 | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| cig_qcn92xx_cal() { | ||||
| 	local bands=$(cat /proc/rf_switch) | ||||
| 	local ext_ant=0 | ||||
| 	 | ||||
| 	[ -f /sys/firmware/devicetree/base/soc@0/wifi@c0000000/ext_antenna ] && ext_ant=1	 | ||||
|  | ||||
| 	if [ "$bands" = "2" ]; then | ||||
| 		if [ "$ext_ant" = "0" ]; then | ||||
| 			caldata_extract_mmc "0:ART" 0x8b800 0x2d000 | ||||
| 		else | ||||
| 			caldata_extract_mmc "0:ART" 0xe3000 0x2d000 | ||||
| 		fi | ||||
| 	else | ||||
| 		if [ "$ext_ant" = "0" ]; then | ||||
| 			caldata_extract_mmc "0:ART" 0x58800 0x2d000 | ||||
| 		else | ||||
| 			caldata_extract_mmc "0:ART" 0x115000 0x2d000 | ||||
| 		fi | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| board=$(board_name) | ||||
| case "$FIRMWARE" in | ||||
| ath12k/IPQ5332/hw1.0/caldata.bin) | ||||
| @@ -32,14 +65,20 @@ ath12k/IPQ5332/hw1.0/caldata.bin) | ||||
| 	cig,wf189|\ | ||||
| 	edgecore,eap105|\ | ||||
| 	sercomm,ap72tip-v4|\ | ||||
| 	sercomm,ap72tip) | ||||
| 	sercomm,ap72tip|\ | ||||
| 	zyxel,nwa130be) | ||||
| 		caldata_extract "0:ART" 0x1000 0x20000  | ||||
| 		;; | ||||
| 	cig,wf672) | ||||
| 		cig_ipq5322_cal | ||||
| 		;; | ||||
| 	sonicfi,rap7110c-341x) | ||||
| 		caldata_extract_mmc "0:ART" 0x1000 0xF800 | ||||
| 		;; | ||||
| 	sonicfi,rap750e-h|\ | ||||
| 	sonicfi,rap750e-s|\ | ||||
| 	sonicfi,rap750w-311a) | ||||
| 		caldata_extract "0:ART" 0x1000 0xf800  | ||||
| 		caldata_extract "0:ART" 0x1000 0xf800 | ||||
| 		;; | ||||
| 	esac | ||||
| 	;; | ||||
| @@ -48,9 +87,13 @@ ath12k/QCN92XX/hw1.0/cal-pci-0001:01:00.0.bin) | ||||
| 	cig,wf189|\ | ||||
| 	edgecore,eap105|\ | ||||
| 	sercomm,ap72tip-v4|\ | ||||
| 	sercomm,ap72tip) | ||||
| 	sercomm,ap72tip|\ | ||||
| 	zyxel,nwa130be) | ||||
| 		caldata_extract "0:ART" 0x58800 0x2d000 | ||||
| 		;; | ||||
| 	cig,wf672) | ||||
| 		cig_qcn92xx_cal | ||||
| 		;; | ||||
| 	sonicfi,rap7110c-341x) | ||||
| 		caldata_extract_mmc "0:ART" 0x58800 0x2d000 | ||||
| 		;; | ||||
| @@ -58,6 +101,8 @@ ath12k/QCN92XX/hw1.0/cal-pci-0001:01:00.0.bin) | ||||
| 	;; | ||||
| ath12k/QCN6432/hw1.0/caldata_1.bin) | ||||
| 	case "$board" in | ||||
| 	sonicfi,rap750e-h|\ | ||||
| 	sonicfi,rap750e-s|\ | ||||
| 	sonicfi,rap750w-311a) | ||||
| 		caldata_extract "0:ART" 0x12800 0x18800 | ||||
| 		;; | ||||
|   | ||||
| @@ -0,0 +1,20 @@ | ||||
| # /etc/hotplug.d/iface/85-greqos | ||||
| [ "$ACTION" == "ifup" ] || exit 0 | ||||
|  | ||||
| . /lib/functions.sh | ||||
|  | ||||
| case "$(board_name)" in | ||||
| cig,wf189|\ | ||||
| cig,wf189w|\ | ||||
| cig,wf189h|\ | ||||
| cig,wf672) | ||||
|     case "$INTERFACE" in | ||||
|       gre*) | ||||
|         dev=$(ubus call network.interface.$INTERFACE status | jsonfilter -e '@.l3_device') | ||||
|         [ -n "$dev" ] && { | ||||
|           tc qdisc del dev $dev root 2>/dev/null | ||||
|           tc qdisc add dev $dev root noqueue | ||||
|         } | ||||
|         ;; | ||||
|     esac | ||||
| esac | ||||
| @@ -57,6 +57,52 @@ sonicfi_dualimage_check() { | ||||
| 	fi | ||||
| } | ||||
|  | ||||
| spi_nor_emmc_do_upgrade_bootconfig() { | ||||
| 	local tar_file="$1" | ||||
|  | ||||
| 	local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$') | ||||
| 	board_dir=${board_dir%/} | ||||
| 	[ -f /proc/boot_info/bootconfig0/getbinary_bootconfig ] || { | ||||
| 		echo "bootconfig does not exist" | ||||
| 		exit | ||||
| 	} | ||||
| 	CI_ROOTPART="$(cat /proc/boot_info/bootconfig0/rootfs/upgradepartition)" | ||||
| 	CI_KERNPART="$(cat /proc/boot_info/bootconfig0/0:HLOS/upgradepartition)" | ||||
|  | ||||
| 	[ -n "$CI_KERNPART" -a -n "$CI_ROOTPART" ] || { | ||||
| 		echo "kernel or rootfs partition is unknown" | ||||
| 		exit | ||||
| 	} | ||||
|  | ||||
| 	local primary="0" | ||||
| 	[ "$(cat /proc/boot_info/bootconfig0/rootfs/primaryboot)" = "0" ] && primary="1" | ||||
| 	echo "$primary" > /proc/boot_info/bootconfig0/rootfs/primaryboot 2>/dev/null | ||||
| 	echo "$primary" > /proc/boot_info/bootconfig0/0:HLOS/primaryboot 2>/dev/null | ||||
| 	cp /proc/boot_info/bootconfig0/getbinary_bootconfig /tmp/bootconfig | ||||
|  | ||||
| 	do_flash_emmc $tar_file $CI_KERNPART $board_dir kernel | ||||
| 	do_flash_emmc $tar_file $CI_ROOTPART $board_dir root | ||||
|  | ||||
| 	local emmcblock="$(find_mmc_part "rootfs_data")" | ||||
| 	if [ -e "$emmcblock" ]; then | ||||
| 		mkfs.ext4 -F "$emmcblock" | ||||
| 	fi | ||||
|  | ||||
| 	for part in "0:BOOTCONFIG" "0:BOOTCONFIG1"; do | ||||
| 				local mtdchar=$(echo $(find_mtd_chardev $part) | sed 's/^.\{5\}//') | ||||
| 				if [ -n "$mtdchar" ]; then | ||||
| 						echo start to update $mtdchar | ||||
| 						mtd -qq write /proc/boot_info/bootconfig0/getbinary_bootconfig "/dev/${mtdchar}" 2>/dev/null && echo update mtd $mtdchar | ||||
| 			   else | ||||
| 						emmcblock=$(find_mmc_part $part) | ||||
| 						echo erase ${emmcblock} | ||||
| 						dd if=/dev/zero of=${emmcblock} 2> /dev/null | ||||
| 						echo update $emmcblock | ||||
| 						dd if=/tmp/bootconfig of=${emmcblock} 2> /dev/null | ||||
| 				fi | ||||
| 	done | ||||
| } | ||||
|  | ||||
| emmc_do_upgrade() { | ||||
| 	local tar_file="$1" | ||||
| 	local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$') | ||||
| @@ -86,6 +132,8 @@ platform_do_upgrade() { | ||||
|  | ||||
| 	board=$(board_name) | ||||
| 	case $board in | ||||
| 	sercomm,ap72tip-v4|\ | ||||
| 	sercomm,ap72tip|\ | ||||
| 	cig,wf189w|\ | ||||
| 	cig,wf189h|\ | ||||
| 	cig,wf189) | ||||
| @@ -98,6 +146,9 @@ platform_do_upgrade() { | ||||
| 		fi | ||||
| 		nand_upgrade_tar "$1" | ||||
| 		;; | ||||
| 	cig,wf672) | ||||
| 		spi_nor_emmc_do_upgrade_bootconfig $1 | ||||
| 		;; | ||||
| 	edgecore,eap105) | ||||
| 		if [ "$(find_mtd_chardev rootfs)" ]; then | ||||
| 			CI_UBIPART="rootfs" | ||||
| @@ -114,14 +165,15 @@ platform_do_upgrade() { | ||||
| 		;; | ||||
| 	sonicfi,rap7110c-341x) | ||||
| 		sonicfi_dualimage_check | ||||
| 		emmc_do_upgrade $1 $1 | ||||
| 		emmc_do_upgrade "$1" | ||||
| 		;; | ||||
| 	sonicfi,rap750e-h|\ | ||||
| 	sonicfi,rap750e-s|\ | ||||
| 	sonicfi,rap750w-311a) | ||||
| 		sonicfi_dualimage_check | ||||
| 		nand_upgrade_tar "$1" | ||||
| 		;; | ||||
| 	sercomm,ap72tip-v4|\ | ||||
| 	sercomm,ap72tip) | ||||
| 	zyxel,nwa130be) | ||||
| 		nand_upgrade_tar "$1" | ||||
| 		;; | ||||
| 	esac | ||||
|   | ||||
| @@ -1223,3 +1223,5 @@ CONFIG_PSTORE=y | ||||
| CONFIG_PSTORE_CONSOLE=y | ||||
| CONFIG_PSTORE_PMSG=y | ||||
| CONFIG_PSTORE_RAM=y | ||||
| # CONFIG_RTL8221D_PHY is not set | ||||
| # CONFIG_INPUT_LSM303AGR is not set | ||||
|   | ||||
| @@ -18,6 +18,21 @@ | ||||
| 	model = "CIG WF189"; | ||||
| 	compatible = "cig,wf189", "qcom,ipq5332-ap-mi01.6", "qcom,ipq5332-rdp468", "qcom,ipq5332"; | ||||
|  | ||||
|     reserved-memory { | ||||
|         #address-cells = <2>; | ||||
|         #size-cells = <2>; | ||||
|         ranges; | ||||
|  | ||||
|        ramoops@49c00000 { | ||||
|            compatible = "ramoops"; | ||||
|            no-map; | ||||
|            reg = <0x0 0x49c00000 0x0 0x50000>; | ||||
|            record-size = <0x20000>; | ||||
|            console-size = <0x8000>; | ||||
|            pmsg-size = <0x8000>; | ||||
|        }; | ||||
|     }; | ||||
|  | ||||
| 	aliases { | ||||
| 		serial0 = &blsp1_uart0; | ||||
| 		serial1 = &blsp1_uart1; | ||||
|   | ||||
							
								
								
									
										548
									
								
								feeds/qca-wifi-7/ipq53xx/dts/ipq5332-cig-wf672.dts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										548
									
								
								feeds/qca-wifi-7/ipq53xx/dts/ipq5332-cig-wf672.dts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,548 @@ | ||||
| // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) | ||||
| /* | ||||
|  * IPQ5332 RDP468 board device tree source | ||||
|  * | ||||
|  * Copyright (c) 2020-2021 The Linux Foundation. All rights reserved. | ||||
|  * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. | ||||
|  */ | ||||
|  | ||||
| /dts-v1/; | ||||
|  | ||||
| #include <dt-bindings/gpio/gpio.h> | ||||
| #include <dt-bindings/input/input.h> | ||||
| #include <dt-bindings/leds/common.h> | ||||
| #include "ipq5332.dtsi" | ||||
| #include "ipq5332-default-memory.dtsi" | ||||
|  | ||||
| / { | ||||
| 	model = "CIG WF672"; | ||||
| 	compatible = "cig,wf672", "qcom,ipq5332-rdp468", "qcom,ipq5332"; | ||||
|  | ||||
| 	aliases { | ||||
| 		serial0 = &blsp1_uart0; | ||||
| 		serial1 = &blsp1_uart1; | ||||
| 		ethernet0 = "/soc/dp1"; | ||||
| 		ethernet1 = "/soc/dp2"; | ||||
| 		led-boot = &led_power_green; | ||||
| 		led-failsafe = &led_power_red; | ||||
| 		led-running = &led_power_green; | ||||
| 		led-upgrade = &led_power_green; | ||||
| 	}; | ||||
|  | ||||
| 	chosen { | ||||
| 		stdout-path = "serial0"; | ||||
| 	}; | ||||
|  | ||||
| 	soc@0 { | ||||
| 		mdio:mdio@90000 { | ||||
| 			pinctrl-0 = <&mdio1_pins>; | ||||
| 			pinctrl-names = "default"; | ||||
| 			/*gpio51 for manhattan reset*/ | ||||
| 			phy-reset-gpio = <&tlmm 21 GPIO_ACTIVE_LOW>; | ||||
| 			phyaddr_fixup = <0xC90F018>; | ||||
| 			uniphyaddr_fixup = <0xC90F014>; | ||||
| 			mdio_clk_fixup; /* MDIO clock sequence fix up flag */ | ||||
| 			status = "okay"; | ||||
|  | ||||
| 			phy0: ethernet-phy@0 { | ||||
| 				reg = <1>; | ||||
| 				compatible ="ethernet-phy-ieee802.3-c45"; | ||||
| 				fixup; | ||||
| 			}; | ||||
| 			phy1: ethernet-phy@1 { | ||||
| 				reg = <30>; | ||||
| 				fixup; | ||||
| 			}; | ||||
| 		}; | ||||
|  | ||||
| 		ess-instance { | ||||
| 			num_devices = <0x1>; | ||||
|  | ||||
| 			ess-switch@3a000000 { | ||||
| 				switch_cpu_bmp = <0x1>;  /* cpu port bitmap */ | ||||
| 				switch_lan_bmp = <0x2>; /* lan port bitmap */ | ||||
| 				switch_wan_bmp = <0x4>; /* wan port bitmap */ | ||||
| 				switch_mac_mode = <0xc>; /* mac mode for uniphy instance0*/ | ||||
| 				switch_mac_mode1 = <0xe>; /* mac mode for uniphy instance1*/ | ||||
| 				switch_mac_mode2 = <0xff>; /* mac mode for uniphy instance2*/ | ||||
|  | ||||
| 				qcom,port_phyinfo { | ||||
| 					port@0 { | ||||
| 						port_id = <1>; | ||||
| 						phy_address = <1>; | ||||
| 						ethernet-phy-ieee802.3-c45; | ||||
| 						forced-speed = <2500>; | ||||
| 						forced-duplex = <1>; | ||||
| 						mdiobus = <&mdio>; | ||||
| 					}; | ||||
| 					port@1 { | ||||
| 						port_id = <2>; | ||||
| 						phy_address = <30>; | ||||
| 						phy_i2c_address =<30>; | ||||
| 						phy-i2c-mode; | ||||
| 						sfp_rx_los_pin = <&tlmm 43 0>; | ||||
| 						sfp_mod_present_pin = <&tlmm 45 0>; | ||||
| 						sfp_tx_dis_pin = <&extgpio 11 0>; | ||||
| 						media-type = "sfp"; /* fiber mode */ | ||||
| 					}; | ||||
| 				}; | ||||
|  | ||||
| 			}; | ||||
|  | ||||
| 		}; | ||||
|  | ||||
| 		dp2 { | ||||
| 			device_type = "network"; | ||||
| 			compatible = "qcom,nss-dp"; | ||||
| 			qcom,id = <1>; | ||||
| 			reg = <0x3a500000 0x4000>; | ||||
| 			qcom,mactype = <1>; | ||||
| 			local-mac-address = [000000000000]; | ||||
| 			mdio-bus = <&mdio>; | ||||
| 			qcom,phy-mdio-addr = <1>; | ||||
| 			qcom,link-poll = <1>; | ||||
| 			phy-mode = "sgmii"; | ||||
| 		}; | ||||
|  | ||||
| 		gmac2:dp1 { | ||||
| 			device_type = "network"; | ||||
| 			compatible = "qcom,nss-dp"; | ||||
| 			qcom,id = <2>; | ||||
| 			reg = <0x3a504000 0x4000>; | ||||
| 			qcom,mactype = <1>; | ||||
| 			local-mac-address = [000000000000]; | ||||
| 			qcom,phy-mdio-addr = <30>; | ||||
| 			qcom,link-poll = <1>; | ||||
| 			phy-mode = "sgmii"; | ||||
| 		}; | ||||
|  | ||||
| 		x5-cpe { | ||||
| 			compatible = "x55-poweron"; | ||||
| 			pwykey = <&extgpio2 13 0>; | ||||
| 			status = "ok"; | ||||
| 		}; | ||||
|  | ||||
| 		/* EDMA host driver configuration for the board */ | ||||
| 		edma@3ab00000 { | ||||
| 			qcom,txdesc-ring-start = <4>;		/* Tx desc ring start ID */ | ||||
| 			qcom,txdesc-rings = <12>;		/* Total number of Tx desc rings to be provisioned */ | ||||
| 			qcom,mht-txdesc-rings = <8>;            /* Extra Tx desc rings to be provisioned for MHT SW ports */ | ||||
| 			qcom,txcmpl-ring-start = <4>;		/* Tx complete ring start ID */ | ||||
| 			qcom,txcmpl-rings = <12>;		/* Total number of Tx complete rings to be provisioned */ | ||||
| 			qcom,mht-txcmpl-rings = <8>;            /* Extra Tx complete rings to be provisioned for mht sw ports. */ | ||||
| 			qcom,rxfill-ring-start = <4>;		/* Rx fill ring start ID */ | ||||
| 			qcom,rxfill-rings = <4>;		/* Total number of Rx fill rings to be provisioned */ | ||||
| 			qcom,rxdesc-ring-start = <12>;		/* Rx desc ring start ID */ | ||||
| 			qcom,rxdesc-rings = <4>;		/* Total number of Rx desc rings to be provisioned */ | ||||
| 			qcom,rx-page-mode = <0>;		/* Rx fill ring page mode */ | ||||
| 			qcom,tx-map-priority-level = <1>;	/* Tx priority level per port */ | ||||
| 			qcom,rx-map-priority-level = <1>;	/* Rx priority level per core */ | ||||
| 			qcom,ppeds-num = <2>;			/* Number of PPEDS nodes */ | ||||
| 			/* PPE-DS node format: <Rx-fill Tx-cmpl Rx Tx Queue-base Queue-count> */ | ||||
| 			qcom,ppeds-map = <1 1 1 1 32 8>,	/* PPEDS Node#0 ring and queue map */ | ||||
| 					<2 2 2 2 40 8>;		/* PPEDS Node#1 ring and queue map */ | ||||
| 			qcom,txdesc-map = <8 9 10 11>,		/* Port0 per-core Tx ring map */ | ||||
| 					<12 13 14 15>,        /* MHT-Port1 per-core Tx ring map */ | ||||
| 					<4 5 6 7>,            /* MHT-Port2 per-core Tx ring map/packets from  vp*/ | ||||
| 					<16 17 18 19>,        /* MHT-Port3 per-core Tx ring map */ | ||||
| 					<20 21 22 23>;        /* MHT-Port4 per-core Tx ring map */ | ||||
| 			qcom,txdesc-fc-grp-map = <1 2 3 4 5>;   /* Per GMAC flow control group map */ | ||||
| 			qcom,rxfill-map = <4 5 6 7>;		/* Per-core Rx fill ring map */ | ||||
| 			qcom,rxdesc-map = <12 13 14 15>;	/* Per-core Rx desc ring map */ | ||||
| 			qcom,rx-queue-start = <0>;		/* Rx queue start */ | ||||
| 			qcom,rx-ring-queue-map = <0 8 16 24>,	/* Priority 0 queues per-core Rx ring map */ | ||||
| 						<1 9 17 25>,	/* Priority 1 queues per-core Rx ring map */ | ||||
| 						<2 10 18 26>,	/* Priority 2 queues per-core Rx ring map */ | ||||
| 						<3 11 19 27>,	/* Priority 3 queues per-core Rx ring map */ | ||||
| 						<4 12 20 28>,	/* Priority 4 queues per-core Rx ring map */ | ||||
| 						<5 13 21 29>,	/* Priority 5 queues per-core Rx ring map */ | ||||
| 						<6 14 22 30>,	/* Priority 6 queues per-core Rx ring map */ | ||||
| 						<7 15 23 31>;	/* Priority 7 queues per-core Rx ring map */ | ||||
| 			interrupts = <0 163 4>,			/* Tx complete ring id #4 IRQ info */ | ||||
| 				   <0 164 4>,			/* Tx complete ring id #5 IRQ info */ | ||||
| 				   <0 165 4>,			/* Tx complete ring id #6 IRQ info */ | ||||
| 				   <0 166 4>,			/* Tx complete ring id #7 IRQ info */ | ||||
| 				   <0 167 4>,			/* Tx complete ring id #8 IRQ info */ | ||||
| 				   <0 168 4>,			/* Tx complete ring id #9 IRQ info */ | ||||
| 				   <0 169 4>,			/* Tx complete ring id #10 IRQ info */ | ||||
| 				   <0 170 4>,			/* Tx complete ring id #11 IRQ info */ | ||||
| 				   <0 171 4>,			/* Tx complete ring id #12 IRQ info */ | ||||
| 				   <0 172 4>,			/* Tx complete ring id #13 IRQ info */ | ||||
| 				   <0 173 4>,			/* Tx complete ring id #14 IRQ info */ | ||||
| 				   <0 174 4>,			/* Tx complete ring id #15 IRQ info */ | ||||
| 				   <0 139 4>,			/* Rx desc ring id #12 IRQ info */ | ||||
| 				   <0 140 4>,			/* Rx desc ring id #13 IRQ info */ | ||||
| 				   <0 141 4>,			/* Rx desc ring id #14 IRQ info */ | ||||
| 				   <0 142 4>,			/* Rx desc ring id #15 IRQ info */ | ||||
| 				   <0 191 4>,			/* Misc error IRQ info */ | ||||
| 				<0 160 4>,			/* PPEDS Node #1(TxComp ring id #1) TxComplete IRQ info */ | ||||
| 				<0 128 4>,			/* PPEDS Node #1(Rx Desc ring id #1) Rx Desc IRQ info */ | ||||
| 				<0 152 4>,			/* PPEDS Node #1(RxFill Desc ring id #1) Rx Fill IRQ info */ | ||||
| 				<0 161 4>,			/* PPEDS Node #2(TxComp ring id #2) TxComplete IRQ info */ | ||||
| 				<0 129 4>,			/* PPEDS Node #2(Rx Desc ring id #2) Rx Desc IRQ info */ | ||||
| 				<0 153 4>,                      /* PPEDS Node #2(RxFill Desc ring id #2) Rx Fill IRQ info */ | ||||
| 				<0 175 4>,                   /* MHT port Tx complete ring id #16 IRQ info */ | ||||
| 				<0 176 4>,                   /* MHT port Tx complete ring id #17 IRQ info */ | ||||
| 				<0 177 4>,                   /* MHT port Tx complete ring id #18 IRQ info */ | ||||
| 				<0 178 4>,                   /* MHT port Tx complete ring id #19 IRQ info */ | ||||
| 				<0 179 4>,                   /* MHT port Tx complete ring id #20 IRQ info */ | ||||
| 				<0 180 4>,                   /* MHT port Tx complete ring id #21 IRQ info */ | ||||
| 				<0 181 4>,                   /* MHT port Tx complete ring id #22 IRQ info */ | ||||
| 				<0 182 4>;                   /* MHT port Tx complete ring id #23 IRQ info */ | ||||
| 		}; | ||||
|  | ||||
| 		pwmleds { | ||||
| 			compatible = "pwm-leds"; | ||||
|  | ||||
| 			led_power_red:red { | ||||
| 				label = "pwm:red"; | ||||
| 				pwms = <&pwm 3 1250000>; | ||||
| 				max-brightness = <160>; | ||||
| 				linux,default-trigger = "none"; | ||||
| 				default-state = "off"; | ||||
| 			}; | ||||
|  | ||||
| 			led_power_green:green { | ||||
| 				label = "pwm:green"; | ||||
| 				pwms = <&pwm 2 1250000>; | ||||
| 				max-brightness = <160>; | ||||
| 				linux,default-trigger = "none"; | ||||
| 				default-state = "off"; | ||||
| 			}; | ||||
|  | ||||
| 			led_power_blue: blue { | ||||
| 				label = "pwm:blue"; | ||||
| 				pwms = <&pwm 1 1250000>; | ||||
| 				max-brightness = <160>; | ||||
| 				linux,default-trigger = "none"; | ||||
| 				default-state = "off"; | ||||
| 			}; | ||||
| 		}; | ||||
|  | ||||
| 		gpio_keys { | ||||
| 			compatible = "gpio-keys"; | ||||
| 			pinctrl-0 = <&button_pins>; | ||||
| 			pinctrl-names = "default"; | ||||
| 			status = "okay"; | ||||
|  | ||||
| 			button@1 { | ||||
| 				label = "rst"; | ||||
| 				linux,code = <KEY_RESTART>; | ||||
| 				gpios = <&tlmm 24 GPIO_ACTIVE_LOW>; | ||||
| 				linux,input-type = <1>; | ||||
| 				debounce-interval = <60>; | ||||
| 			}; | ||||
| 		}; | ||||
|  | ||||
| 		wsi: wsi { | ||||
| 			id = <0>; | ||||
| 			num_chip = <2>; | ||||
| 			status = "okay"; | ||||
| 			chip_info = <0 1 1>, | ||||
| 				    <1 1 0>; | ||||
| 		}; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &wifi0 { | ||||
| 	led-gpio = <&tlmm 36 GPIO_ACTIVE_HIGH>; | ||||
| 	qcom,rproc = <&q6_wcss_pd1>; | ||||
| 	qcom,rproc_rpd = <&q6v5_wcss>; | ||||
| 	qcom,multipd_arch; | ||||
| 	qcom,userpd-subsys-name = "q6v5_wcss_userpd1"; | ||||
| 	memory-region = <&q6_region>; | ||||
| 	qcom,wsi = <&wsi>; | ||||
| 	qcom,wsi_index = <0>; | ||||
| 	qcom,board_id = <0x12>; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &qcn9224_pcie1 { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &blsp1_uart0 { | ||||
| 	pinctrl-0 = <&serial_0_pins>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &blsp1_uart1 { | ||||
| 	pinctrl-0 = <&serial_1_pins &pta_slic>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &blsp1_i2c1 { | ||||
| 	status = "okay"; | ||||
| 	clock-frequency  = <400000>; | ||||
| 	pinctrl-0 = <&i2c_1_pins>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	extgpio:pca9555@20{ | ||||
| 		compatible = "nxp,pca9555"; | ||||
| 		reg = <0x20>; | ||||
| 		pinctrl-names = "default"; | ||||
| 		gpio-controller; | ||||
| 		#gpio-cells = <2>; | ||||
| 		status = "okay"; | ||||
|  | ||||
| 	}; | ||||
| 	extgpio2:pca9555@21{ | ||||
| 		compatible = "nxp,pca9555"; | ||||
| 		reg = <0x21>; | ||||
| 		pinctrl-names = "default"; | ||||
| 		gpio-controller; | ||||
| 		#gpio-cells = <2>; | ||||
| 		status = "okay"; | ||||
| 	}; | ||||
| 	lsm303_acc@19{ | ||||
| 		compatible = "st,lsm303agr_acc"; | ||||
| 		reg = <0x19>; | ||||
| 	}; | ||||
| 	lsm303_mag@1e{ | ||||
| 		compatible = "st,lsm303agr_mag"; | ||||
| 		reg = <0x1e>; | ||||
| 	}; | ||||
| 	ilps22qs@5c{ | ||||
| 		compatible = "st,ilps22qs"; | ||||
| 		reg = <0x5c>; | ||||
| 	}; | ||||
| 	temp-sense@70 { | ||||
| 		compatible = "ti,tmp103"; | ||||
| 		reg = <0x70>; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &blsp1_spi0 { | ||||
| 	pinctrl-0 = <&spi_0_data_clk_pins &spi_0_cs_pins>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "okay"; | ||||
|  | ||||
| 	flash@0 { | ||||
| 		compatible = "n25q128a11", "micron,n25q128a11", "jedec,spi-nor"; | ||||
| 		reg = <0>; | ||||
| 		#address-cells = <1>; | ||||
| 		#size-cells = <1>; | ||||
| 		spi-max-frequency = <50000000>; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &blsp1_spi2 { | ||||
| 	pinctrl-0 = <&spi_2_pins>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	cs-select = <0>; | ||||
| 	status = "disabled"; | ||||
| }; | ||||
|  | ||||
| &sdhc { | ||||
|         bus-width = <4>; | ||||
|         max-frequency = <192000000>; | ||||
|         mmc-ddr-1_8v; | ||||
|         mmc-hs200-1_8v; | ||||
|         non-removable; | ||||
|         pinctrl-0 = <&sdc_default_state>; | ||||
|         reset = <&tlmm 20 0>; | ||||
|         pinctrl-names = "default"; | ||||
|         status = "okay"; | ||||
| }; | ||||
|  | ||||
| &sleep_clk { | ||||
| 	clock-frequency = <32000>; | ||||
| }; | ||||
|  | ||||
| &xo { | ||||
| 	clock-frequency = <24000000>; | ||||
| }; | ||||
|  | ||||
| &qpic_bam { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &pcie1_phy_x2 { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &pcie0_phy { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &pcie0 { | ||||
| 	pinctrl-0 = <&pcie0_default_state>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	perst-gpios = <&tlmm 38 GPIO_ACTIVE_LOW>; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &pcie1 { | ||||
| 	pinctrl-0 = <&pcie1_default_state>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	perst-gpios = <&tlmm 47 GPIO_ACTIVE_LOW>; | ||||
| 	status = "okay"; | ||||
|  | ||||
| 	pcie1_rp { | ||||
| 		reg = <0 0 0 0 0>; | ||||
|  | ||||
| 		qcom,mhi@1 { | ||||
| 			reg = <0 0 0 0 0>; | ||||
| 			boot-args = <0x2 0x4 0x34 0x3 0x0 0x0     /* MX Rail, GPIO52, Drive strength 0x3 */ | ||||
| 					0x4 0x4 0x18 0x3 0x0 0x0  /* RFA1p2 Rail, GPIO24, Drive strength 0x3 */ | ||||
| 					0x0 0x4 0x0 0x0 0x0 0x0>; /* End of arguments */ | ||||
| 			memory-region = <&qcn9224_pcie1>; | ||||
| 			qcom,wsi = <&wsi>; | ||||
| 			qcom,wsi_index = <1>; | ||||
| 			qcom,board_id = <0x1015>; | ||||
| 		}; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| /* PINCTRL */ | ||||
|  | ||||
| &tlmm { | ||||
| 	i2c_1_pins: i2c-1-state { | ||||
| 		pins = "gpio29", "gpio30"; | ||||
| 		function = "blsp1_i2c0"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-up; | ||||
| 	}; | ||||
|  | ||||
| 	spi_2_pins: spi-2-pins { | ||||
| 		pins = "gpio33", "gpio34", "gpio35", "gpio36"; | ||||
| 		function = "blsp2_spi0"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-down; | ||||
| 	}; | ||||
| 	 | ||||
| 	 pta_slic: pta_slic { | ||||
| 		pta1_0 { | ||||
| 			pins = "gpio49"; | ||||
| 			function = "pta1_0"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-disable; | ||||
| 		}; | ||||
| 		pta1_1 { | ||||
| 			pins = "gpio50"; | ||||
| 			function = "pta1_1"; | ||||
|                         drive-strength = <8>; | ||||
| 			bias-disable; | ||||
|                 }; | ||||
| 		pta1_2 { | ||||
| 			pins = "gpio51"; | ||||
| 			function = "pta1_2"; | ||||
|                         drive-strength = <8>; | ||||
| 			bias-disable; | ||||
|                 }; | ||||
| 	}; | ||||
|  | ||||
| 	spi_0_data_clk_pins: spi-0-data-clk-state { | ||||
| 		pins = "gpio14", "gpio15", "gpio16"; | ||||
| 		function = "blsp0_spi"; | ||||
| 		drive-strength = <2>; | ||||
| 		bias-pull-down; | ||||
| 	}; | ||||
|  | ||||
| 	spi_0_cs_pins: spi-0-cs-state { | ||||
| 		pins = "gpio17"; | ||||
| 		function = "blsp0_spi"; | ||||
| 		drive-strength = <2>; | ||||
| 		bias-pull-up; | ||||
| 	}; | ||||
|  | ||||
| 	serial_1_pins: serial1-pinmux { | ||||
| 		pins = "gpio33", "gpio34", "gpio35", "gpio36"; | ||||
| 		function = "blsp1_uart2"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-up; | ||||
| 	}; | ||||
|  | ||||
| 	button_pins: button-state { | ||||
| 		pins = "gpio24"; | ||||
| 		function = "gpio"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-up; | ||||
| 	}; | ||||
|  | ||||
| 	pwm_pins: pwm-state { | ||||
|  | ||||
| 		mux_1 { | ||||
| 			pins = "gpio25"; | ||||
| 			function = "pwm2"; | ||||
| 			drive-strength = <8>; | ||||
| 		}; | ||||
| 		mux_2 { | ||||
| 			pins = "gpio26"; | ||||
| 			function = "pwm2"; | ||||
| 			drive-strength = <8>; | ||||
| 		}; | ||||
| 		mux_3 { | ||||
| 			pins = "gpio31"; | ||||
| 			function = "pwm1"; | ||||
| 			drive-strength = <8>; | ||||
| 		}; | ||||
| 	}; | ||||
|  | ||||
| 	sdc_default_state: sdc-default-state { | ||||
|                 clk-pins { | ||||
|                         pins = "gpio13"; | ||||
|                         function = "sdc_clk"; | ||||
|                         drive-strength = <8>; | ||||
|                         bias-disable; | ||||
|                 }; | ||||
|  | ||||
|                 cmd-pins { | ||||
|                         pins = "gpio12"; | ||||
|                         function = "sdc_cmd"; | ||||
|                         drive-strength = <8>; | ||||
|                         bias-pull-up; | ||||
|                 }; | ||||
|  | ||||
|                 data-pins { | ||||
|                         pins = "gpio8", "gpio9", "gpio10", "gpio11"; | ||||
|                         function = "sdc_data"; | ||||
|                         drive-strength = <8>; | ||||
|                         bias-pull-up; | ||||
|                 }; | ||||
|         }; | ||||
|  | ||||
| 	pcie0_default_state: pcie0-default-state { | ||||
| 		pins = "gpio38"; | ||||
| 		function = "gpio"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-up; | ||||
| 		output-low; | ||||
| 	}; | ||||
|  | ||||
| 	pcie1_default_state: pcie1-default-state { | ||||
| 		pins = "gpio47"; | ||||
| 		function = "gpio"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-up; | ||||
| 		output-low; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &license_manager { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &usb3 { | ||||
| 	qcom,select-utmi-as-pipe-clk; | ||||
| 	status = "okay"; | ||||
| 	dwc3@8a00000 { | ||||
|                 /delete-property/ #phy-cells; | ||||
|                 /delete-property/ phys; | ||||
|                 /delete-property/ phy-names; | ||||
|         }; | ||||
| }; | ||||
|  | ||||
| &pwm { | ||||
| 	pinctrl-0 = <&pwm_pins>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	dft-pwm-status = <0>, <0>, <1>, <0>; | ||||
|         poe_type_pin = <&extgpio 0 0 &extgpio 1 0 &extgpio 2 0>; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &hs_m31phy_0 { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| @@ -15,7 +15,7 @@ | ||||
| #include "ipq5332-default-memory.dtsi" | ||||
|  | ||||
| / { | ||||
| 	model = "Sercomm WiFi-7"; | ||||
| 	model = "Sercomm AP72TIP-v4"; | ||||
| 	compatible = "sercomm,ap72tip-v4", "qcom,ipq5332-ap-mi01.6", "qcom,ipq5332"; | ||||
|  | ||||
| 	aliases { | ||||
|   | ||||
| @@ -15,7 +15,7 @@ | ||||
| #include "ipq5332-default-memory.dtsi" | ||||
|  | ||||
| / { | ||||
| 	model = "Sercomm WiFi-7"; | ||||
| 	model = "Sercomm AP72TIP"; | ||||
| 	compatible = "sercomm,ap72tip", "qcom,ipq5332-ap-mi01.6", "qcom,ipq5332"; | ||||
|  | ||||
| 	aliases { | ||||
| @@ -255,7 +255,7 @@ | ||||
| 					gpios = <&tca6416 14 GPIO_ACTIVE_HIGH>; | ||||
| 				}; | ||||
| 		}; | ||||
| /* | ||||
| 		 | ||||
| 		gpio_keys { | ||||
| 			compatible = "gpio-keys"; | ||||
| 			pinctrl-0 = <&button_pins>; | ||||
| @@ -263,11 +263,11 @@ | ||||
| 			button@1 { | ||||
| 				label = "rst"; | ||||
| 				linux,code = <KEY_RESTART>; | ||||
| 				gpios = <&tlmm 25 GPIO_ACTIVE_LOW>; | ||||
| 				gpios = <&tlmm 1 GPIO_ACTIVE_LOW>; | ||||
| 				linux,input-type = <1>; | ||||
| 				debounce-interval = <60>; | ||||
| 			}; | ||||
| 		};*/ | ||||
| 		}; | ||||
|  | ||||
| 		wsi: wsi { | ||||
| 			id = <0>; | ||||
| @@ -546,13 +546,13 @@ | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-down; | ||||
| 	};*/ | ||||
| /* | ||||
| 	 | ||||
| 	button_pins: button-state { | ||||
| 		pins = "gpio25"; | ||||
| 		pins = "gpio1"; | ||||
| 		function = "gpio"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-up; | ||||
| 	};*/ | ||||
| 	}; | ||||
|  | ||||
| 	pwm_pins: pwm-state { | ||||
| 		pins = "gpio46"; | ||||
|   | ||||
							
								
								
									
										687
									
								
								feeds/qca-wifi-7/ipq53xx/dts/ipq5332-sonicfi-rap750e-h.dts
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										687
									
								
								feeds/qca-wifi-7/ipq53xx/dts/ipq5332-sonicfi-rap750e-h.dts
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,687 @@ | ||||
| // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) | ||||
| /* | ||||
|  * IPQ5332 RDP477 board device tree source | ||||
|  * | ||||
|  * Copyright (c) 2020-2021 The Linux Foundation. All rights reserved. | ||||
|  * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. | ||||
|  */ | ||||
|  | ||||
| /dts-v1/; | ||||
|  | ||||
| #include "ipq5332.dtsi" | ||||
| #include <dt-bindings/gpio/gpio.h> | ||||
| #include <dt-bindings/input/input.h> | ||||
| #include <dt-bindings/leds/common.h> | ||||
| #include "ipq5332-default-memory.dtsi" | ||||
|  | ||||
| / { | ||||
| 	model = "SONICFI RAP750E-H"; | ||||
| 	compatible = "sonicfi,rap750e-h","qcom,ipq5332-ap-mi01.3-c2", "qcom,ipq5332"; | ||||
|  | ||||
| #ifdef __IPQ_MEM_PROFILE_512_MB__ | ||||
|        /*	512M Memory Layout for IPQ5332 + QCN6432 | ||||
| 	* +==========+==============+========================+ | ||||
| 	* |         |              |                         | | ||||
| 	* |  Region | Start Offset |          Size           | | ||||
| 	* |         |              |                         | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |   Q6    |              |                         | | ||||
| 	* |  code/  |  0x4A900000  |          20MB           | | ||||
| 	* |  data   |              |                         | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* | IPQ5332 |              |                         | | ||||
| 	* |  data   |  0x4BD00000  |          17MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* | IPQ5332 |              |                         | | ||||
| 	* | M3 Dump |  0x4CE00000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* | IPQ5332 |              |                         | | ||||
| 	* |  QDSS   |  0x4CF00000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |IPQ5332  |              |                         | | ||||
| 	* |  CALDB  |  0x4D000000  |           3MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |  data   |  0x4D300000  |          16MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* | M3 Dump |  0x4E300000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |  QDSS   |  0x4E400000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |  CALDB  |  0x4E500000  |           5MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |MEM_HOLE |  0x4EA00000  |           5MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |         |              |                         | | ||||
| 	* |   MLO   |  0x4EF00000  |          17MB           | | ||||
| 	* +==================================================+ | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* |             Rest of memory for Linux             | | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* +==================================================+ | ||||
| 	*/ | ||||
|  | ||||
| 	reserved-memory { | ||||
|  | ||||
| 		/delete-node/ m3_dump@4cc00000; | ||||
| 		/delete-node/ q6_etr_dump@1; | ||||
| 		/delete-node/ mlo_global_mem_0@0x4db00000; | ||||
| 		/delete-node/ wcnss@4a900000; | ||||
| 		/delete-node/ q6_caldb_region@4ce00000; | ||||
|  | ||||
| 		q6_mem_regions: q6_mem_regions@4A900000  { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4A900000 0x0 0x4600000>; | ||||
| 		}; | ||||
|  | ||||
| 		q6_code_data: q6_code_data@4A900000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4A900000 0x0 0x1400000>; | ||||
| 		}; | ||||
|  | ||||
| 		q6_ipq5332_data: q6_ipq5332_data@4BD00000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4BD00000 0x0 0x1100000>; | ||||
| 		}; | ||||
|  | ||||
| 		m3_dump: m3_dump@4CE00000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4CE00000 0x0 0x100000>; | ||||
| 		}; | ||||
|  | ||||
| 		q6_etr_region: q6_etr_dump@4CF00000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4CF00000 0x0 0x100000>; | ||||
| 		}; | ||||
|  | ||||
| 		q6_ipq5332_caldb: q6_ipq5332_caldb@4D000000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4D000000 0x0 0x300000>; | ||||
| 		}; | ||||
|  | ||||
| 		q6_qcn6432_data_1: q6_qcn6432_data_1@4D300000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4D300000 0x0 0x1000000>; | ||||
| 		}; | ||||
|  | ||||
| 		m3_dump_qcn6432_1: m3_dump_qcn6432_1@4E300000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4E300000 0x0 0x100000>; | ||||
|                 }; | ||||
|  | ||||
| 		q6_qcn6432_etr_1: q6_qcn6432_etr_1@4E400000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4E400000 0x0 0x100000>; | ||||
| 		}; | ||||
|  | ||||
| 		q6_qcn6432_caldb_1: q6_qcn6432_caldb_1@4E500000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4E500000 0x0 0x500000>; | ||||
| 		}; | ||||
|  | ||||
| 		mlo_global_mem0: mlo_global_mem_0@4EF00000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4EF00000 0x0 0x1100000>; | ||||
| 		}; | ||||
| 	}; | ||||
| #else | ||||
|        /*      1G Memory Layout for IPQ5332 + QCN6432 | ||||
| 	* +==========+==============+========================+ | ||||
| 	* |         |              |                         | | ||||
| 	* |  Region | Start Offset |          Size           | | ||||
| 	* |         |              |                         | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |   Q6    |              |                         | | ||||
| 	* |  code/  |  0x4A900000  |          20MB           | | ||||
| 	* |  data   |              |                         | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* | IPQ5332 |              |                         | | ||||
| 	* |  data   |  0x4BD00000  |          21MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* | IPQ5332 |              |                         | | ||||
| 	* | M3 Dump |  0x4D200000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* | IPQ5332 |              |                         | | ||||
| 	* |  QDSS   |  0x4D300000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |IPQ5332  |              |                         | | ||||
| 	* |  CALDB  |  0x4D400000  |           5MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |  data   |  0x4D900000  |          21MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* | M3 Dump |  0x4EE00000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |  QDSS   |  0x4EF00000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |  CALDB  |  0x4F000000  |           5MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |MEM_HOLE |  0x4F500000  |           5MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |         |              |                         | | ||||
| 	* |   MLO   |  0x4FA00000  |          17MB           | | ||||
| 	* +==================================================+ | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* |             Rest of memory for Linux             | | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* +==================================================+ | ||||
| 	*/ | ||||
| 	reserved-memory { | ||||
|  | ||||
| 		/delete-node/ m3_dump@4cc00000; | ||||
| 		/delete-node/ q6_etr_dump@1; | ||||
| 		/delete-node/ mlo_global_mem_0@0x4db00000; | ||||
| 		/delete-node/ wcnss@4a900000; | ||||
| 		/delete-node/ q6_caldb_region@4ce00000; | ||||
|  | ||||
| 		q6_mem_regions: q6_mem_regions@4A900000  { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4A900000 0x0 0x5100000>; | ||||
| 		}; | ||||
| 		q6_code_data: q6_code_data@4A900000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4A900000 0x0 0x1400000>; | ||||
| 		}; | ||||
| 		q6_ipq5332_data: q6_ipq5332_data@4BD00000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4BD00000 0x0 0x1500000>; | ||||
| 		}; | ||||
| 		m3_dump: m3_dump@4D200000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4D200000 0x0 0x100000>; | ||||
| 		}; | ||||
| 		q6_etr_region: q6_etr_dump@4D300000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4D300000 0x0 0x100000>; | ||||
| 		}; | ||||
| 		q6_ipq5332_caldb: q6_ipq5332_caldb@4D400000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4D400000 0x0 0x500000>; | ||||
| 		}; | ||||
| 		q6_qcn6432_data_1: q6_qcn6432_data_1@4D900000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4D900000 0x0 0x1500000>; | ||||
| 		}; | ||||
| 		m3_dump_qcn6432_1: m3_dump_qcn6432_1@4EE00000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4EE00000 0x0 0x100000>; | ||||
| 		}; | ||||
| 		q6_qcn6432_etr_1: q6_qcn6432_etr_1@4EF00000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4EF00000 0x0 0x100000>; | ||||
| 		}; | ||||
| 		q6_qcn6432_caldb_1: q6_qcn6432_caldb_1@4F000000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4F000000 0x0 0x500000>; | ||||
| 		}; | ||||
| 		mlo_global_mem0: mlo_global_mem_0@4FA00000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4FA00000 0x0 0x1100000>; | ||||
| 		}; | ||||
| 	}; | ||||
|  | ||||
| #endif | ||||
| 	aliases { | ||||
| 		serial0 = &blsp1_uart0; | ||||
| 		serial1 = &blsp1_uart1; | ||||
| 		ethernet0 = "/soc/dp1"; | ||||
| 		//ethernet1 = "/soc/dp2"; | ||||
| 		led-boot = &led_power; | ||||
| 		led-failsafe = &led_power; | ||||
| 		led-running = &led_power; | ||||
| 		led-upgrade = &led_power; | ||||
| 	}; | ||||
|  | ||||
| 	chosen { | ||||
| 		stdout-path = "serial0"; | ||||
| 	}; | ||||
|  | ||||
| 	soc@0 { | ||||
| 		mdio:mdio@90000 { | ||||
| 			pinctrl-0 = <&mdio1_pins>; | ||||
| 			pinctrl-names = "default"; | ||||
| 			/*gpio26 for manhattan reset*/ | ||||
| 			phy-reset-gpio = <&tlmm 26 GPIO_ACTIVE_LOW>; | ||||
| 			status = "okay"; | ||||
|  | ||||
| 			phy0: ethernet-phy@0 { | ||||
| 				reg = <16>; | ||||
| 			}; | ||||
| 		}; | ||||
|  | ||||
|  | ||||
| 		gpio_keys { | ||||
| 			compatible = "gpio-keys"; | ||||
| 			pinctrl-0 = <&button_pins>; | ||||
| 			pinctrl-names = "default"; | ||||
| 			status = "okay"; | ||||
|  | ||||
| 			button@1 { | ||||
| 				label = "reset"; | ||||
| 				linux,code = <KEY_RESTART>; | ||||
| 				gpios = <&tlmm 24 GPIO_ACTIVE_LOW>; | ||||
| 				linux,input-type = <1>; | ||||
| 				debounce-interval = <60>; | ||||
| 			}; | ||||
| 		}; | ||||
|  | ||||
| 		pwmleds { | ||||
| 			compatible = "pwm-leds"; | ||||
|  | ||||
| 			red { | ||||
| 				label = "pwm:red"; | ||||
| 				pwms = <&pwm 2 1250000>; | ||||
| 				max-brightness = <255>; | ||||
| 				linux,default-trigger = "none"; | ||||
| 			}; | ||||
| 		 | ||||
| 			green { | ||||
| 				label = "pwm:green"; | ||||
| 				pwms = <&pwm 3 1250000>; | ||||
| 				max-brightness = <255>; | ||||
| 				linux,default-trigger = "none"; | ||||
| 			}; | ||||
| 		 | ||||
| 			led_power: blue { | ||||
| 				label = "pwm:blue"; | ||||
| 				pwms = <&pwm 1 1250000>; | ||||
| 				max-brightness = <255>; | ||||
| 				linux,default-trigger = "none"; | ||||
| 			}; | ||||
|  | ||||
| 			white { | ||||
| 				label = "pwm:white"; | ||||
| 				pwms = <&pwm 0 1250000>; | ||||
| 				max-brightness = <255>; | ||||
| 				linux,default-trigger = "none"; | ||||
| 			};			 | ||||
| 		}; | ||||
|  | ||||
| 		ess-instance { | ||||
| 			num_devices = <0x1>; | ||||
|  | ||||
| 			ess-switch@3a000000 { | ||||
| 				switch_cpu_bmp = <0x1>;  /* cpu port bitmap */ | ||||
| 				switch_lan_bmp = <0x4>; /* lan port bitmap */ | ||||
| 				switch_wan_bmp = <0x0>; /* wan port bitmap */ | ||||
| 				switch_mac_mode = <0xff>; /* mac mode for uniphy instance0*/ | ||||
| 				switch_mac_mode1 = <0xf>; /* mac mode for uniphy instance1*/ | ||||
| 				switch_mac_mode2 = <0xff>; /* mac mode for uniphy instance2*/ | ||||
|  | ||||
| 				qcom,port_phyinfo { | ||||
| 					port@1 { | ||||
| 						port_id = <2>; | ||||
| 						phy_address = <16>; | ||||
| 					}; | ||||
| 				}; | ||||
| 			}; | ||||
| 		}; | ||||
|  | ||||
| 		dp1 { | ||||
| 			device_type = "network"; | ||||
| 			compatible = "qcom,nss-dp"; | ||||
| 			qcom,id = <2>; | ||||
| 			reg = <0x3a504000 0x4000>; | ||||
| 			qcom,mactype = <1>; | ||||
| 			local-mac-address = [000000000000]; | ||||
| 			mdio-bus = <&mdio>; | ||||
| 			qcom,phy-mdio-addr = <16>; | ||||
| 			qcom,link-poll = <1>; | ||||
| 			phy-mode = "sgmii"; | ||||
| 		}; | ||||
|  | ||||
| 		/* EDMA host driver configuration for the board */ | ||||
| 		edma@3ab00000 { | ||||
| 			qcom,txdesc-ring-start = <4>;		/* Tx desc ring start ID */ | ||||
| 			qcom,txdesc-rings = <12>;		/* Total number of Tx desc rings to be provisioned */ | ||||
| 			qcom,mht-txdesc-rings = <8>;            /* Extra Tx desc rings to be provisioned for MHT SW ports */ | ||||
| 			qcom,txcmpl-ring-start = <4>;		/* Tx complete ring start ID */ | ||||
| 			qcom,txcmpl-rings = <12>;		/* Total number of Tx complete rings to be provisioned */ | ||||
| 			qcom,mht-txcmpl-rings = <8>;            /* Extra Tx complete rings to be provisioned for mht sw ports. */ | ||||
| 			qcom,rxfill-ring-start = <4>;		/* Rx fill ring start ID */ | ||||
| 			qcom,rxfill-rings = <4>;		/* Total number of Rx fill rings to be provisioned */ | ||||
| 			qcom,rxdesc-ring-start = <12>;		/* Rx desc ring start ID */ | ||||
| 			qcom,rxdesc-rings = <4>;		/* Total number of Rx desc rings to be provisioned */ | ||||
| 			qcom,rx-page-mode = <0>;		/* Rx fill ring page mode */ | ||||
| 			qcom,tx-map-priority-level = <1>;	/* Tx priority level per port */ | ||||
| 			qcom,rx-map-priority-level = <1>;	/* Rx priority level per core */ | ||||
| 			qcom,ppeds-num = <2>;			/* Number of PPEDS nodes */ | ||||
| 			/* PPE-DS node format: <Rx-fill Tx-cmpl Rx Tx Queue-base Queue-count> */ | ||||
| 			qcom,ppeds-map = <1 1 1 1 32 8>,	/* PPEDS Node#0 ring and queue map */ | ||||
| 					<2 2 2 2 40 8>;		/* PPEDS Node#1 ring and queue map */ | ||||
| 			qcom,txdesc-map = <8 9 10 11>,		/* Port0 per-core Tx ring map */ | ||||
| 					  <12 13 14 15>,        /* MHT-Port1 per-core Tx ring map */ | ||||
| 					  <4 5 6 7>,            /* MHT-Port2 per-core Tx ring map/packets from  vp*/ | ||||
| 					  <16 17 18 19>,        /* MHT-Port3 per-core Tx ring map */ | ||||
| 					  <20 21 22 23>;        /* MHT-Port4 per-core Tx ring map */ | ||||
| 			qcom,txdesc-fc-grp-map = <1 2 3 4 5>;   /* Per GMAC flow control group map */ | ||||
| 			qcom,rxfill-map = <4 5 6 7>;		/* Per-core Rx fill ring map */ | ||||
| 			qcom,rxdesc-map = <12 13 14 15>;	/* Per-core Rx desc ring map */ | ||||
| 			qcom,rx-queue-start = <0>;		/* Rx queue start */ | ||||
| 			qcom,rx-ring-queue-map = <0 8 16 24>,	/* Priority 0 queues per-core Rx ring map */ | ||||
| 						<1 9 17 25>,	/* Priority 1 queues per-core Rx ring map */ | ||||
| 						<2 10 18 26>,	/* Priority 2 queues per-core Rx ring map */ | ||||
| 						<3 11 19 27>,	/* Priority 3 queues per-core Rx ring map */ | ||||
| 						<4 12 20 28>,	/* Priority 4 queues per-core Rx ring map */ | ||||
| 						<5 13 21 29>,	/* Priority 5 queues per-core Rx ring map */ | ||||
| 						<6 14 22 30>,	/* Priority 6 queues per-core Rx ring map */ | ||||
| 						<7 15 23 31>;	/* Priority 7 queues per-core Rx ring map */ | ||||
| 			interrupts = <0 163 4>,			/* Tx complete ring id #4 IRQ info */ | ||||
| 				   <0 164 4>,			/* Tx complete ring id #5 IRQ info */ | ||||
| 				   <0 165 4>,			/* Tx complete ring id #6 IRQ info */ | ||||
| 				   <0 166 4>,			/* Tx complete ring id #7 IRQ info */ | ||||
| 				   <0 167 4>,			/* Tx complete ring id #8 IRQ info */ | ||||
| 				   <0 168 4>,			/* Tx complete ring id #9 IRQ info */ | ||||
| 				   <0 169 4>,			/* Tx complete ring id #10 IRQ info */ | ||||
| 				   <0 170 4>,			/* Tx complete ring id #11 IRQ info */ | ||||
| 				   <0 171 4>,			/* Tx complete ring id #12 IRQ info */ | ||||
| 				   <0 172 4>,			/* Tx complete ring id #13 IRQ info */ | ||||
| 				   <0 173 4>,			/* Tx complete ring id #14 IRQ info */ | ||||
| 				   <0 174 4>,			/* Tx complete ring id #15 IRQ info */ | ||||
| 				   <0 139 4>,			/* Rx desc ring id #12 IRQ info */ | ||||
| 				   <0 140 4>,			/* Rx desc ring id #13 IRQ info */ | ||||
| 				   <0 141 4>,			/* Rx desc ring id #14 IRQ info */ | ||||
| 				   <0 142 4>,			/* Rx desc ring id #15 IRQ info */ | ||||
| 				   <0 191 4>,			/* Misc error IRQ info */ | ||||
| 				<0 160 4>,			/* PPEDS Node #1(TxComp ring id #1) TxComplete IRQ info */ | ||||
| 				<0 128 4>,			/* PPEDS Node #1(Rx Desc ring id #1) Rx Desc IRQ info */ | ||||
| 				<0 152 4>,			/* PPEDS Node #1(RxFill Desc ring id #1) Rx Fill IRQ info */ | ||||
| 				<0 161 4>,			/* PPEDS Node #2(TxComp ring id #2) TxComplete IRQ info */ | ||||
| 				<0 129 4>,			/* PPEDS Node #2(Rx Desc ring id #2) Rx Desc IRQ info */ | ||||
| 				<0 153 4>,                      /* PPEDS Node #2(RxFill Desc ring id #2) Rx Fill IRQ info */ | ||||
| 				<0 175 4>,                   /* MHT port Tx complete ring id #16 IRQ info */ | ||||
| 				<0 176 4>,                   /* MHT port Tx complete ring id #17 IRQ info */ | ||||
| 				<0 177 4>,                   /* MHT port Tx complete ring id #18 IRQ info */ | ||||
| 				<0 178 4>,                   /* MHT port Tx complete ring id #19 IRQ info */ | ||||
| 				<0 179 4>,                   /* MHT port Tx complete ring id #20 IRQ info */ | ||||
| 				<0 180 4>,                   /* MHT port Tx complete ring id #21 IRQ info */ | ||||
| 				<0 181 4>,                   /* MHT port Tx complete ring id #22 IRQ info */ | ||||
| 				<0 182 4>;                   /* MHT port Tx complete ring id #23 IRQ info */ | ||||
| 		}; | ||||
|  | ||||
| 		wsi: wsi { | ||||
| 			id = <0>; | ||||
| 			num_chip = <2>; | ||||
| 			status = "okay"; | ||||
| 			chip_info = <0 1 1>, | ||||
| 				<1 1 0>; | ||||
| 		}; | ||||
|  | ||||
| 		q6v5_wcss: remoteproc@d100000 { | ||||
| 			boot-args = <0x1 0x4 0x3 0x0 0x26 0x2>; | ||||
| 			memory-region = <&q6_mem_regions>; | ||||
|  | ||||
| 			q6_wcss_pd1: remoteproc_pd1 { | ||||
| 				status = "okay"; | ||||
| 			}; | ||||
|  | ||||
| 			q6_wcss_pd2: remoteproc_pd2 { | ||||
| 				compatible = "qcom,ipq5332-wcss-pcie-mpd"; | ||||
| 				firmware = "IPQ5332/q6_fw2.mdt"; | ||||
| 				m3_firmware = "qcn6432/iu_fw.mdt"; | ||||
| 				interrupts-extended = <&wcss_smp2p_in 16 0>, | ||||
| 						<&wcss_smp2p_in 17 0>, | ||||
| 						<&wcss_smp2p_in 20 0>, | ||||
| 						<&wcss_smp2p_in 19 0>; | ||||
| 				interrupt-names = "fatal", | ||||
| 						"ready", | ||||
| 						"spawn-ack", | ||||
| 						"stop-ack"; | ||||
| 				qcom,smem-states = <&wcss_smp2p_out 16>, | ||||
| 						<&wcss_smp2p_out 17>, | ||||
| 						<&wcss_smp2p_out 18>; | ||||
| 				qcom,smem-state-names = "shutdown", | ||||
| 							"stop", | ||||
| 							"spawn"; | ||||
| 				status = "okay"; | ||||
| 			}; | ||||
| 		}; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &blsp1_uart0 { | ||||
| 	pinctrl-0 = <&serial_0_pins>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "okay"; | ||||
| }; | ||||
| /* | ||||
| &blsp1_uart1 { | ||||
|         pinctrl-0 = <&serial_1_pins>; | ||||
|         pinctrl-names = "default"; | ||||
|         status = "disabled"; | ||||
| }; | ||||
| */ | ||||
| &blsp1_i2c1 { | ||||
| 	clock-frequency  = <400000>; | ||||
| 	pinctrl-0 = <&i2c_1_pins>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &blsp1_spi0 { | ||||
| 	status = "disabled"; | ||||
| }; | ||||
|  | ||||
| &sdhc { | ||||
| 	bus-width = <4>; | ||||
| 	max-frequency = <192000000>; | ||||
| 	mmc-ddr-1_8v; | ||||
| 	mmc-hs200-1_8v; | ||||
| 	non-removable; | ||||
| 	pinctrl-0 = <&sdc_default_state>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "disabled"; | ||||
| }; | ||||
|  | ||||
| &sleep_clk { | ||||
| 	clock-frequency = <32000>; | ||||
| }; | ||||
|  | ||||
| &xo { | ||||
| 	clock-frequency = <24000000>; | ||||
| }; | ||||
|  | ||||
| &qpic_bam { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &qpic_nand { | ||||
| 	pinctrl-0 = <&qspi_default_state>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "okay"; | ||||
|  | ||||
| 	nandcs@0 { | ||||
| 		reg = <0>; | ||||
| 		#address-cells = <1>; | ||||
| 		#size-cells = <1>; | ||||
|  | ||||
| 		nand-ecc-strength = <8>; | ||||
| 		nand-ecc-step-size = <512>; | ||||
| 		nand-bus-width = <8>; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| /* PINCTRL */ | ||||
|  | ||||
| &tlmm { | ||||
| 	qspi_default_state: qspi-default-state { | ||||
| 		qspi_clock { | ||||
| 			pins = "gpio13"; | ||||
| 			function = "qspi_clk"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-down; | ||||
| 		}; | ||||
|  | ||||
| 		qspi_cs { | ||||
| 			pins = "gpio12"; | ||||
| 			function = "qspi_cs"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-up; | ||||
| 		}; | ||||
|  | ||||
| 		qspi_data { | ||||
| 			pins = "gpio8", "gpio9", "gpio10", "gpio11"; | ||||
| 			function = "qspi_data"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-down; | ||||
| 		}; | ||||
| 	}; | ||||
|  | ||||
| 	pwm_pins: pwm_pinmux { | ||||
| 			/* PWM LED GREEN */ | ||||
| 			mux_1 { | ||||
| 				pins = "gpio43"; | ||||
| 				function = "pwm0"; | ||||
| 				drive-strength = <8>; | ||||
| 			}; | ||||
| 			/* PWM LED BLUE */ | ||||
| 			mux_2 { | ||||
| 				pins = "gpio45"; | ||||
| 				function = "pwm0"; | ||||
| 				drive-strength = <8>; | ||||
| 			}; | ||||
| 			/* PWM LED RED */ | ||||
| 			mux_3 { | ||||
| 				pins = "gpio44"; | ||||
| 				function = "pwm0"; | ||||
| 				drive-strength = <8>; | ||||
| 			}; | ||||
| 			/* PWM LED WHITE */ | ||||
| 			mux_4 { | ||||
| 				pins = "gpio46"; | ||||
| 				function = "pwm0"; | ||||
| 				drive-strength = <8>; | ||||
| 			}; | ||||
| 	}; | ||||
| /* | ||||
| 	serial_1_pins: serial1-pinmux { | ||||
| 		pins = "gpio33", "gpio34", "gpio35", "gpio36"; | ||||
| 		function = "blsp1_uart2"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-up; | ||||
| 	}; | ||||
| */ | ||||
| 	i2c_1_pins: i2c-1-state { | ||||
| 		pins = "gpio29", "gpio30"; | ||||
| 		function = "blsp1_i2c0"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-up; | ||||
| 	}; | ||||
| /* | ||||
| 	gpio_leds_default: gpio-leds-default-state { | ||||
| 		pins = "gpio36"; | ||||
| 		function = "gpio"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-down; | ||||
| 	};  | ||||
| */ | ||||
| 	button_pins: button-state { | ||||
| 		pins = "gpio24"; | ||||
| 		function = "gpio"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-up; | ||||
| 	}; | ||||
|  | ||||
| 	sdc_default_state: sdc-default-state { | ||||
| 		clk-pins { | ||||
| 			pins = "gpio13"; | ||||
| 			function = "sdc_clk"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-disable; | ||||
| 		}; | ||||
|  | ||||
| 		cmd-pins { | ||||
| 			pins = "gpio12"; | ||||
| 			function = "sdc_cmd"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-up; | ||||
| 		}; | ||||
|  | ||||
| 		data-pins { | ||||
| 			pins = "gpio8", "gpio9", "gpio10", "gpio11"; | ||||
| 			function = "sdc_data"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-up; | ||||
| 		}; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &license_manager { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &usb3 { | ||||
| 	qcom,select-utmi-as-pipe-clk; | ||||
| 	status = "disabled"; | ||||
| }; | ||||
|  | ||||
| &pwm { | ||||
| 	pinctrl-0 = <&pwm_pins>; | ||||
| 	used-pwm-indices = <1>, <1>, <1>, <1>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &hs_m31phy_0 { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &wifi0 { | ||||
| 	qcom,multipd_arch; | ||||
| 	qcom,rproc = <&q6_wcss_pd1>; | ||||
| 	qcom,rproc_rpd = <&q6v5_wcss>; | ||||
| 	qcom,userpd-subsys-name = "q6v5_wcss_userpd1"; | ||||
| 	qcom,bdf-addr = <0x4BD00000 0x4BD00000 0x0 0x0 0x0 0x0>; | ||||
| 	qcom,caldb-addr = <0x4D400000 0x4D000000 0x0 0x0 0x0 0x0>; | ||||
| #ifdef __IPQ_MEM_PROFILE_512_MB__ | ||||
| 	qcom,tgt-mem-mode = <1>; | ||||
| 	qcom,caldb-size = <0x300000>; | ||||
| #else | ||||
| 	qcom,tgt-mem-mode = <0>; | ||||
| 	qcom,caldb-size = <0x500000>; | ||||
| #endif | ||||
| 	qcom,board_id = <0x1b>; | ||||
| 	memory-region = <&q6_ipq5332_data>; | ||||
| 	qcom,wsi = <&wsi>; | ||||
| 	qcom,wsi_index = <0>; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &wifi1 { | ||||
| 	qcom,multipd_arch; | ||||
| 	qcom,rproc = <&q6_wcss_pd2>; | ||||
| 	qcom,rproc_rpd = <&q6v5_wcss>; | ||||
| 	qcom,userpd-subsys-name = "q6v5_wcss_userpd2"; | ||||
| 	qcom,bdf-addr = <0x4D900000 0x4D300000 0x0 0x0 0x0 0x0>; | ||||
| 	qcom,caldb-addr = <0x4F000000 0x4E500000 0x0 0x0 0x0 0x0>; | ||||
| 	qcom,umac-irq-reset-addr = <0x20000884>; | ||||
| 	qcom,caldb-size = <0x500000>; | ||||
| #ifdef __IPQ_MEM_PROFILE_512_MB__ | ||||
| 	qcom,tgt-mem-mode = <1>; | ||||
| #else | ||||
| 	qcom,tgt-mem-mode = <0>; | ||||
| #endif | ||||
| 	qcom,board_id = <0x060>; | ||||
| 	memory-region = <&q6_qcn6432_data_1>; | ||||
| 	qcom,wsi = <&wsi>; | ||||
| 	qcom,wsi_index = <1>; | ||||
| 	status = "okay"; | ||||
| 	interrupts = <GIC_SPI 33 IRQ_TYPE_EDGE_RISING>; | ||||
| 	interrupt-names = "umac_reset"; | ||||
| }; | ||||
							
								
								
									
										687
									
								
								feeds/qca-wifi-7/ipq53xx/dts/ipq5332-sonicfi-rap750e-s.dts
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										687
									
								
								feeds/qca-wifi-7/ipq53xx/dts/ipq5332-sonicfi-rap750e-s.dts
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,687 @@ | ||||
| // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) | ||||
| /* | ||||
|  * IPQ5332 RDP477 board device tree source | ||||
|  * | ||||
|  * Copyright (c) 2020-2021 The Linux Foundation. All rights reserved. | ||||
|  * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. | ||||
|  */ | ||||
|  | ||||
| /dts-v1/; | ||||
|  | ||||
| #include "ipq5332.dtsi" | ||||
| #include <dt-bindings/gpio/gpio.h> | ||||
| #include <dt-bindings/input/input.h> | ||||
| #include <dt-bindings/leds/common.h> | ||||
| #include "ipq5332-default-memory.dtsi" | ||||
|  | ||||
| / { | ||||
| 	model = "SONICFI RAP750E-S"; | ||||
| 	compatible = "sonicfi,rap750e-s","qcom,ipq5332-ap-mi01.3-c2", "qcom,ipq5332"; | ||||
|  | ||||
| #ifdef __IPQ_MEM_PROFILE_512_MB__ | ||||
|        /*	512M Memory Layout for IPQ5332 + QCN6432 | ||||
| 	* +==========+==============+========================+ | ||||
| 	* |         |              |                         | | ||||
| 	* |  Region | Start Offset |          Size           | | ||||
| 	* |         |              |                         | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |   Q6    |              |                         | | ||||
| 	* |  code/  |  0x4A900000  |          20MB           | | ||||
| 	* |  data   |              |                         | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* | IPQ5332 |              |                         | | ||||
| 	* |  data   |  0x4BD00000  |          17MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* | IPQ5332 |              |                         | | ||||
| 	* | M3 Dump |  0x4CE00000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* | IPQ5332 |              |                         | | ||||
| 	* |  QDSS   |  0x4CF00000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |IPQ5332  |              |                         | | ||||
| 	* |  CALDB  |  0x4D000000  |           3MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |  data   |  0x4D300000  |          16MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* | M3 Dump |  0x4E300000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |  QDSS   |  0x4E400000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |  CALDB  |  0x4E500000  |           5MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |MEM_HOLE |  0x4EA00000  |           5MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |         |              |                         | | ||||
| 	* |   MLO   |  0x4EF00000  |          17MB           | | ||||
| 	* +==================================================+ | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* |             Rest of memory for Linux             | | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* +==================================================+ | ||||
| 	*/ | ||||
|  | ||||
| 	reserved-memory { | ||||
|  | ||||
| 		/delete-node/ m3_dump@4cc00000; | ||||
| 		/delete-node/ q6_etr_dump@1; | ||||
| 		/delete-node/ mlo_global_mem_0@0x4db00000; | ||||
| 		/delete-node/ wcnss@4a900000; | ||||
| 		/delete-node/ q6_caldb_region@4ce00000; | ||||
|  | ||||
| 		q6_mem_regions: q6_mem_regions@4A900000  { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4A900000 0x0 0x4600000>; | ||||
| 		}; | ||||
|  | ||||
| 		q6_code_data: q6_code_data@4A900000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4A900000 0x0 0x1400000>; | ||||
| 		}; | ||||
|  | ||||
| 		q6_ipq5332_data: q6_ipq5332_data@4BD00000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4BD00000 0x0 0x1100000>; | ||||
| 		}; | ||||
|  | ||||
| 		m3_dump: m3_dump@4CE00000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4CE00000 0x0 0x100000>; | ||||
| 		}; | ||||
|  | ||||
| 		q6_etr_region: q6_etr_dump@4CF00000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4CF00000 0x0 0x100000>; | ||||
| 		}; | ||||
|  | ||||
| 		q6_ipq5332_caldb: q6_ipq5332_caldb@4D000000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4D000000 0x0 0x300000>; | ||||
| 		}; | ||||
|  | ||||
| 		q6_qcn6432_data_1: q6_qcn6432_data_1@4D300000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4D300000 0x0 0x1000000>; | ||||
| 		}; | ||||
|  | ||||
| 		m3_dump_qcn6432_1: m3_dump_qcn6432_1@4E300000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4E300000 0x0 0x100000>; | ||||
|                 }; | ||||
|  | ||||
| 		q6_qcn6432_etr_1: q6_qcn6432_etr_1@4E400000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4E400000 0x0 0x100000>; | ||||
| 		}; | ||||
|  | ||||
| 		q6_qcn6432_caldb_1: q6_qcn6432_caldb_1@4E500000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4E500000 0x0 0x500000>; | ||||
| 		}; | ||||
|  | ||||
| 		mlo_global_mem0: mlo_global_mem_0@4EF00000 { | ||||
| 			no-map; | ||||
| 			reg = <0x0 0x4EF00000 0x0 0x1100000>; | ||||
| 		}; | ||||
| 	}; | ||||
| #else | ||||
|        /*      1G Memory Layout for IPQ5332 + QCN6432 | ||||
| 	* +==========+==============+========================+ | ||||
| 	* |         |              |                         | | ||||
| 	* |  Region | Start Offset |          Size           | | ||||
| 	* |         |              |                         | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |   Q6    |              |                         | | ||||
| 	* |  code/  |  0x4A900000  |          20MB           | | ||||
| 	* |  data   |              |                         | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* | IPQ5332 |              |                         | | ||||
| 	* |  data   |  0x4BD00000  |          21MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* | IPQ5332 |              |                         | | ||||
| 	* | M3 Dump |  0x4D200000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* | IPQ5332 |              |                         | | ||||
| 	* |  QDSS   |  0x4D300000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |IPQ5332  |              |                         | | ||||
| 	* |  CALDB  |  0x4D400000  |           5MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |  data   |  0x4D900000  |          21MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* | M3 Dump |  0x4EE00000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |  QDSS   |  0x4EF00000  |           1MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |  CALDB  |  0x4F000000  |           5MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |QCN6432_1|              |                         | | ||||
| 	* |MEM_HOLE |  0x4F500000  |           5MB           | | ||||
| 	* +---------+--------------+-------------------------+ | ||||
| 	* |         |              |                         | | ||||
| 	* |   MLO   |  0x4FA00000  |          17MB           | | ||||
| 	* +==================================================+ | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* |             Rest of memory for Linux             | | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* |                                                  | | ||||
| 	* +==================================================+ | ||||
| 	*/ | ||||
| 	reserved-memory { | ||||
|  | ||||
| 		/delete-node/ m3_dump@4cc00000; | ||||
| 		/delete-node/ q6_etr_dump@1; | ||||
| 		/delete-node/ mlo_global_mem_0@0x4db00000; | ||||
| 		/delete-node/ wcnss@4a900000; | ||||
| 		/delete-node/ q6_caldb_region@4ce00000; | ||||
|  | ||||
| 		q6_mem_regions: q6_mem_regions@4A900000  { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4A900000 0x0 0x5100000>; | ||||
| 		}; | ||||
| 		q6_code_data: q6_code_data@4A900000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4A900000 0x0 0x1400000>; | ||||
| 		}; | ||||
| 		q6_ipq5332_data: q6_ipq5332_data@4BD00000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4BD00000 0x0 0x1500000>; | ||||
| 		}; | ||||
| 		m3_dump: m3_dump@4D200000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4D200000 0x0 0x100000>; | ||||
| 		}; | ||||
| 		q6_etr_region: q6_etr_dump@4D300000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4D300000 0x0 0x100000>; | ||||
| 		}; | ||||
| 		q6_ipq5332_caldb: q6_ipq5332_caldb@4D400000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4D400000 0x0 0x500000>; | ||||
| 		}; | ||||
| 		q6_qcn6432_data_1: q6_qcn6432_data_1@4D900000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4D900000 0x0 0x1500000>; | ||||
| 		}; | ||||
| 		m3_dump_qcn6432_1: m3_dump_qcn6432_1@4EE00000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4EE00000 0x0 0x100000>; | ||||
| 		}; | ||||
| 		q6_qcn6432_etr_1: q6_qcn6432_etr_1@4EF00000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4EF00000 0x0 0x100000>; | ||||
| 		}; | ||||
| 		q6_qcn6432_caldb_1: q6_qcn6432_caldb_1@4F000000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4F000000 0x0 0x500000>; | ||||
| 		}; | ||||
| 		mlo_global_mem0: mlo_global_mem_0@4FA00000 { | ||||
| 		        no-map; | ||||
| 		        reg = <0x0 0x4FA00000 0x0 0x1100000>; | ||||
| 		}; | ||||
| 	}; | ||||
|  | ||||
| #endif | ||||
| 	aliases { | ||||
| 		serial0 = &blsp1_uart0; | ||||
| 		serial1 = &blsp1_uart1; | ||||
| 		ethernet0 = "/soc/dp1"; | ||||
| 		//ethernet1 = "/soc/dp2"; | ||||
| 		led-boot = &led_power; | ||||
| 		led-failsafe = &led_power; | ||||
| 		led-running = &led_power; | ||||
| 		led-upgrade = &led_power; | ||||
| 	}; | ||||
|  | ||||
| 	chosen { | ||||
| 		stdout-path = "serial0"; | ||||
| 	}; | ||||
|  | ||||
| 	soc@0 { | ||||
| 		mdio:mdio@90000 { | ||||
| 			pinctrl-0 = <&mdio1_pins>; | ||||
| 			pinctrl-names = "default"; | ||||
| 			/*gpio26 for manhattan reset*/ | ||||
| 			phy-reset-gpio = <&tlmm 26 GPIO_ACTIVE_LOW>; | ||||
| 			status = "okay"; | ||||
|  | ||||
| 			phy0: ethernet-phy@0 { | ||||
| 				reg = <16>; | ||||
| 			}; | ||||
| 		}; | ||||
|  | ||||
|  | ||||
| 		gpio_keys { | ||||
| 			compatible = "gpio-keys"; | ||||
| 			pinctrl-0 = <&button_pins>; | ||||
| 			pinctrl-names = "default"; | ||||
| 			status = "okay"; | ||||
|  | ||||
| 			button@1 { | ||||
| 				label = "reset"; | ||||
| 				linux,code = <KEY_RESTART>; | ||||
| 				gpios = <&tlmm 24 GPIO_ACTIVE_LOW>; | ||||
| 				linux,input-type = <1>; | ||||
| 				debounce-interval = <60>; | ||||
| 			}; | ||||
| 		}; | ||||
|  | ||||
| 		pwmleds { | ||||
| 			compatible = "pwm-leds"; | ||||
|  | ||||
| 			red { | ||||
| 				label = "pwm:red"; | ||||
| 				pwms = <&pwm 2 1250000>; | ||||
| 				max-brightness = <255>; | ||||
| 				linux,default-trigger = "none"; | ||||
| 			}; | ||||
| 		 | ||||
| 			green { | ||||
| 				label = "pwm:green"; | ||||
| 				pwms = <&pwm 3 1250000>; | ||||
| 				max-brightness = <255>; | ||||
| 				linux,default-trigger = "none"; | ||||
| 			}; | ||||
| 		 | ||||
| 			led_power: blue { | ||||
| 				label = "pwm:blue"; | ||||
| 				pwms = <&pwm 1 1250000>; | ||||
| 				max-brightness = <255>; | ||||
| 				linux,default-trigger = "none"; | ||||
| 			}; | ||||
|  | ||||
| 			white { | ||||
| 				label = "pwm:white"; | ||||
| 				pwms = <&pwm 0 1250000>; | ||||
| 				max-brightness = <255>; | ||||
| 				linux,default-trigger = "none"; | ||||
| 			};			 | ||||
| 		}; | ||||
|  | ||||
| 		ess-instance { | ||||
| 			num_devices = <0x1>; | ||||
|  | ||||
| 			ess-switch@3a000000 { | ||||
| 				switch_cpu_bmp = <0x1>;  /* cpu port bitmap */ | ||||
| 				switch_lan_bmp = <0x4>; /* lan port bitmap */ | ||||
| 				switch_wan_bmp = <0x0>; /* wan port bitmap */ | ||||
| 				switch_mac_mode = <0xff>; /* mac mode for uniphy instance0*/ | ||||
| 				switch_mac_mode1 = <0xf>; /* mac mode for uniphy instance1*/ | ||||
| 				switch_mac_mode2 = <0xff>; /* mac mode for uniphy instance2*/ | ||||
|  | ||||
| 				qcom,port_phyinfo { | ||||
| 					port@1 { | ||||
| 						port_id = <2>; | ||||
| 						phy_address = <16>; | ||||
| 					}; | ||||
| 				}; | ||||
| 			}; | ||||
| 		}; | ||||
|  | ||||
| 		dp1 { | ||||
| 			device_type = "network"; | ||||
| 			compatible = "qcom,nss-dp"; | ||||
| 			qcom,id = <2>; | ||||
| 			reg = <0x3a504000 0x4000>; | ||||
| 			qcom,mactype = <1>; | ||||
| 			local-mac-address = [000000000000]; | ||||
| 			mdio-bus = <&mdio>; | ||||
| 			qcom,phy-mdio-addr = <16>; | ||||
| 			qcom,link-poll = <1>; | ||||
| 			phy-mode = "sgmii"; | ||||
| 		}; | ||||
|  | ||||
| 		/* EDMA host driver configuration for the board */ | ||||
| 		edma@3ab00000 { | ||||
| 			qcom,txdesc-ring-start = <4>;		/* Tx desc ring start ID */ | ||||
| 			qcom,txdesc-rings = <12>;		/* Total number of Tx desc rings to be provisioned */ | ||||
| 			qcom,mht-txdesc-rings = <8>;            /* Extra Tx desc rings to be provisioned for MHT SW ports */ | ||||
| 			qcom,txcmpl-ring-start = <4>;		/* Tx complete ring start ID */ | ||||
| 			qcom,txcmpl-rings = <12>;		/* Total number of Tx complete rings to be provisioned */ | ||||
| 			qcom,mht-txcmpl-rings = <8>;            /* Extra Tx complete rings to be provisioned for mht sw ports. */ | ||||
| 			qcom,rxfill-ring-start = <4>;		/* Rx fill ring start ID */ | ||||
| 			qcom,rxfill-rings = <4>;		/* Total number of Rx fill rings to be provisioned */ | ||||
| 			qcom,rxdesc-ring-start = <12>;		/* Rx desc ring start ID */ | ||||
| 			qcom,rxdesc-rings = <4>;		/* Total number of Rx desc rings to be provisioned */ | ||||
| 			qcom,rx-page-mode = <0>;		/* Rx fill ring page mode */ | ||||
| 			qcom,tx-map-priority-level = <1>;	/* Tx priority level per port */ | ||||
| 			qcom,rx-map-priority-level = <1>;	/* Rx priority level per core */ | ||||
| 			qcom,ppeds-num = <2>;			/* Number of PPEDS nodes */ | ||||
| 			/* PPE-DS node format: <Rx-fill Tx-cmpl Rx Tx Queue-base Queue-count> */ | ||||
| 			qcom,ppeds-map = <1 1 1 1 32 8>,	/* PPEDS Node#0 ring and queue map */ | ||||
| 					<2 2 2 2 40 8>;		/* PPEDS Node#1 ring and queue map */ | ||||
| 			qcom,txdesc-map = <8 9 10 11>,		/* Port0 per-core Tx ring map */ | ||||
| 					  <12 13 14 15>,        /* MHT-Port1 per-core Tx ring map */ | ||||
| 					  <4 5 6 7>,            /* MHT-Port2 per-core Tx ring map/packets from  vp*/ | ||||
| 					  <16 17 18 19>,        /* MHT-Port3 per-core Tx ring map */ | ||||
| 					  <20 21 22 23>;        /* MHT-Port4 per-core Tx ring map */ | ||||
| 			qcom,txdesc-fc-grp-map = <1 2 3 4 5>;   /* Per GMAC flow control group map */ | ||||
| 			qcom,rxfill-map = <4 5 6 7>;		/* Per-core Rx fill ring map */ | ||||
| 			qcom,rxdesc-map = <12 13 14 15>;	/* Per-core Rx desc ring map */ | ||||
| 			qcom,rx-queue-start = <0>;		/* Rx queue start */ | ||||
| 			qcom,rx-ring-queue-map = <0 8 16 24>,	/* Priority 0 queues per-core Rx ring map */ | ||||
| 						<1 9 17 25>,	/* Priority 1 queues per-core Rx ring map */ | ||||
| 						<2 10 18 26>,	/* Priority 2 queues per-core Rx ring map */ | ||||
| 						<3 11 19 27>,	/* Priority 3 queues per-core Rx ring map */ | ||||
| 						<4 12 20 28>,	/* Priority 4 queues per-core Rx ring map */ | ||||
| 						<5 13 21 29>,	/* Priority 5 queues per-core Rx ring map */ | ||||
| 						<6 14 22 30>,	/* Priority 6 queues per-core Rx ring map */ | ||||
| 						<7 15 23 31>;	/* Priority 7 queues per-core Rx ring map */ | ||||
| 			interrupts = <0 163 4>,			/* Tx complete ring id #4 IRQ info */ | ||||
| 				   <0 164 4>,			/* Tx complete ring id #5 IRQ info */ | ||||
| 				   <0 165 4>,			/* Tx complete ring id #6 IRQ info */ | ||||
| 				   <0 166 4>,			/* Tx complete ring id #7 IRQ info */ | ||||
| 				   <0 167 4>,			/* Tx complete ring id #8 IRQ info */ | ||||
| 				   <0 168 4>,			/* Tx complete ring id #9 IRQ info */ | ||||
| 				   <0 169 4>,			/* Tx complete ring id #10 IRQ info */ | ||||
| 				   <0 170 4>,			/* Tx complete ring id #11 IRQ info */ | ||||
| 				   <0 171 4>,			/* Tx complete ring id #12 IRQ info */ | ||||
| 				   <0 172 4>,			/* Tx complete ring id #13 IRQ info */ | ||||
| 				   <0 173 4>,			/* Tx complete ring id #14 IRQ info */ | ||||
| 				   <0 174 4>,			/* Tx complete ring id #15 IRQ info */ | ||||
| 				   <0 139 4>,			/* Rx desc ring id #12 IRQ info */ | ||||
| 				   <0 140 4>,			/* Rx desc ring id #13 IRQ info */ | ||||
| 				   <0 141 4>,			/* Rx desc ring id #14 IRQ info */ | ||||
| 				   <0 142 4>,			/* Rx desc ring id #15 IRQ info */ | ||||
| 				   <0 191 4>,			/* Misc error IRQ info */ | ||||
| 				<0 160 4>,			/* PPEDS Node #1(TxComp ring id #1) TxComplete IRQ info */ | ||||
| 				<0 128 4>,			/* PPEDS Node #1(Rx Desc ring id #1) Rx Desc IRQ info */ | ||||
| 				<0 152 4>,			/* PPEDS Node #1(RxFill Desc ring id #1) Rx Fill IRQ info */ | ||||
| 				<0 161 4>,			/* PPEDS Node #2(TxComp ring id #2) TxComplete IRQ info */ | ||||
| 				<0 129 4>,			/* PPEDS Node #2(Rx Desc ring id #2) Rx Desc IRQ info */ | ||||
| 				<0 153 4>,                      /* PPEDS Node #2(RxFill Desc ring id #2) Rx Fill IRQ info */ | ||||
| 				<0 175 4>,                   /* MHT port Tx complete ring id #16 IRQ info */ | ||||
| 				<0 176 4>,                   /* MHT port Tx complete ring id #17 IRQ info */ | ||||
| 				<0 177 4>,                   /* MHT port Tx complete ring id #18 IRQ info */ | ||||
| 				<0 178 4>,                   /* MHT port Tx complete ring id #19 IRQ info */ | ||||
| 				<0 179 4>,                   /* MHT port Tx complete ring id #20 IRQ info */ | ||||
| 				<0 180 4>,                   /* MHT port Tx complete ring id #21 IRQ info */ | ||||
| 				<0 181 4>,                   /* MHT port Tx complete ring id #22 IRQ info */ | ||||
| 				<0 182 4>;                   /* MHT port Tx complete ring id #23 IRQ info */ | ||||
| 		}; | ||||
|  | ||||
| 		wsi: wsi { | ||||
| 			id = <0>; | ||||
| 			num_chip = <2>; | ||||
| 			status = "okay"; | ||||
| 			chip_info = <0 1 1>, | ||||
| 				<1 1 0>; | ||||
| 		}; | ||||
|  | ||||
| 		q6v5_wcss: remoteproc@d100000 { | ||||
| 			boot-args = <0x1 0x4 0x3 0x0 0x26 0x2>; | ||||
| 			memory-region = <&q6_mem_regions>; | ||||
|  | ||||
| 			q6_wcss_pd1: remoteproc_pd1 { | ||||
| 				status = "okay"; | ||||
| 			}; | ||||
|  | ||||
| 			q6_wcss_pd2: remoteproc_pd2 { | ||||
| 				compatible = "qcom,ipq5332-wcss-pcie-mpd"; | ||||
| 				firmware = "IPQ5332/q6_fw2.mdt"; | ||||
| 				m3_firmware = "qcn6432/iu_fw.mdt"; | ||||
| 				interrupts-extended = <&wcss_smp2p_in 16 0>, | ||||
| 						<&wcss_smp2p_in 17 0>, | ||||
| 						<&wcss_smp2p_in 20 0>, | ||||
| 						<&wcss_smp2p_in 19 0>; | ||||
| 				interrupt-names = "fatal", | ||||
| 						"ready", | ||||
| 						"spawn-ack", | ||||
| 						"stop-ack"; | ||||
| 				qcom,smem-states = <&wcss_smp2p_out 16>, | ||||
| 						<&wcss_smp2p_out 17>, | ||||
| 						<&wcss_smp2p_out 18>; | ||||
| 				qcom,smem-state-names = "shutdown", | ||||
| 							"stop", | ||||
| 							"spawn"; | ||||
| 				status = "okay"; | ||||
| 			}; | ||||
| 		}; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &blsp1_uart0 { | ||||
| 	pinctrl-0 = <&serial_0_pins>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "okay"; | ||||
| }; | ||||
| /* | ||||
| &blsp1_uart1 { | ||||
|         pinctrl-0 = <&serial_1_pins>; | ||||
|         pinctrl-names = "default"; | ||||
|         status = "disabled"; | ||||
| }; | ||||
| */ | ||||
| &blsp1_i2c1 { | ||||
| 	clock-frequency  = <400000>; | ||||
| 	pinctrl-0 = <&i2c_1_pins>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &blsp1_spi0 { | ||||
| 	status = "disabled"; | ||||
| }; | ||||
|  | ||||
| &sdhc { | ||||
| 	bus-width = <4>; | ||||
| 	max-frequency = <192000000>; | ||||
| 	mmc-ddr-1_8v; | ||||
| 	mmc-hs200-1_8v; | ||||
| 	non-removable; | ||||
| 	pinctrl-0 = <&sdc_default_state>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "disabled"; | ||||
| }; | ||||
|  | ||||
| &sleep_clk { | ||||
| 	clock-frequency = <32000>; | ||||
| }; | ||||
|  | ||||
| &xo { | ||||
| 	clock-frequency = <24000000>; | ||||
| }; | ||||
|  | ||||
| &qpic_bam { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &qpic_nand { | ||||
| 	pinctrl-0 = <&qspi_default_state>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "okay"; | ||||
|  | ||||
| 	nandcs@0 { | ||||
| 		reg = <0>; | ||||
| 		#address-cells = <1>; | ||||
| 		#size-cells = <1>; | ||||
|  | ||||
| 		nand-ecc-strength = <8>; | ||||
| 		nand-ecc-step-size = <512>; | ||||
| 		nand-bus-width = <8>; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| /* PINCTRL */ | ||||
|  | ||||
| &tlmm { | ||||
| 	qspi_default_state: qspi-default-state { | ||||
| 		qspi_clock { | ||||
| 			pins = "gpio13"; | ||||
| 			function = "qspi_clk"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-down; | ||||
| 		}; | ||||
|  | ||||
| 		qspi_cs { | ||||
| 			pins = "gpio12"; | ||||
| 			function = "qspi_cs"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-up; | ||||
| 		}; | ||||
|  | ||||
| 		qspi_data { | ||||
| 			pins = "gpio8", "gpio9", "gpio10", "gpio11"; | ||||
| 			function = "qspi_data"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-down; | ||||
| 		}; | ||||
| 	}; | ||||
|  | ||||
| 	pwm_pins: pwm_pinmux { | ||||
| 			/* PWM LED GREEN */ | ||||
| 			mux_1 { | ||||
| 				pins = "gpio43"; | ||||
| 				function = "pwm0"; | ||||
| 				drive-strength = <8>; | ||||
| 			}; | ||||
| 			/* PWM LED BLUE */ | ||||
| 			mux_2 { | ||||
| 				pins = "gpio45"; | ||||
| 				function = "pwm0"; | ||||
| 				drive-strength = <8>; | ||||
| 			}; | ||||
| 			/* PWM LED RED */ | ||||
| 			mux_3 { | ||||
| 				pins = "gpio44"; | ||||
| 				function = "pwm0"; | ||||
| 				drive-strength = <8>; | ||||
| 			}; | ||||
| 			/* PWM LED WHITE */ | ||||
| 			mux_4 { | ||||
| 				pins = "gpio46"; | ||||
| 				function = "pwm0"; | ||||
| 				drive-strength = <8>; | ||||
| 			}; | ||||
| 	}; | ||||
| /* | ||||
| 	serial_1_pins: serial1-pinmux { | ||||
| 		pins = "gpio33", "gpio34", "gpio35", "gpio36"; | ||||
| 		function = "blsp1_uart2"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-up; | ||||
| 	}; | ||||
| */ | ||||
| 	i2c_1_pins: i2c-1-state { | ||||
| 		pins = "gpio29", "gpio30"; | ||||
| 		function = "blsp1_i2c0"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-up; | ||||
| 	}; | ||||
| /* | ||||
| 	gpio_leds_default: gpio-leds-default-state { | ||||
| 		pins = "gpio36"; | ||||
| 		function = "gpio"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-down; | ||||
| 	};  | ||||
| */ | ||||
| 	button_pins: button-state { | ||||
| 		pins = "gpio24"; | ||||
| 		function = "gpio"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-up; | ||||
| 	}; | ||||
|  | ||||
| 	sdc_default_state: sdc-default-state { | ||||
| 		clk-pins { | ||||
| 			pins = "gpio13"; | ||||
| 			function = "sdc_clk"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-disable; | ||||
| 		}; | ||||
|  | ||||
| 		cmd-pins { | ||||
| 			pins = "gpio12"; | ||||
| 			function = "sdc_cmd"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-up; | ||||
| 		}; | ||||
|  | ||||
| 		data-pins { | ||||
| 			pins = "gpio8", "gpio9", "gpio10", "gpio11"; | ||||
| 			function = "sdc_data"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-up; | ||||
| 		}; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &license_manager { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &usb3 { | ||||
| 	qcom,select-utmi-as-pipe-clk; | ||||
| 	status = "disabled"; | ||||
| }; | ||||
|  | ||||
| &pwm { | ||||
| 	pinctrl-0 = <&pwm_pins>; | ||||
| 	used-pwm-indices = <1>, <1>, <1>, <1>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &hs_m31phy_0 { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &wifi0 { | ||||
| 	qcom,multipd_arch; | ||||
| 	qcom,rproc = <&q6_wcss_pd1>; | ||||
| 	qcom,rproc_rpd = <&q6v5_wcss>; | ||||
| 	qcom,userpd-subsys-name = "q6v5_wcss_userpd1"; | ||||
| 	qcom,bdf-addr = <0x4BD00000 0x4BD00000 0x0 0x0 0x0 0x0>; | ||||
| 	qcom,caldb-addr = <0x4D400000 0x4D000000 0x0 0x0 0x0 0x0>; | ||||
| #ifdef __IPQ_MEM_PROFILE_512_MB__ | ||||
| 	qcom,tgt-mem-mode = <1>; | ||||
| 	qcom,caldb-size = <0x300000>; | ||||
| #else | ||||
| 	qcom,tgt-mem-mode = <0>; | ||||
| 	qcom,caldb-size = <0x500000>; | ||||
| #endif | ||||
| 	qcom,board_id = <0x1b>; | ||||
| 	memory-region = <&q6_ipq5332_data>; | ||||
| 	qcom,wsi = <&wsi>; | ||||
| 	qcom,wsi_index = <0>; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &wifi1 { | ||||
| 	qcom,multipd_arch; | ||||
| 	qcom,rproc = <&q6_wcss_pd2>; | ||||
| 	qcom,rproc_rpd = <&q6v5_wcss>; | ||||
| 	qcom,userpd-subsys-name = "q6v5_wcss_userpd2"; | ||||
| 	qcom,bdf-addr = <0x4D900000 0x4D300000 0x0 0x0 0x0 0x0>; | ||||
| 	qcom,caldb-addr = <0x4F000000 0x4E500000 0x0 0x0 0x0 0x0>; | ||||
| 	qcom,umac-irq-reset-addr = <0x20000884>; | ||||
| 	qcom,caldb-size = <0x500000>; | ||||
| #ifdef __IPQ_MEM_PROFILE_512_MB__ | ||||
| 	qcom,tgt-mem-mode = <1>; | ||||
| #else | ||||
| 	qcom,tgt-mem-mode = <0>; | ||||
| #endif | ||||
| 	qcom,board_id = <0x060>; | ||||
| 	memory-region = <&q6_qcn6432_data_1>; | ||||
| 	qcom,wsi = <&wsi>; | ||||
| 	qcom,wsi_index = <1>; | ||||
| 	status = "okay"; | ||||
| 	interrupts = <GIC_SPI 33 IRQ_TYPE_EDGE_RISING>; | ||||
| 	interrupt-names = "umac_reset"; | ||||
| }; | ||||
							
								
								
									
										592
									
								
								feeds/qca-wifi-7/ipq53xx/dts/ipq5332-zyxel-nwa130be.dts
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										592
									
								
								feeds/qca-wifi-7/ipq53xx/dts/ipq5332-zyxel-nwa130be.dts
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,592 @@ | ||||
| // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) | ||||
| /* | ||||
|  * IPQ5332 RDP468 board device tree source | ||||
|  * | ||||
|  * Copyright (c) 2020-2021 The Linux Foundation. All rights reserved. | ||||
|  * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. | ||||
|  */ | ||||
|  | ||||
| /dts-v1/; | ||||
|  | ||||
| #include <dt-bindings/gpio/gpio.h> | ||||
| #include <dt-bindings/input/input.h> | ||||
| #include <dt-bindings/leds/common.h> | ||||
| #include "ipq5332.dtsi" | ||||
| #include "ipq5332-default-memory.dtsi" | ||||
|  | ||||
| / { | ||||
| 	model = "Zyxel NWA130BE"; | ||||
| 	compatible = "zyxel,nwa130be", "qcom,ipq5332-ap-mi01.6", "qcom,ipq5332-rdp468", "qcom,ipq5332"; | ||||
|  | ||||
| 	aliases { | ||||
| 		serial0 = &blsp1_uart0; | ||||
| 		serial1 = &blsp1_uart1; | ||||
| 		ethernet0 = "/soc/dp1"; | ||||
| 		ethernet1 = "/soc/dp2"; | ||||
| 	}; | ||||
|  | ||||
| 	chosen { | ||||
| 		stdout-path = "serial0"; | ||||
| 	}; | ||||
|  | ||||
| 	soc@0 { | ||||
| 		mdio:mdio@90000 { | ||||
| 			pinctrl-0 = <&mdio1_pins &mdio0_pins>; | ||||
| 			pinctrl-names = "default"; | ||||
| 			/*gpio51 for manhattan reset*/ | ||||
| 			phy-reset-gpio = <&tlmm 51 GPIO_ACTIVE_LOW>; | ||||
| 			phyaddr_fixup = <0xC90F018>; | ||||
| 			uniphyaddr_fixup = <0xC90F014>; | ||||
| 			mdio_clk_fixup; /* MDIO clock sequence fix up flag */ | ||||
| 			status = "okay"; | ||||
|  | ||||
| 			phy0: ethernet-phy@0 { | ||||
| 				reg = <1>; | ||||
| 				fixup; | ||||
| 			}; | ||||
| 			phy1: ethernet-phy@1 { | ||||
| 				reg = <2>; | ||||
| 				fixup; | ||||
| 			}; | ||||
| 			phy2: ethernet-phy@2 { | ||||
| 				reg = <3>; | ||||
| 				fixup; | ||||
| 			}; | ||||
| 			phy3: ethernet-phy@3 { | ||||
| 				reg = <4>; | ||||
| 				fixup; | ||||
| 			}; | ||||
|  | ||||
| 			switch0@10 { | ||||
| 				compatible = "qca,qca8386"; | ||||
| 				#address-cells = <1>; | ||||
| 				#size-cells = <0>; | ||||
| 				reg = <0x10>; | ||||
|  | ||||
| 				ports { | ||||
| 					#address-cells = <1>; | ||||
| 					#size-cells = <0>; | ||||
|  | ||||
| 					port@0 { | ||||
| 						reg = <0>; | ||||
| 						label = "cpu"; | ||||
| 						ethernet = <&gmac2>; | ||||
| 						dsa-tag-protocol = "qca_4b"; | ||||
| 					}; | ||||
|  | ||||
| 					port@1 { | ||||
| 						reg = <1>; | ||||
| 						label = "lan1"; | ||||
| 						phy-handle = <&phy0>; | ||||
| 						phy-mode = "usxgmii"; | ||||
| 					}; | ||||
|  | ||||
| 					port@2 { | ||||
| 						reg = <2>; | ||||
| 						label = "lan2"; | ||||
| 						phy-handle = <&phy1>; | ||||
| 						phy-mode = "usxgmii"; | ||||
| 					}; | ||||
|  | ||||
| 					port@3 { | ||||
| 						reg = <3>; | ||||
| 						label = "lan3"; | ||||
| 						phy-handle = <&phy2>; | ||||
| 						phy-mode = "usxgmii"; | ||||
| 					}; | ||||
| 				}; | ||||
| 			}; | ||||
| 		}; | ||||
|  | ||||
| 		ess-instance { | ||||
| 			num_devices = <0x2>; | ||||
|  | ||||
| 			ess-switch@3a000000 { | ||||
| 				switch_cpu_bmp = <0x1>;  /* cpu port bitmap */ | ||||
| 				switch_lan_bmp = <0x2>; /* lan port bitmap */ | ||||
| 				switch_wan_bmp = <0x4>; /* wan port bitmap */ | ||||
| 				switch_mac_mode = <0xc>; /* mac mode for uniphy instance0*/ | ||||
| 				switch_mac_mode1 = <0xf>; /* mac mode for uniphy instance1*/ | ||||
| 				switch_mac_mode2 = <0xff>; /* mac mode for uniphy instance2*/ | ||||
|  | ||||
| 				qcom,port_phyinfo { | ||||
| 					port@0 { | ||||
| 						port_id = <1>; | ||||
| 						forced-speed = <2500>; | ||||
| 						forced-duplex = <1>; | ||||
| 					}; | ||||
| 					port@1 { | ||||
| 						port_id = <2>; | ||||
| 						phy_address = <4>; | ||||
| 					}; | ||||
| 				}; | ||||
|  | ||||
| 				led_source@5 { | ||||
| 					source = <5>; | ||||
| 					mode = "normal"; | ||||
| 					speed = "all"; | ||||
| 					blink_en = "enable"; | ||||
| 					active = "high"; | ||||
| 				}; | ||||
| 			}; | ||||
|  | ||||
| 			ess-switch1@1 { | ||||
| 				compatible = "qcom,ess-switch-qca8386"; | ||||
| 				device_id = <1>; | ||||
| 				switch_access_mode = "mdio"; | ||||
| 				mdio-bus = <&mdio>; | ||||
| 				switch_mac_mode = <0xc>; /* mac mode for uniphy instance0 */ | ||||
| 				switch_mac_mode1 = <0xff>; /* mac mode1 for uniphy instance1 */ | ||||
| 				switch_cpu_bmp = <0x1>;  /* cpu port bitmap */ | ||||
| 				switch_lan_bmp = <0xe>; /* lan port bitmap */ | ||||
| 				switch_wan_bmp = <0x0>;  /* wan port bitmap */ | ||||
| 				link-polling-required = <0>; | ||||
| 				fdb_sync = "interrupt"; | ||||
| 				link-intr-gpio = <&tlmm 23 GPIO_ACTIVE_HIGH>; | ||||
|  | ||||
| 				qcom,port_phyinfo { | ||||
| 					port@0 { | ||||
| 						port_id = <0>; | ||||
| 						forced-speed = <2500>; | ||||
| 						forced-duplex = <1>; | ||||
| 					}; | ||||
| 					port@1 { | ||||
| 						port_id = <1>; | ||||
| 						phy_address = <1>; | ||||
| 					}; | ||||
| 					port@2 { | ||||
| 						port_id = <2>; | ||||
| 						phy_address = <2>; | ||||
| 					}; | ||||
| 					port@3 { | ||||
| 						port_id = <3>; | ||||
| 						phy_address = <3>; | ||||
| 					}; | ||||
| 				}; | ||||
|  | ||||
| 				led_source@2 { | ||||
| 					source = <2>; | ||||
| 					mode = "normal"; | ||||
| 					speed = "all"; | ||||
| 					blink_en = "enable"; | ||||
| 					active = "high"; | ||||
| 				}; | ||||
| 				led_source@5 { | ||||
| 					source = <5>; | ||||
| 					mode = "normal"; | ||||
| 					speed = "all"; | ||||
| 					blink_en = "enable"; | ||||
| 					active = "high"; | ||||
| 				}; | ||||
| 				led_source@8 { | ||||
| 					source = <8>; | ||||
| 					mode = "normal"; | ||||
| 					speed = "all"; | ||||
| 					blink_en = "enable"; | ||||
| 					active = "high"; | ||||
| 				}; | ||||
| 			}; | ||||
| 		}; | ||||
|  | ||||
| 		dp1 { | ||||
| 			device_type = "network"; | ||||
| 			compatible = "qcom,nss-dp"; | ||||
| 			qcom,id = <2>; | ||||
| 			reg = <0x3a504000 0x4000>; | ||||
| 			qcom,mactype = <1>; | ||||
| 			local-mac-address = [000000000000]; | ||||
| 			mdio-bus = <&mdio>; | ||||
| 			qcom,phy-mdio-addr = <4>; | ||||
| 			qcom,link-poll = <1>; | ||||
| 			phy-mode = "sgmii"; | ||||
| 		}; | ||||
|  | ||||
| 		gmac2:dp2 { | ||||
| 			device_type = "network"; | ||||
| 			compatible = "qcom,nss-dp"; | ||||
| 			qcom,id = <1>; | ||||
| 			reg = <0x3a500000 0x4000>; | ||||
| 			qcom,mactype = <1>; | ||||
| 			local-mac-address = [000000000000]; | ||||
| 			phy-mode = "sgmii"; | ||||
| 			qcom,mht-dev = <1>; | ||||
| 			qcom,is_switch_connected = <1>; | ||||
| 			qcom,ppe-offload-disabled = <1>; | ||||
| 		}; | ||||
|  | ||||
| 		/* EDMA host driver configuration for the board */ | ||||
| 		edma@3ab00000 { | ||||
| 			qcom,txdesc-ring-start = <4>;		/* Tx desc ring start ID */ | ||||
| 			qcom,txdesc-rings = <12>;		/* Total number of Tx desc rings to be provisioned */ | ||||
| 			qcom,mht-txdesc-rings = <8>;            /* Extra Tx desc rings to be provisioned for MHT SW ports */ | ||||
| 			qcom,txcmpl-ring-start = <4>;		/* Tx complete ring start ID */ | ||||
| 			qcom,txcmpl-rings = <12>;		/* Total number of Tx complete rings to be provisioned */ | ||||
| 			qcom,mht-txcmpl-rings = <8>;            /* Extra Tx complete rings to be provisioned for mht sw ports. */ | ||||
| 			qcom,rxfill-ring-start = <4>;		/* Rx fill ring start ID */ | ||||
| 			qcom,rxfill-rings = <4>;		/* Total number of Rx fill rings to be provisioned */ | ||||
| 			qcom,rxdesc-ring-start = <12>;		/* Rx desc ring start ID */ | ||||
| 			qcom,rxdesc-rings = <4>;		/* Total number of Rx desc rings to be provisioned */ | ||||
| 			qcom,rx-page-mode = <0>;		/* Rx fill ring page mode */ | ||||
| 			qcom,tx-map-priority-level = <1>;	/* Tx priority level per port */ | ||||
| 			qcom,rx-map-priority-level = <1>;	/* Rx priority level per core */ | ||||
| 			qcom,ppeds-num = <2>;			/* Number of PPEDS nodes */ | ||||
| 			/* PPE-DS node format: <Rx-fill Tx-cmpl Rx Tx Queue-base Queue-count> */ | ||||
| 			qcom,ppeds-map = <1 1 1 1 32 8>,	/* PPEDS Node#0 ring and queue map */ | ||||
| 					<2 2 2 2 40 8>;		/* PPEDS Node#1 ring and queue map */ | ||||
| 			qcom,txdesc-map = <8 9 10 11>,		/* Port0 per-core Tx ring map */ | ||||
| 					<12 13 14 15>,        /* MHT-Port1 per-core Tx ring map */ | ||||
| 					<4 5 6 7>,            /* MHT-Port2 per-core Tx ring map/packets from  vp*/ | ||||
| 					<16 17 18 19>,        /* MHT-Port3 per-core Tx ring map */ | ||||
| 					<20 21 22 23>;        /* MHT-Port4 per-core Tx ring map */ | ||||
| 			qcom,txdesc-fc-grp-map = <1 2 3 4 5>;   /* Per GMAC flow control group map */ | ||||
| 			qcom,rxfill-map = <4 5 6 7>;		/* Per-core Rx fill ring map */ | ||||
| 			qcom,rxdesc-map = <12 13 14 15>;	/* Per-core Rx desc ring map */ | ||||
| 			qcom,rx-queue-start = <0>;		/* Rx queue start */ | ||||
| 			qcom,rx-ring-queue-map = <0 8 16 24>,	/* Priority 0 queues per-core Rx ring map */ | ||||
| 						<1 9 17 25>,	/* Priority 1 queues per-core Rx ring map */ | ||||
| 						<2 10 18 26>,	/* Priority 2 queues per-core Rx ring map */ | ||||
| 						<3 11 19 27>,	/* Priority 3 queues per-core Rx ring map */ | ||||
| 						<4 12 20 28>,	/* Priority 4 queues per-core Rx ring map */ | ||||
| 						<5 13 21 29>,	/* Priority 5 queues per-core Rx ring map */ | ||||
| 						<6 14 22 30>,	/* Priority 6 queues per-core Rx ring map */ | ||||
| 						<7 15 23 31>;	/* Priority 7 queues per-core Rx ring map */ | ||||
| 			interrupts = <0 163 4>,			/* Tx complete ring id #4 IRQ info */ | ||||
| 				   <0 164 4>,			/* Tx complete ring id #5 IRQ info */ | ||||
| 				   <0 165 4>,			/* Tx complete ring id #6 IRQ info */ | ||||
| 				   <0 166 4>,			/* Tx complete ring id #7 IRQ info */ | ||||
| 				   <0 167 4>,			/* Tx complete ring id #8 IRQ info */ | ||||
| 				   <0 168 4>,			/* Tx complete ring id #9 IRQ info */ | ||||
| 				   <0 169 4>,			/* Tx complete ring id #10 IRQ info */ | ||||
| 				   <0 170 4>,			/* Tx complete ring id #11 IRQ info */ | ||||
| 				   <0 171 4>,			/* Tx complete ring id #12 IRQ info */ | ||||
| 				   <0 172 4>,			/* Tx complete ring id #13 IRQ info */ | ||||
| 				   <0 173 4>,			/* Tx complete ring id #14 IRQ info */ | ||||
| 				   <0 174 4>,			/* Tx complete ring id #15 IRQ info */ | ||||
| 				   <0 139 4>,			/* Rx desc ring id #12 IRQ info */ | ||||
| 				   <0 140 4>,			/* Rx desc ring id #13 IRQ info */ | ||||
| 				   <0 141 4>,			/* Rx desc ring id #14 IRQ info */ | ||||
| 				   <0 142 4>,			/* Rx desc ring id #15 IRQ info */ | ||||
| 				   <0 191 4>,			/* Misc error IRQ info */ | ||||
| 				<0 160 4>,			/* PPEDS Node #1(TxComp ring id #1) TxComplete IRQ info */ | ||||
| 				<0 128 4>,			/* PPEDS Node #1(Rx Desc ring id #1) Rx Desc IRQ info */ | ||||
| 				<0 152 4>,			/* PPEDS Node #1(RxFill Desc ring id #1) Rx Fill IRQ info */ | ||||
| 				<0 161 4>,			/* PPEDS Node #2(TxComp ring id #2) TxComplete IRQ info */ | ||||
| 				<0 129 4>,			/* PPEDS Node #2(Rx Desc ring id #2) Rx Desc IRQ info */ | ||||
| 				<0 153 4>,                      /* PPEDS Node #2(RxFill Desc ring id #2) Rx Fill IRQ info */ | ||||
| 				<0 175 4>,                   /* MHT port Tx complete ring id #16 IRQ info */ | ||||
| 				<0 176 4>,                   /* MHT port Tx complete ring id #17 IRQ info */ | ||||
| 				<0 177 4>,                   /* MHT port Tx complete ring id #18 IRQ info */ | ||||
| 				<0 178 4>,                   /* MHT port Tx complete ring id #19 IRQ info */ | ||||
| 				<0 179 4>,                   /* MHT port Tx complete ring id #20 IRQ info */ | ||||
| 				<0 180 4>,                   /* MHT port Tx complete ring id #21 IRQ info */ | ||||
| 				<0 181 4>,                   /* MHT port Tx complete ring id #22 IRQ info */ | ||||
| 				<0 182 4>;                   /* MHT port Tx complete ring id #23 IRQ info */ | ||||
| 		}; | ||||
|  | ||||
| 		leds { | ||||
| 			compatible = "gpio-leds"; | ||||
| 			pinctrl-0 = <&led_pins>; | ||||
| 			pinctrl-names = "default"; | ||||
| 			led_blue{ | ||||
| 				label = "led_blue"; | ||||
| 				gpio = <&tlmm 22 GPIO_ACTIVE_HIGH>; | ||||
| 				linux,default-trigger = "led_blue"; | ||||
| 				default-state = "off"; | ||||
| 			}; | ||||
| 			led_green { | ||||
| 				label = "led_green"; | ||||
| 				gpio = <&tlmm 31 GPIO_ACTIVE_HIGH>; | ||||
| 				linux,default-trigger = "led_green"; | ||||
| 				default-state = "on"; | ||||
| 			}; | ||||
| 			led_white { | ||||
| 				label = "led_white"; | ||||
| 				gpio = <&tlmm 32 GPIO_ACTIVE_HIGH>; | ||||
| 				linux,default-trigger = "led_white"; | ||||
| 				default-state = "off"; | ||||
| 			}; | ||||
| 			led_red { | ||||
| 				label = "led_red"; | ||||
| 				gpio = <&tlmm 44 GPIO_ACTIVE_HIGH>; | ||||
| 				linux,default-trigger = "led_red"; | ||||
| 				default-state = "off"; | ||||
| 			}; | ||||
| 		}; | ||||
|  | ||||
| 		gpio_keys { | ||||
| 			compatible = "gpio-keys"; | ||||
| 			pinctrl-0 = <&button_pins>; | ||||
| 			pinctrl-names = "default"; | ||||
| 			button@1 { | ||||
| 				label = "reset"; | ||||
| 				linux,code = <KEY_RESTART>; | ||||
| 				gpios = <&tlmm 30 GPIO_ACTIVE_LOW>; | ||||
| 				linux,input-type = <1>; | ||||
| 				debounce-interval = <60>; | ||||
| 			}; | ||||
| 		}; | ||||
|  | ||||
| 		wsi: wsi { | ||||
| 			id = <0>; | ||||
| 			num_chip = <2>; | ||||
| 			status = "okay"; | ||||
| 			chip_info = <0 1 1>, | ||||
| 				    <1 1 0>; | ||||
| 		}; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &wifi0 { | ||||
| 	led-gpio = <&tlmm 36 GPIO_ACTIVE_HIGH>; | ||||
| 	qcom,rproc = <&q6_wcss_pd1>; | ||||
| 	qcom,rproc_rpd = <&q6v5_wcss>; | ||||
| 	qcom,multipd_arch; | ||||
| 	qcom,userpd-subsys-name = "q6v5_wcss_userpd1"; | ||||
| 	memory-region = <&q6_region>; | ||||
| 	qcom,wsi = <&wsi>; | ||||
| 	qcom,wsi_index = <0>; | ||||
| 	qcom,board_id = <0x12>; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &qcn9224_pcie1 { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &blsp1_uart0 { | ||||
| 	pinctrl-0 = <&serial_0_pins>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &blsp1_uart1 { | ||||
| 	pinctrl-0 = <&serial_1_pins>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "disabled"; | ||||
| }; | ||||
|  | ||||
| &blsp1_spi0 { | ||||
| 	pinctrl-0 = <&spi_0_data_clk_pins &spi_0_cs_pins>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "okay"; | ||||
|  | ||||
| 	flash@0 { | ||||
| 		compatible = "n25q128a11", "micron,n25q128a11", "jedec,spi-nor"; | ||||
| 		reg = <0>; | ||||
| 		#address-cells = <1>; | ||||
| 		#size-cells = <1>; | ||||
| 		spi-max-frequency = <50000000>; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &sdhc { | ||||
| 	bus-width = <4>; | ||||
| 	max-frequency = <192000000>; | ||||
| 	mmc-ddr-1_8v; | ||||
| 	mmc-hs200-1_8v; | ||||
| 	non-removable; | ||||
| 	pinctrl-0 = <&sdc_default_state>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "disabled"; | ||||
| }; | ||||
|  | ||||
| &sleep_clk { | ||||
| 	clock-frequency = <32000>; | ||||
| }; | ||||
|  | ||||
| &xo { | ||||
| 	clock-frequency = <24000000>; | ||||
| }; | ||||
|  | ||||
| &qpic_bam { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &qpic_nand { | ||||
| 	pinctrl-0 = <&qspi_default_state>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "okay"; | ||||
|  | ||||
| 	nandcs@0 { | ||||
| 		reg = <0>; | ||||
| 		#address-cells = <1>; | ||||
| 		#size-cells = <1>; | ||||
|  | ||||
| 		nand-ecc-strength = <8>; | ||||
| 		nand-ecc-step-size = <512>; | ||||
| 		nand-bus-width = <8>; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &pcie1_phy_x2 { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &pcie1 { | ||||
| 	pinctrl-0 = <&pcie1_default_state>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	perst-gpios = <&tlmm 47 GPIO_ACTIVE_LOW>; | ||||
| 	status = "okay"; | ||||
|  | ||||
| 	pcie1_rp { | ||||
| 		reg = <0 0 0 0 0>; | ||||
|  | ||||
| 		qcom,mhi@1 { | ||||
| 			reg = <0 0 0 0 0>; | ||||
| 			boot-args = <0x2 0x4 0x34 0x3 0x0 0x0     /* MX Rail, GPIO52, Drive strength 0x3 */ | ||||
| 					0x4 0x4 0x18 0x3 0x0 0x0  /* RFA1p2 Rail, GPIO24, Drive strength 0x3 */ | ||||
| 					0x0 0x4 0x0 0x0 0x0 0x0>; /* End of arguments */ | ||||
| 			memory-region = <&qcn9224_pcie1>; | ||||
| 			qcom,wsi = <&wsi>; | ||||
| 			qcom,wsi_index = <1>; | ||||
| 			qcom,board_id = <0x1019>; | ||||
| 		}; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| /* PINCTRL */ | ||||
|  | ||||
| &tlmm { | ||||
|  | ||||
| 	led_pins: led_pins { | ||||
| 		led_blue { | ||||
| 			pins = "gpio22"; | ||||
| 			function = "gpio"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-down; | ||||
| 		}; | ||||
|  | ||||
| 		led_green { | ||||
| 			pins = "gpio31"; | ||||
| 			function = "gpio"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-down; | ||||
| 		}; | ||||
|  | ||||
| 		led_white { | ||||
| 			pins = "gpio32"; | ||||
| 			function = "gpio"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-down; | ||||
| 		}; | ||||
|  | ||||
| 		led_red { | ||||
| 			pins = "gpio44"; | ||||
| 			function = "gpio"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-down; | ||||
| 		}; | ||||
| 	}; | ||||
|  | ||||
|  | ||||
| 	sdc_default_state: sdc-default-state { | ||||
| 		clk-pins { | ||||
| 			pins = "gpio13"; | ||||
| 			function = "sdc_clk"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-disable; | ||||
| 		}; | ||||
|  | ||||
| 		cmd-pins { | ||||
| 			pins = "gpio12"; | ||||
| 			function = "sdc_cmd"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-up; | ||||
| 		}; | ||||
|  | ||||
| 		data-pins { | ||||
| 			pins = "gpio8", "gpio9", "gpio10", "gpio11"; | ||||
| 			function = "sdc_data"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-up; | ||||
| 		}; | ||||
| 	}; | ||||
|  | ||||
| 	spi_0_data_clk_pins: spi-0-data-clk-state { | ||||
| 		pins = "gpio14", "gpio15", "gpio16"; | ||||
| 		function = "blsp0_spi"; | ||||
| 		drive-strength = <2>; | ||||
| 		bias-pull-down; | ||||
| 	}; | ||||
|  | ||||
| 	spi_0_cs_pins: spi-0-cs-state { | ||||
| 		pins = "gpio17"; | ||||
| 		function = "blsp0_spi"; | ||||
| 		drive-strength = <2>; | ||||
| 		bias-pull-up; | ||||
| 	}; | ||||
|  | ||||
| 	qspi_default_state: qspi-default-state { | ||||
| 		qspi_clock { | ||||
| 			pins = "gpio13"; | ||||
| 			function = "qspi_clk"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-down; | ||||
| 		}; | ||||
|  | ||||
| 		qspi_cs { | ||||
| 			pins = "gpio12"; | ||||
| 			function = "qspi_cs"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-up; | ||||
| 		}; | ||||
|  | ||||
| 		qspi_data { | ||||
| 			pins = "gpio8", "gpio9", "gpio10", "gpio11"; | ||||
| 			function = "qspi_data"; | ||||
| 			drive-strength = <8>; | ||||
| 			bias-pull-down; | ||||
| 		}; | ||||
| 	}; | ||||
|  | ||||
| 	serial_1_pins: serial1-pinmux { | ||||
| 		pins = "gpio33", "gpio34", "gpio35", "gpio36"; | ||||
| 		function = "blsp1_uart2"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-up; | ||||
| 	}; | ||||
|  | ||||
| 	button_pins: button-state { | ||||
| 		pins = "gpio30"; | ||||
| 		function = "gpio"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-up; | ||||
| 	}; | ||||
|  | ||||
| 	pwm_pins: pwm-state { | ||||
| 		pins = "gpio46"; | ||||
| 		function = "pwm0"; | ||||
| 		drive-strength = <8>; | ||||
| 	}; | ||||
|  | ||||
| 	pcie1_default_state: pcie1-default-state { | ||||
| 		pins = "gpio47"; | ||||
| 		function = "gpio"; | ||||
| 		drive-strength = <8>; | ||||
| 		bias-pull-up; | ||||
| 		output-low; | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| &license_manager { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &usb3 { | ||||
| 	qcom,multiplexed-phy; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &pwm { | ||||
| 	pinctrl-0 = <&pwm_pins>; | ||||
| 	pinctrl-names = "default"; | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &hs_m31phy_0 { | ||||
| 	status = "okay"; | ||||
| }; | ||||
|  | ||||
| &ssuniphy_0 { | ||||
| 	status = "okay"; | ||||
| }; | ||||
| @@ -0,0 +1,157 @@ | ||||
| /* SPDX-License-Identifier: GPL-2.0-only */ | ||||
| /* | ||||
|  * STMicroelectronics ilps22qs driver | ||||
|  * | ||||
|  * Copyright 2023 STMicroelectronics Inc. | ||||
|  * | ||||
|  * MEMS Software Solutions Team | ||||
|  */ | ||||
|  | ||||
| #ifndef __ST_ILPS22QS_H | ||||
| #define __ST_ILPS22QS_H | ||||
|  | ||||
| #include <linux/bitfield.h> | ||||
| #include <linux/iio/iio.h> | ||||
| #include <linux/module.h> | ||||
| #include <linux/mutex.h> | ||||
| #include <linux/of.h> | ||||
| #include <linux/regmap.h> | ||||
| #include <linux/types.h> | ||||
| #include <linux/workqueue.h> | ||||
|  | ||||
| #define ST_ILPS22QS_DEV_NAME			"ilps22qs" | ||||
| #define ST_ILPS28QSW_DEV_NAME			"ilps28qsw" | ||||
|  | ||||
| #define ST_ILPS22QS_WHO_AM_I_ADDR		0x0f | ||||
| #define ST_ILPS22QS_WHOAMI_VAL			0xb4 | ||||
|  | ||||
| #define ST_ILPS22QS_CTRL1_ADDR			0x10 | ||||
| #define ST_ILPS22QS_ODR_MASK			GENMASK(6, 3) | ||||
|  | ||||
| #define ST_ILPS22QS_CTRL2_ADDR			0x11 | ||||
| #define ST_ILPS22QS_SOFT_RESET_MASK		BIT(2) | ||||
| #define ST_ILPS22QS_BDU_MASK			BIT(3) | ||||
|  | ||||
| #define ST_ILPS22QS_CTRL3_ADDR			0x12 | ||||
| #define ST_ILPS22QS_AH_QVAR_EN_MASK		BIT(7) | ||||
| #define ST_ILPS22QS_AH_QVAR_P_AUTO_EN_MASK	BIT(5) | ||||
|  | ||||
| #define ST_ILPS22QS_PRESS_OUT_XL_ADDR		0x28 | ||||
| #define ST_ILPS22QS_TEMP_OUT_L_ADDR		0x2b | ||||
|  | ||||
| #define ST_ILPS22QS_PRESS_FS_AVL_GAIN		(1000000000UL / 4096UL) | ||||
| #define ST_ILPS22QS_TEMP_FS_AVL_GAIN		100 | ||||
| #define ST_ILPS22QS_QVAR_FS_AVL_GAIN		438000 | ||||
|  | ||||
| #define ST_ILPS22QS_SHIFT_VAL(val, mask)	(((val) << __ffs(mask)) & (mask)) | ||||
|  | ||||
| #define ST_ILPS22QS_ODR_LIST_NUM		8 | ||||
|  | ||||
| enum st_ilps22qs_sensor_id { | ||||
| 	ST_ILPS22QS_PRESS = 0, | ||||
| 	ST_ILPS22QS_TEMP, | ||||
| 	ST_ILPS22QS_QVAR, | ||||
| 	ST_ILPS22QS_SENSORS_NUM, | ||||
| }; | ||||
|  | ||||
| struct st_ilps22qs_odr_t { | ||||
| 	u8 hz; | ||||
| 	u8 val; | ||||
| }; | ||||
|  | ||||
| struct st_ilps22qs_reg { | ||||
| 	u8 addr; | ||||
| 	u8 mask; | ||||
| }; | ||||
|  | ||||
| struct st_ilps22qs_odr_table_t { | ||||
| 	u8 size; | ||||
| 	struct st_ilps22qs_reg reg; | ||||
| 	struct st_ilps22qs_odr_t odr_avl[ST_ILPS22QS_ODR_LIST_NUM]; | ||||
| }; | ||||
|  | ||||
| struct st_ilps22qs_hw { | ||||
| 	struct iio_dev *iio_devs[ST_ILPS22QS_SENSORS_NUM]; | ||||
| 	struct workqueue_struct *workqueue; | ||||
| 	struct regulator *vddio_supply; | ||||
| 	struct regulator *vdd_supply; | ||||
| 	struct regmap *regmap; | ||||
| 	struct device *dev; | ||||
| 	struct mutex lock; | ||||
| 	bool interleave; | ||||
| 	u8 enable_mask; | ||||
| 	u8 odr; | ||||
| }; | ||||
|  | ||||
| struct st_ilps22qs_sensor { | ||||
| 	enum st_ilps22qs_sensor_id id; | ||||
| 	struct work_struct iio_work; | ||||
| 	struct st_ilps22qs_hw *hw; | ||||
| 	struct hrtimer hr_timer; | ||||
| 	ktime_t ktime; | ||||
| 	int64_t timestamp; | ||||
| 	char name[32]; | ||||
| 	u32 gain; | ||||
| 	u8 odr; | ||||
| }; | ||||
|  | ||||
| extern const struct dev_pm_ops st_ilps22qs_pm_ops; | ||||
|  | ||||
| static inline int st_ilps22qs_update_locked(struct st_ilps22qs_hw *hw, | ||||
| 					    unsigned int addr, | ||||
| 					    unsigned int mask, | ||||
| 					    unsigned int data) | ||||
| { | ||||
| 	unsigned int val = ST_ILPS22QS_SHIFT_VAL(data, mask); | ||||
| 	int err; | ||||
|  | ||||
| 	mutex_lock(&hw->lock); | ||||
| 	err = regmap_update_bits(hw->regmap, addr, mask, val); | ||||
| 	mutex_unlock(&hw->lock); | ||||
|  | ||||
| 	return err; | ||||
| } | ||||
|  | ||||
| static inline int st_ilps22qs_read_locked(struct st_ilps22qs_hw *hw, | ||||
| 					  unsigned int addr, void *val, | ||||
| 					  unsigned int len) | ||||
| { | ||||
| 	int err; | ||||
|  | ||||
| 	mutex_lock(&hw->lock); | ||||
| 	err = regmap_bulk_read(hw->regmap, addr, val, len); | ||||
| 	mutex_unlock(&hw->lock); | ||||
|  | ||||
| 	return err; | ||||
| } | ||||
|  | ||||
| static inline void st_ilps22qs_flush_works(struct st_ilps22qs_hw *hw) | ||||
| { | ||||
| 	flush_workqueue(hw->workqueue); | ||||
| } | ||||
|  | ||||
| static inline int st_ilps22qs_destroy_workqueue(struct st_ilps22qs_hw *hw) | ||||
| { | ||||
| 	if (hw->workqueue) | ||||
| 		destroy_workqueue(hw->workqueue); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static inline int st_ilps22qs_allocate_workqueue(struct st_ilps22qs_hw *hw) | ||||
| { | ||||
| 	if (!hw->workqueue) | ||||
| 		hw->workqueue = create_workqueue(ST_ILPS22QS_DEV_NAME); | ||||
|  | ||||
| 	return !hw->workqueue ? -ENOMEM : 0; | ||||
| } | ||||
|  | ||||
| static inline s64 st_ilps22qs_get_time_ns(struct st_ilps22qs_hw *hw) | ||||
| { | ||||
| 	return iio_get_time_ns(hw->iio_devs[ST_ILPS22QS_PRESS]); | ||||
| } | ||||
|  | ||||
| int st_ilps22qs_probe(struct device *dev, struct regmap *regmap); | ||||
| int st_ilps22qs_remove(struct device *dev); | ||||
|  | ||||
| #endif /* __ST_ILPS22QS_H */ | ||||
| @@ -0,0 +1,927 @@ | ||||
| // SPDX-License-Identifier: GPL-2.0-only | ||||
| /* | ||||
|  * STMicroelectronics ilps22qs driver | ||||
|  * | ||||
|  * Copyright 2023 STMicroelectronics Inc. | ||||
|  * | ||||
|  * MEMS Software Solutions Team | ||||
|  */ | ||||
|  | ||||
| #include <linux/delay.h> | ||||
| #include <linux/kernel.h> | ||||
| #include <linux/iio/buffer.h> | ||||
| #include <linux/iio/events.h> | ||||
| #include <linux/iio/iio.h> | ||||
| #include <linux/iio/kfifo_buf.h> | ||||
| #include <linux/iio/sysfs.h> | ||||
| #include <linux/iio/trigger_consumer.h> | ||||
| #include <linux/iio/triggered_buffer.h> | ||||
| #include <linux/iio/trigger.h> | ||||
| #include <linux/regulator/consumer.h> | ||||
| #include <linux/slab.h> | ||||
| #include <linux/types.h> | ||||
| #include <linux/version.h> | ||||
|  | ||||
| #if KERNEL_VERSION(6, 11, 0) < LINUX_VERSION_CODE | ||||
| #include <linux/unaligned.h> | ||||
| #else /* LINUX_VERSION_CODE */ | ||||
| #include <asm/unaligned.h> | ||||
| #endif /* LINUX_VERSION_CODE */ | ||||
|  | ||||
| #include "st_ilps22qs.h" | ||||
|  | ||||
| static const struct st_ilps22qs_odr_table_t st_ilps22qs_odr_table = { | ||||
| 	.size = ST_ILPS22QS_ODR_LIST_NUM, | ||||
| 	.reg = { | ||||
| 		.addr = ST_ILPS22QS_CTRL1_ADDR, | ||||
| 		.mask = ST_ILPS22QS_ODR_MASK, | ||||
| 	}, | ||||
| 	.odr_avl[0] = {   1, 0x01 }, | ||||
| 	.odr_avl[1] = {   4, 0x02 }, | ||||
| 	.odr_avl[2] = {  10, 0x03 }, | ||||
| 	.odr_avl[3] = {  25, 0x04 }, | ||||
| 	.odr_avl[4] = {  50, 0x05 }, | ||||
| 	.odr_avl[5] = {  75, 0x06 }, | ||||
| 	.odr_avl[6] = { 100, 0x07 }, | ||||
| 	.odr_avl[7] = { 200, 0x08 }, | ||||
| }; | ||||
|  | ||||
| static const struct iio_chan_spec st_ilps22qs_press_channels[] = { | ||||
| 	{ | ||||
| 		.type = IIO_PRESSURE, | ||||
| 		.address = ST_ILPS22QS_PRESS_OUT_XL_ADDR, | ||||
| 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | | ||||
| 				      BIT(IIO_CHAN_INFO_SCALE), | ||||
| 		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), | ||||
| 		.channel2 = IIO_NO_MOD, | ||||
| 		.scan_index = 0, | ||||
| 		.scan_type = { | ||||
| 			.sign = 'u', | ||||
| 			.realbits = 24, | ||||
| 			.storagebits = 32, | ||||
| 			.endianness = IIO_LE, | ||||
| 		}, | ||||
| 	}, | ||||
| 	IIO_CHAN_SOFT_TIMESTAMP(1) | ||||
| }; | ||||
|  | ||||
| static const struct iio_chan_spec st_ilps22qs_temp_channels[] = { | ||||
| 	{ | ||||
| 		.type = IIO_TEMP, | ||||
| 		.address = ST_ILPS22QS_TEMP_OUT_L_ADDR, | ||||
| 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | | ||||
| 				      BIT(IIO_CHAN_INFO_SCALE), | ||||
| 		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), | ||||
| 		.channel2 = IIO_NO_MOD, | ||||
| 		.scan_index = 0, | ||||
| 		.scan_type = { | ||||
| 			.sign = 's', | ||||
| 			.realbits = 16, | ||||
| 			.storagebits = 16, | ||||
| 			.endianness = IIO_LE, | ||||
| 		}, | ||||
| 	}, | ||||
| 	IIO_CHAN_SOFT_TIMESTAMP(1) | ||||
| }; | ||||
|  | ||||
| static const struct iio_chan_spec st_ilps22qs_qvar_channels[] = { | ||||
| 	{ | ||||
| 		.type = IIO_ALTVOLTAGE, | ||||
| 		.address = ST_ILPS22QS_PRESS_OUT_XL_ADDR, | ||||
| 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | | ||||
| 				      BIT(IIO_CHAN_INFO_SCALE), | ||||
| 		.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), | ||||
| 		.channel2 = IIO_NO_MOD, | ||||
| 		.scan_index = 0, | ||||
| 		.scan_type = { | ||||
| 			.sign = 's', | ||||
| 			.realbits = 24, | ||||
| 			.storagebits = 32, | ||||
| 			.endianness = IIO_LE, | ||||
| 		} | ||||
| 	}, | ||||
| 	IIO_CHAN_SOFT_TIMESTAMP(1), | ||||
| }; | ||||
|  | ||||
| static enum hrtimer_restart | ||||
| st_ilps22qs_poll_function_read(struct hrtimer *timer) | ||||
| { | ||||
| 	struct st_ilps22qs_sensor *sensor; | ||||
|  | ||||
| 	sensor = container_of((struct hrtimer *)timer, | ||||
| 			      struct st_ilps22qs_sensor, hr_timer); | ||||
|  | ||||
| 	sensor->timestamp = st_ilps22qs_get_time_ns(sensor->hw); | ||||
| 	queue_work(sensor->hw->workqueue, &sensor->iio_work); | ||||
|  | ||||
| 	return HRTIMER_NORESTART; | ||||
| } | ||||
|  | ||||
| static void st_ilps22qs_report_temp(struct st_ilps22qs_sensor *sensor, | ||||
| 				    u8 *tmp, int64_t timestamp) | ||||
| { | ||||
| 	struct iio_dev *iio_dev = sensor->hw->iio_devs[sensor->id]; | ||||
| 	u8 iio_buf[ALIGN(2, sizeof(s64)) + sizeof(s64)]; | ||||
|  | ||||
| 	memcpy(iio_buf, tmp, 2); | ||||
| 	iio_push_to_buffers_with_timestamp(iio_dev, iio_buf, timestamp); | ||||
| } | ||||
|  | ||||
| static void st_silps22qs_report_press_qvar(struct st_ilps22qs_sensor *sensor, | ||||
| 					   u8 *tmp, int64_t timestamp) | ||||
| { | ||||
| 	u8 iio_buf[ALIGN(3, sizeof(s64)) + sizeof(s64)]; | ||||
| 	struct st_ilps22qs_hw *hw = sensor->hw; | ||||
| 	struct iio_dev *iio_dev; | ||||
|  | ||||
| 	mutex_lock(&hw->lock); | ||||
| 	if (hw->interleave) { | ||||
| 		if (tmp[0] & 0x01) | ||||
| 			iio_dev = sensor->hw->iio_devs[ST_ILPS22QS_QVAR]; | ||||
| 		else | ||||
| 			iio_dev = sensor->hw->iio_devs[ST_ILPS22QS_PRESS]; | ||||
| 	} else { | ||||
| 		iio_dev = sensor->hw->iio_devs[sensor->id]; | ||||
| 	} | ||||
| 	mutex_unlock(&hw->lock); | ||||
|  | ||||
| 	memcpy(iio_buf, tmp, 3); | ||||
| 	iio_push_to_buffers_with_timestamp(iio_dev, iio_buf, timestamp); | ||||
| } | ||||
|  | ||||
| static void st_ilps22qs_poll_function_work(struct work_struct *iio_work) | ||||
| { | ||||
| 	struct st_ilps22qs_sensor *sensor; | ||||
| 	struct st_ilps22qs_hw *hw; | ||||
| 	ktime_t tmpkt, ktdelta; | ||||
| 	int len; | ||||
| 	int err; | ||||
| 	int id; | ||||
|  | ||||
| 	sensor = container_of((struct work_struct *)iio_work, | ||||
| 			      struct st_ilps22qs_sensor, iio_work); | ||||
| 	hw = sensor->hw; | ||||
| 	id = sensor->id; | ||||
|  | ||||
| 	/* adjust delta time */ | ||||
| 	ktdelta = ktime_set(0, | ||||
| 			    (st_ilps22qs_get_time_ns(hw) - sensor->timestamp)); | ||||
|  | ||||
| 	/* avoid negative value in case of high odr */ | ||||
| 	mutex_lock(&hw->lock); | ||||
| 	if (ktime_after(sensor->ktime, ktdelta)) | ||||
| 		tmpkt = ktime_sub(sensor->ktime, ktdelta); | ||||
| 	else | ||||
| 		tmpkt = sensor->ktime; | ||||
|  | ||||
| 	hrtimer_start(&sensor->hr_timer, tmpkt, HRTIMER_MODE_REL); | ||||
| 	mutex_unlock(&sensor->hw->lock); | ||||
|  | ||||
| 	len = hw->iio_devs[id]->channels->scan_type.realbits >> 3; | ||||
|  | ||||
| 	switch (id) { | ||||
| 	case ST_ILPS22QS_PRESS: | ||||
| 	case ST_ILPS22QS_QVAR: { | ||||
| 		u8 data[3]; | ||||
|  | ||||
| 		err = st_ilps22qs_read_locked(hw, | ||||
| 					    hw->iio_devs[id]->channels->address, | ||||
| 					    data, len); | ||||
| 		if (err < 0) | ||||
| 			return; | ||||
|  | ||||
| 		st_silps22qs_report_press_qvar(sensor, data, sensor->timestamp); | ||||
| 		} | ||||
| 		break; | ||||
| 	case ST_ILPS22QS_TEMP: { | ||||
| 		u8 data[2]; | ||||
|  | ||||
| 		err = st_ilps22qs_read_locked(hw, | ||||
| 					    hw->iio_devs[id]->channels->address, | ||||
| 					    data, len); | ||||
| 		if (err < 0) | ||||
| 			return; | ||||
|  | ||||
| 		st_ilps22qs_report_temp(sensor, data, sensor->timestamp); | ||||
| 		} | ||||
| 		break; | ||||
| 	default: | ||||
| 		break; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| static int st_ilps22qs_check_whoami(struct st_ilps22qs_hw *hw) | ||||
| { | ||||
| 	int data; | ||||
| 	int err; | ||||
|  | ||||
| 	err = regmap_read(hw->regmap, ST_ILPS22QS_WHO_AM_I_ADDR, &data); | ||||
| 	if (err < 0) { | ||||
| 		dev_err(hw->dev, "failed to read whoami register\n"); | ||||
|  | ||||
| 		return err; | ||||
| 	} | ||||
|  | ||||
| 	if (data != ST_ILPS22QS_WHOAMI_VAL) { | ||||
| 		dev_err(hw->dev, "unsupported whoami [%02x]\n", data); | ||||
|  | ||||
| 		return -ENODEV; | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static __maybe_unused int st_ilps22qs_reg_access(struct iio_dev *iio_dev, | ||||
| 						 unsigned int reg, | ||||
| 						 unsigned int writeval, | ||||
| 						 unsigned int *readval) | ||||
| { | ||||
| 	struct st_ilps22qs_sensor *sensor = iio_priv(iio_dev); | ||||
| 	int ret; | ||||
|  | ||||
| 	ret = iio_device_claim_direct_mode(iio_dev); | ||||
| 	if (ret) | ||||
| 		return ret; | ||||
|  | ||||
| 	if (readval == NULL) | ||||
| 		ret = regmap_write(sensor->hw->regmap, reg, writeval); | ||||
| 	else | ||||
| 		ret = regmap_read(sensor->hw->regmap, reg, readval); | ||||
|  | ||||
| 	iio_device_release_direct_mode(iio_dev); | ||||
|  | ||||
| 	return (ret < 0) ? ret : 0; | ||||
| } | ||||
|  | ||||
| static int st_ilps22qs_get_odr(struct st_ilps22qs_sensor *sensor, u8 odr) | ||||
| { | ||||
| 	int i; | ||||
|  | ||||
| 	for (i = 0; i < st_ilps22qs_odr_table.size; i++) { | ||||
| 		if (st_ilps22qs_odr_table.odr_avl[i].hz >= odr) | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	return i == st_ilps22qs_odr_table.size ? -EINVAL : i; | ||||
| } | ||||
|  | ||||
| static int st_ilps22qs_set_odr(struct st_ilps22qs_sensor *sensor, u8 odr) | ||||
| { | ||||
| 	struct st_ilps22qs_hw *hw = sensor->hw; | ||||
| 	u8 max_odr = odr; | ||||
| 	int i; | ||||
|  | ||||
| 	for (i = 0; i < ST_ILPS22QS_SENSORS_NUM; i++) { | ||||
| 		if ((hw->enable_mask & BIT(i)) && (sensor->id != i)) { | ||||
| 			struct st_ilps22qs_sensor *temp; | ||||
|  | ||||
| 			temp = iio_priv(hw->iio_devs[i]); | ||||
| 			max_odr = max_t(u32, max_odr, temp->odr); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if (max_odr != hw->odr) { | ||||
| 		int err, ret; | ||||
|  | ||||
| 		ret = st_ilps22qs_get_odr(sensor, max_odr); | ||||
| 		if (ret < 0) | ||||
| 			return ret; | ||||
|  | ||||
| 		err = st_ilps22qs_update_locked(hw, | ||||
| 					 st_ilps22qs_odr_table.reg.addr, | ||||
| 					 st_ilps22qs_odr_table.reg.mask, | ||||
| 					 st_ilps22qs_odr_table.odr_avl[ret].val); | ||||
| 		if (err < 0) | ||||
| 			return err; | ||||
|  | ||||
| 		hw->odr = max_odr; | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| /* need hw->lock */ | ||||
| static int st_ilps22qs_set_interleave(struct st_ilps22qs_sensor *sensor, | ||||
| 				      bool enable) | ||||
| { | ||||
| 	struct st_ilps22qs_hw *hw = sensor->hw; | ||||
| 	int otherid = sensor->id == ST_ILPS22QS_PRESS ? ST_ILPS22QS_QVAR : | ||||
| 							ST_ILPS22QS_PRESS; | ||||
| 	int interleave; | ||||
| 	int err = 0; | ||||
|  | ||||
| 	/* both press / qvar enabling ? */ | ||||
| 	mutex_lock(&hw->lock); | ||||
| 	interleave = (!!(hw->enable_mask & BIT(otherid))) && enable; | ||||
| 	if (interleave) { | ||||
| 		unsigned int ctrl1; | ||||
|  | ||||
| 		err = regmap_bulk_read(hw->regmap, | ||||
| 				       ST_ILPS22QS_CTRL1_ADDR, | ||||
| 				       &ctrl1, 1); | ||||
| 		if (err < 0) | ||||
| 			goto unlock; | ||||
|  | ||||
| 		err = regmap_update_bits(hw->regmap, | ||||
| 					 ST_ILPS22QS_CTRL1_ADDR, | ||||
| 					 ST_ILPS22QS_ODR_MASK, 0); | ||||
| 		if (err < 0) | ||||
| 			goto unlock; | ||||
|  | ||||
| 		err = regmap_update_bits(hw->regmap, | ||||
| 					 ST_ILPS22QS_CTRL3_ADDR, | ||||
| 					 ST_ILPS22QS_AH_QVAR_EN_MASK, 0); | ||||
| 		if (err < 0) | ||||
| 			goto unlock; | ||||
|  | ||||
| 		err = regmap_update_bits(hw->regmap, ST_ILPS22QS_CTRL3_ADDR, | ||||
| 					 ST_ILPS22QS_AH_QVAR_P_AUTO_EN_MASK, | ||||
| 					 ST_ILPS22QS_SHIFT_VAL(interleave, | ||||
| 					    ST_ILPS22QS_AH_QVAR_P_AUTO_EN_MASK)); | ||||
| 		if (err < 0) | ||||
| 			goto unlock; | ||||
|  | ||||
| 		err = regmap_update_bits(hw->regmap, ST_ILPS22QS_CTRL1_ADDR, | ||||
| 					 ST_ILPS22QS_ODR_MASK, ctrl1); | ||||
| 		if (err < 0) | ||||
| 			goto unlock; | ||||
| 	} else if (hw->interleave) { | ||||
| 		err = regmap_update_bits(hw->regmap, ST_ILPS22QS_CTRL3_ADDR, | ||||
| 					 ST_ILPS22QS_AH_QVAR_P_AUTO_EN_MASK, 0); | ||||
| 		if (err < 0) | ||||
| 			goto unlock; | ||||
| 	} | ||||
|  | ||||
| 	hw->interleave = interleave; | ||||
|  | ||||
| unlock: | ||||
| 	mutex_unlock(&hw->lock); | ||||
|  | ||||
| 	return err; | ||||
| } | ||||
|  | ||||
| static int st_ilps22qs_hw_enable(struct st_ilps22qs_sensor *sensor, bool enable) | ||||
| { | ||||
| 	int ret = 0; | ||||
|  | ||||
| 	switch (sensor->id) { | ||||
| 	case ST_ILPS22QS_QVAR: | ||||
| 	case ST_ILPS22QS_PRESS: | ||||
| 		ret = st_ilps22qs_set_interleave(sensor, enable); | ||||
| 		break; | ||||
| 	default: | ||||
| 		return 0; | ||||
| 	} | ||||
|  | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| static int st_ilps22qs_set_enable(struct st_ilps22qs_sensor *sensor, | ||||
| 				  bool enable) | ||||
| { | ||||
| 	struct st_ilps22qs_hw *hw = sensor->hw; | ||||
| 	u8 odr = enable ? sensor->odr : 0; | ||||
| 	int err; | ||||
|  | ||||
| 	err = st_ilps22qs_hw_enable(sensor, enable); | ||||
| 	if (err < 0) | ||||
| 		return err; | ||||
|  | ||||
| 	err = st_ilps22qs_set_odr(sensor, odr); | ||||
| 	if (err < 0) | ||||
| 		return err; | ||||
|  | ||||
| 	mutex_lock(&hw->lock); | ||||
| 	if (enable) { | ||||
| 		ktime_t ktime = ktime_set(0, 1000000000 / sensor->odr); | ||||
|  | ||||
| 		hrtimer_start(&sensor->hr_timer, ktime, HRTIMER_MODE_REL); | ||||
| 		sensor->ktime = ktime; | ||||
| 		hw->enable_mask |= BIT(sensor->id); | ||||
| 	} else { | ||||
| 		cancel_work_sync(&sensor->iio_work); | ||||
| 		hrtimer_cancel(&sensor->hr_timer); | ||||
| 		hw->enable_mask &= ~BIT(sensor->id); | ||||
| 	} | ||||
|  | ||||
| 	if (!hw->interleave) { | ||||
| 		err = regmap_update_bits(hw->regmap, | ||||
| 					 ST_ILPS22QS_CTRL3_ADDR, | ||||
| 					 ST_ILPS22QS_AH_QVAR_EN_MASK, | ||||
| 					 ST_ILPS22QS_SHIFT_VAL(!!(hw->enable_mask & BIT(ST_ILPS22QS_QVAR)), | ||||
| 					  ST_ILPS22QS_AH_QVAR_EN_MASK)); | ||||
| 	} | ||||
| 	mutex_unlock(&hw->lock); | ||||
|  | ||||
| 	return err; | ||||
| } | ||||
|  | ||||
| static int st_ilps22qs_init_sensors(struct st_ilps22qs_hw *hw) | ||||
| { | ||||
| 	int err; | ||||
|  | ||||
| 	/* soft reset the device on power on */ | ||||
| 	err = st_ilps22qs_update_locked(hw, ST_ILPS22QS_CTRL2_ADDR, | ||||
| 					ST_ILPS22QS_SOFT_RESET_MASK, 1); | ||||
| 	if (err < 0) | ||||
| 		return err; | ||||
|  | ||||
| 	usleep_range(50, 60); | ||||
|  | ||||
| 	/* interleave disabled by default */ | ||||
| 	hw->interleave = false; | ||||
|  | ||||
| 	/* enable BDU */ | ||||
| 	return st_ilps22qs_update_locked(hw, ST_ILPS22QS_CTRL1_ADDR, | ||||
| 					 ST_ILPS22QS_BDU_MASK, 1); | ||||
| } | ||||
|  | ||||
| static ssize_t | ||||
| st_ilps22qs_get_sampling_frequency_avail(struct device *dev, | ||||
| 					 struct device_attribute *attr, | ||||
| 					 char *buf) | ||||
| { | ||||
| 	int i, len = 0; | ||||
|  | ||||
| 	for (i = 0; i < st_ilps22qs_odr_table.size; i++) { | ||||
| 		len += scnprintf(buf + len, PAGE_SIZE - len, "%d ", | ||||
| 				 st_ilps22qs_odr_table.odr_avl[i].hz); | ||||
| 	} | ||||
|  | ||||
| 	buf[len - 1] = '\n'; | ||||
|  | ||||
| 	return len; | ||||
| } | ||||
|  | ||||
| static int st_ilps22qs_read_raw(struct iio_dev *iio_dev, | ||||
| 				struct iio_chan_spec const *ch, | ||||
| 				int *val, int *val2, long mask) | ||||
| { | ||||
| 	struct st_ilps22qs_sensor *sensor = iio_priv(iio_dev); | ||||
| 	struct st_ilps22qs_hw *hw = sensor->hw; | ||||
| 	int ret; | ||||
|  | ||||
| 	switch (mask) { | ||||
| 	case IIO_CHAN_INFO_RAW: { | ||||
| 		u8 data[4] = {}; | ||||
| 		int delay; | ||||
|  | ||||
| 		ret = iio_device_claim_direct_mode(iio_dev); | ||||
| 		if (ret) | ||||
| 			return ret; | ||||
|  | ||||
| 		ret = st_ilps22qs_set_enable(sensor, true); | ||||
| 		if (ret < 0) | ||||
| 			goto read_error; | ||||
|  | ||||
| 		delay = 1000000 / sensor->odr; | ||||
| 		usleep_range(delay, 2 * delay); | ||||
|  | ||||
| 		ret = regmap_bulk_read(hw->regmap, ch->address, data, | ||||
| 				       ch->scan_type.realbits >> 3); | ||||
| 		if (ret < 0) | ||||
| 			goto read_error; | ||||
|  | ||||
| 		switch (sensor->id) { | ||||
| 		case ST_ILPS22QS_PRESS: | ||||
| 			*val = (s32)get_unaligned_le32(data); | ||||
| 			break; | ||||
| 		case ST_ILPS22QS_TEMP: | ||||
| 			*val = (s16)get_unaligned_le16(data); | ||||
| 			break; | ||||
| 		case ST_ILPS22QS_QVAR: | ||||
| 			*val = (s32)get_unaligned_le32(data); | ||||
| 			break; | ||||
| 		default: | ||||
| 			ret = -ENODEV; | ||||
| 			goto read_error; | ||||
| 		} | ||||
|  | ||||
| read_error: | ||||
| 		st_ilps22qs_set_enable(sensor, false); | ||||
| 		iio_device_release_direct_mode(iio_dev); | ||||
|  | ||||
| 		if (ret < 0) | ||||
| 			return ret; | ||||
|  | ||||
| 		ret = IIO_VAL_INT; | ||||
| 		break; | ||||
| 	} | ||||
| 	case IIO_CHAN_INFO_SCALE: | ||||
| 		switch (ch->type) { | ||||
| 		case IIO_TEMP: | ||||
| 			*val = 1000; | ||||
| 			*val2 = sensor->gain; | ||||
| 			ret = IIO_VAL_FRACTIONAL; | ||||
| 			break; | ||||
| 		case IIO_PRESSURE: | ||||
| 			*val = 0; | ||||
| 			*val2 = sensor->gain; | ||||
| 			ret = IIO_VAL_INT_PLUS_NANO; | ||||
| 			break; | ||||
| 		case IIO_ALTVOLTAGE: | ||||
| 			*val = 0; | ||||
| 			*val2 = sensor->gain; | ||||
| 			ret = IIO_VAL_INT_PLUS_NANO; | ||||
| 			break; | ||||
| 		default: | ||||
| 			ret = -ENODEV; | ||||
| 			break; | ||||
| 		} | ||||
| 		break; | ||||
| 	case IIO_CHAN_INFO_SAMP_FREQ: | ||||
| 		*val = sensor->odr; | ||||
| 		ret = IIO_VAL_INT; | ||||
| 		break; | ||||
| 	default: | ||||
| 		ret = -EINVAL; | ||||
| 		break; | ||||
| 	} | ||||
|  | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| static int st_ilps22qs_write_raw(struct iio_dev *iio_dev, | ||||
| 				 struct iio_chan_spec const *ch, | ||||
| 				 int val, int val2, long mask) | ||||
| { | ||||
| 	struct st_ilps22qs_sensor *sensor = iio_priv(iio_dev); | ||||
| 	int ret; | ||||
|  | ||||
| 	ret = iio_device_claim_direct_mode(iio_dev); | ||||
| 	if (ret) | ||||
| 		return ret; | ||||
|  | ||||
| 	switch (mask) { | ||||
| 	case IIO_CHAN_INFO_SAMP_FREQ: | ||||
| 		ret = st_ilps22qs_get_odr(sensor, val); | ||||
| 		if (ret < 0) | ||||
| 			goto exit_fail; | ||||
|  | ||||
| 		sensor->odr = st_ilps22qs_odr_table.odr_avl[ret].hz; | ||||
| 		break; | ||||
| 	default: | ||||
| 		ret = -EINVAL; | ||||
| 		break; | ||||
| 	} | ||||
|  | ||||
| exit_fail: | ||||
| 	iio_device_release_direct_mode(iio_dev); | ||||
|  | ||||
| 	return ret < 0 ? ret : 0; | ||||
| } | ||||
|  | ||||
| static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(st_ilps22qs_get_sampling_frequency_avail); | ||||
|  | ||||
| static struct attribute *st_ilps22qs_press_attributes[] = { | ||||
| 	&iio_dev_attr_sampling_frequency_available.dev_attr.attr, | ||||
| 	NULL, | ||||
| }; | ||||
|  | ||||
| static const struct attribute_group st_ilps22qs_press_attribute_group = { | ||||
| 	.attrs = st_ilps22qs_press_attributes, | ||||
| }; | ||||
|  | ||||
| static const struct iio_info st_ilps22qs_press_info = { | ||||
| 	.attrs = &st_ilps22qs_press_attribute_group, | ||||
| 	.read_raw = st_ilps22qs_read_raw, | ||||
| 	.write_raw = st_ilps22qs_write_raw, | ||||
| 	.debugfs_reg_access = st_ilps22qs_reg_access, | ||||
| }; | ||||
|  | ||||
| static struct attribute *st_ilps22qs_temp_attributes[] = { | ||||
| 	&iio_dev_attr_sampling_frequency_available.dev_attr.attr, | ||||
| 	NULL, | ||||
| }; | ||||
|  | ||||
| static const struct attribute_group st_ilps22qs_temp_attribute_group = { | ||||
| 	.attrs = st_ilps22qs_temp_attributes, | ||||
| }; | ||||
|  | ||||
| static const struct iio_info st_ilps22qs_temp_info = { | ||||
| 	.attrs = &st_ilps22qs_temp_attribute_group, | ||||
| 	.read_raw = st_ilps22qs_read_raw, | ||||
| 	.write_raw = st_ilps22qs_write_raw, | ||||
| 	.debugfs_reg_access = st_ilps22qs_reg_access, | ||||
| }; | ||||
|  | ||||
| static struct attribute *st_ilps22qs_qvar_attributes[] = { | ||||
| 	&iio_dev_attr_sampling_frequency_available.dev_attr.attr, | ||||
| 	NULL, | ||||
| }; | ||||
|  | ||||
| static const struct attribute_group st_ilps22qs_qvar_attribute_group = { | ||||
| 	.attrs = st_ilps22qs_qvar_attributes, | ||||
| }; | ||||
|  | ||||
| static const struct iio_info st_ilps22qs_qvar_info = { | ||||
| 	.attrs = &st_ilps22qs_qvar_attribute_group, | ||||
| 	.read_raw = st_ilps22qs_read_raw, | ||||
| 	.write_raw = st_ilps22qs_write_raw, | ||||
| 	.debugfs_reg_access = st_ilps22qs_reg_access, | ||||
| }; | ||||
|  | ||||
| static int st_ilps22qs_preenable(struct iio_dev *iio_dev) | ||||
| { | ||||
| 	struct st_ilps22qs_sensor *sensor = iio_priv(iio_dev); | ||||
|  | ||||
| 	return st_ilps22qs_set_enable(sensor, true); | ||||
| } | ||||
|  | ||||
| static int st_ilps22qs_postdisable(struct iio_dev *iio_dev) | ||||
| { | ||||
| 	struct st_ilps22qs_sensor *sensor = iio_priv(iio_dev); | ||||
|  | ||||
| 	return st_ilps22qs_set_enable(sensor, false); | ||||
| } | ||||
|  | ||||
| static const struct iio_buffer_setup_ops st_ilps22qs_fifo_ops = { | ||||
| 	.preenable = st_ilps22qs_preenable, | ||||
| 	.postdisable = st_ilps22qs_postdisable, | ||||
| }; | ||||
|  | ||||
| static void st_ilps22qs_disable_regulator_action(void *_data) | ||||
| { | ||||
| 	struct st_ilps22qs_hw *hw = _data; | ||||
|  | ||||
| 	regulator_disable(hw->vddio_supply); | ||||
| 	regulator_disable(hw->vdd_supply); | ||||
| } | ||||
|  | ||||
| static int st_ilps22qs_power_enable(struct st_ilps22qs_hw *hw) | ||||
| { | ||||
| 	int err; | ||||
|  | ||||
| 	hw->vdd_supply = devm_regulator_get(hw->dev, "vdd"); | ||||
| 	if (IS_ERR(hw->vdd_supply)) { | ||||
| 		if (PTR_ERR(hw->vdd_supply) != -EPROBE_DEFER) | ||||
| 			dev_err(hw->dev, "Failed to get vdd regulator %d\n", | ||||
| 				(int)PTR_ERR(hw->vdd_supply)); | ||||
|  | ||||
| 		return PTR_ERR(hw->vdd_supply); | ||||
| 	} | ||||
|  | ||||
| 	hw->vddio_supply = devm_regulator_get(hw->dev, "vddio"); | ||||
| 	if (IS_ERR(hw->vddio_supply)) { | ||||
| 		if (PTR_ERR(hw->vddio_supply) != -EPROBE_DEFER) | ||||
| 			dev_err(hw->dev, "Failed to get vddio regulator %d\n", | ||||
| 				(int)PTR_ERR(hw->vddio_supply)); | ||||
|  | ||||
| 		return PTR_ERR(hw->vddio_supply); | ||||
| 	} | ||||
|  | ||||
| 	err = regulator_enable(hw->vdd_supply); | ||||
| 	if (err) { | ||||
| 		dev_err(hw->dev, "Failed to enable vdd regulator: %d\n", err); | ||||
|  | ||||
| 		return err; | ||||
| 	} | ||||
|  | ||||
| 	err = regulator_enable(hw->vddio_supply); | ||||
| 	if (err) { | ||||
| 		regulator_disable(hw->vdd_supply); | ||||
|  | ||||
| 		return err; | ||||
| 	} | ||||
|  | ||||
| 	err = devm_add_action_or_reset(hw->dev, | ||||
| 				       st_ilps22qs_disable_regulator_action, | ||||
| 				       hw); | ||||
| 	if (err) { | ||||
| 		dev_err(hw->dev, | ||||
| 			"Failed to setup regulator cleanup action %d\n", err); | ||||
|  | ||||
| 		return err; | ||||
| 	} | ||||
|  | ||||
| 	/* | ||||
| 	 * after the device is powered up, the ILPS22QS performs a 10 ms | ||||
| 	 * boot procedure to load the trimming parameters | ||||
| 	 */ | ||||
| 	usleep_range(10000, 11000); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static struct iio_dev *st_ilps22qs_alloc_iiodev(struct st_ilps22qs_hw *hw, | ||||
| 						enum st_ilps22qs_sensor_id id) | ||||
| { | ||||
| 	struct st_ilps22qs_sensor *sensor; | ||||
| 	struct iio_dev *iio_dev; | ||||
|  | ||||
| 	iio_dev = devm_iio_device_alloc(hw->dev, sizeof(*sensor)); | ||||
| 	if (!iio_dev) | ||||
| 		return NULL; | ||||
|  | ||||
| 	iio_dev->modes = INDIO_DIRECT_MODE; | ||||
| 	iio_dev->dev.parent = hw->dev; | ||||
|  | ||||
| 	sensor = iio_priv(iio_dev); | ||||
| 	sensor->hw = hw; | ||||
| 	sensor->id = id; | ||||
| 	sensor->odr = st_ilps22qs_odr_table.odr_avl[0].hz; | ||||
|  | ||||
| 	switch (id) { | ||||
| 	case ST_ILPS22QS_PRESS: | ||||
| 		sensor->gain = ST_ILPS22QS_PRESS_FS_AVL_GAIN; | ||||
| 		scnprintf(sensor->name, sizeof(sensor->name), | ||||
| 			  ST_ILPS22QS_DEV_NAME "_press"); | ||||
| 		iio_dev->channels = st_ilps22qs_press_channels; | ||||
| 		iio_dev->num_channels = ARRAY_SIZE(st_ilps22qs_press_channels); | ||||
| 		iio_dev->info = &st_ilps22qs_press_info; | ||||
| 		break; | ||||
| 	case ST_ILPS22QS_TEMP: | ||||
| 		sensor->gain = ST_ILPS22QS_TEMP_FS_AVL_GAIN; | ||||
| 		scnprintf(sensor->name, sizeof(sensor->name), | ||||
| 			  ST_ILPS22QS_DEV_NAME "_temp"); | ||||
| 		iio_dev->channels = st_ilps22qs_temp_channels; | ||||
| 		iio_dev->num_channels = ARRAY_SIZE(st_ilps22qs_temp_channels); | ||||
| 		iio_dev->info = &st_ilps22qs_temp_info; | ||||
| 		break; | ||||
| 	case ST_ILPS22QS_QVAR: | ||||
| 		sensor->gain = ST_ILPS22QS_QVAR_FS_AVL_GAIN; | ||||
| 		scnprintf(sensor->name, sizeof(sensor->name), | ||||
| 			  ST_ILPS22QS_DEV_NAME "_qvar"); | ||||
| 		iio_dev->channels = st_ilps22qs_qvar_channels; | ||||
| 		iio_dev->num_channels = ARRAY_SIZE(st_ilps22qs_qvar_channels); | ||||
| 		iio_dev->info = &st_ilps22qs_qvar_info; | ||||
| 		break; | ||||
| 	default: | ||||
| 		return NULL; | ||||
| 	} | ||||
|  | ||||
| 	iio_dev->name = sensor->name; | ||||
|  | ||||
| 	/* configure sensor hrtimer */ | ||||
| 	hrtimer_init(&sensor->hr_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | ||||
| 	sensor->hr_timer.function = &st_ilps22qs_poll_function_read; | ||||
| 	INIT_WORK(&sensor->iio_work, st_ilps22qs_poll_function_work); | ||||
|  | ||||
| 	return iio_dev; | ||||
| } | ||||
|  | ||||
| int st_ilps22qs_probe(struct device *dev, struct regmap *regmap) | ||||
| { | ||||
| 	struct st_ilps22qs_hw *hw; | ||||
| 	int err, i; | ||||
|  | ||||
| 	hw = devm_kzalloc(dev, sizeof(*hw), GFP_KERNEL); | ||||
| 	if (!hw) | ||||
| 		return -ENOMEM; | ||||
|  | ||||
| 	mutex_init(&hw->lock); | ||||
|  | ||||
| 	dev_set_drvdata(dev, (void *)hw); | ||||
| 	hw->dev = dev; | ||||
| 	hw->regmap = regmap; | ||||
|  | ||||
| 	err = st_ilps22qs_power_enable(hw); | ||||
| 	if (err) | ||||
| 		return err; | ||||
|  | ||||
| 	err = st_ilps22qs_check_whoami(hw); | ||||
| 	if (err < 0) | ||||
| 		return err; | ||||
|  | ||||
| 	err = st_ilps22qs_init_sensors(hw); | ||||
| 	if (err < 0) | ||||
| 		return err; | ||||
|  | ||||
| 	for (i = 0; i < ST_ILPS22QS_SENSORS_NUM; i++) { | ||||
|  | ||||
| #if KERNEL_VERSION(5, 13, 0) > LINUX_VERSION_CODE | ||||
| 		struct iio_buffer *buffer; | ||||
| #endif /* LINUX_VERSION_CODE */ | ||||
|  | ||||
| 		hw->iio_devs[i] = st_ilps22qs_alloc_iiodev(hw, i); | ||||
| 		if (!hw->iio_devs[i]) | ||||
| 			return -ENOMEM; | ||||
|  | ||||
| #if KERNEL_VERSION(5, 19, 0) <= LINUX_VERSION_CODE | ||||
| 		err = devm_iio_kfifo_buffer_setup(hw->dev, | ||||
| 						  hw->iio_devs[i], | ||||
| 						  &st_ilps22qs_fifo_ops); | ||||
| 		if (err) | ||||
| 			return err; | ||||
| #elif KERNEL_VERSION(5, 13, 0) <= LINUX_VERSION_CODE | ||||
| 		err = devm_iio_kfifo_buffer_setup(hw->dev, hw->iio_devs[i], | ||||
| 						  INDIO_BUFFER_SOFTWARE, | ||||
| 						  &st_ilps22qs_fifo_ops); | ||||
| 		if (err) | ||||
| 			return err; | ||||
| #else /* LINUX_VERSION_CODE */ | ||||
| 		buffer = devm_iio_kfifo_allocate(hw->dev); | ||||
| 		if (!buffer) | ||||
| 			return -ENOMEM; | ||||
|  | ||||
| 		iio_device_attach_buffer(hw->iio_devs[i], buffer); | ||||
| 		hw->iio_devs[i]->modes |= INDIO_BUFFER_SOFTWARE; | ||||
| 		hw->iio_devs[i]->setup_ops = &st_ilps22qs_fifo_ops; | ||||
| #endif /* LINUX_VERSION_CODE */ | ||||
|  | ||||
| 		err = devm_iio_device_register(hw->dev, hw->iio_devs[i]); | ||||
| 		if (err) | ||||
| 			return err; | ||||
| 	} | ||||
|  | ||||
| 	err = st_ilps22qs_allocate_workqueue(hw); | ||||
| 	if (err) | ||||
| 		return err; | ||||
|  | ||||
| 	dev_info(dev, "device probed\n"); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
| EXPORT_SYMBOL(st_ilps22qs_probe); | ||||
|  | ||||
| int st_ilps22qs_remove(struct device *dev) | ||||
| { | ||||
| 	struct st_ilps22qs_hw *hw = dev_get_drvdata(dev); | ||||
| 	struct st_ilps22qs_sensor *sensor; | ||||
| 	int i; | ||||
|  | ||||
| 	for (i = 0; i < ST_ILPS22QS_SENSORS_NUM; i++) { | ||||
| 		int err; | ||||
|  | ||||
| 		if (!hw->iio_devs[i]) | ||||
| 			continue; | ||||
|  | ||||
| 		sensor = iio_priv(hw->iio_devs[i]); | ||||
| 		if (!(hw->enable_mask & BIT(sensor->id))) | ||||
| 			continue; | ||||
|  | ||||
| 		err = st_ilps22qs_set_enable(sensor, false); | ||||
| 		if (err < 0) | ||||
| 			return err; | ||||
| 	} | ||||
|  | ||||
| 	st_ilps22qs_flush_works(hw); | ||||
| 	st_ilps22qs_destroy_workqueue(hw); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
| EXPORT_SYMBOL(st_ilps22qs_remove); | ||||
|  | ||||
| static int __maybe_unused st_ilps22qs_suspend(struct device *dev) | ||||
| { | ||||
| 	struct st_ilps22qs_hw *hw = dev_get_drvdata(dev); | ||||
| 	struct st_ilps22qs_sensor *sensor; | ||||
| 	int i; | ||||
|  | ||||
| 	for (i = 0; i < ST_ILPS22QS_SENSORS_NUM; i++) { | ||||
| 		int err; | ||||
|  | ||||
| 		if (!hw->iio_devs[i]) | ||||
| 			continue; | ||||
|  | ||||
| 		sensor = iio_priv(hw->iio_devs[i]); | ||||
| 		if (!(hw->enable_mask & BIT(sensor->id))) | ||||
| 			continue; | ||||
|  | ||||
| 		err = st_ilps22qs_set_odr(sensor, 0); | ||||
| 		if (err < 0) | ||||
| 			return err; | ||||
|  | ||||
| 		cancel_work_sync(&sensor->iio_work); | ||||
| 		hrtimer_cancel(&sensor->hr_timer); | ||||
| 	} | ||||
|  | ||||
| 	dev_info(dev, "Suspending device\n"); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static int __maybe_unused st_ilps22qs_resume(struct device *dev) | ||||
| { | ||||
| 	struct st_ilps22qs_hw *hw = dev_get_drvdata(dev); | ||||
| 	struct st_ilps22qs_sensor *sensor; | ||||
| 	int i; | ||||
|  | ||||
| 	dev_info(dev, "Resuming device\n"); | ||||
|  | ||||
| 	for (i = 0; i < ST_ILPS22QS_SENSORS_NUM; i++) { | ||||
| 		int err; | ||||
|  | ||||
| 		if (!hw->iio_devs[i]) | ||||
| 			continue; | ||||
|  | ||||
| 		sensor = iio_priv(hw->iio_devs[i]); | ||||
| 		if (!(hw->enable_mask & BIT(sensor->id))) | ||||
| 			continue; | ||||
|  | ||||
| 		err = st_ilps22qs_set_enable(sensor, true); | ||||
| 		if (err < 0) | ||||
| 			return err; | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| const struct dev_pm_ops st_ilps22qs_pm_ops = { | ||||
| 	SET_SYSTEM_SLEEP_PM_OPS(st_ilps22qs_suspend, st_ilps22qs_resume) | ||||
| }; | ||||
| EXPORT_SYMBOL(st_ilps22qs_pm_ops); | ||||
|  | ||||
| MODULE_AUTHOR("MEMS Software Solutions Team"); | ||||
| MODULE_DESCRIPTION("STMicroelectronics ilps22qs driver"); | ||||
| MODULE_LICENSE("GPL v2"); | ||||
| @@ -0,0 +1,86 @@ | ||||
| // SPDX-License-Identifier: GPL-2.0-only | ||||
| /* | ||||
|  * STMicroelectronics ilps22qs i2c driver | ||||
|  * | ||||
|  * Copyright 2023 STMicroelectronics Inc. | ||||
|  * | ||||
|  * MEMS Software Solutions Team | ||||
|  */ | ||||
|  | ||||
| #include <linux/kernel.h> | ||||
| #include <linux/i2c.h> | ||||
| #include <linux/iio/iio.h> | ||||
| #include <linux/kernel.h> | ||||
| #include <linux/module.h> | ||||
| #include <linux/version.h> | ||||
|  | ||||
| #include "st_ilps22qs.h" | ||||
|  | ||||
| static const struct regmap_config st_ilps22qs_i2c_regmap_config = { | ||||
| 	.reg_bits = 8, | ||||
| 	.val_bits = 8, | ||||
| }; | ||||
|  | ||||
| #if KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE | ||||
| static int st_ilps22qs_i2c_probe(struct i2c_client *client) | ||||
| #else /* LINUX_VERSION_CODE */ | ||||
| static int st_ilps22qs_i2c_probe(struct i2c_client *client, | ||||
| 				 const struct i2c_device_id *id) | ||||
| #endif /* LINUX_VERSION_CODE */ | ||||
| { | ||||
| 	struct regmap *regmap; | ||||
|  | ||||
| 	regmap = devm_regmap_init_i2c(client, &st_ilps22qs_i2c_regmap_config); | ||||
| 	if (IS_ERR(regmap)) { | ||||
| 		dev_err(&client->dev, | ||||
| 			"Failed to register i2c regmap %d\n", | ||||
| 			(int)PTR_ERR(regmap)); | ||||
|  | ||||
| 		return PTR_ERR(regmap); | ||||
| 	} | ||||
|  | ||||
| 	return st_ilps22qs_probe(&client->dev, regmap); | ||||
| } | ||||
|  | ||||
| #if KERNEL_VERSION(6, 1, 0) <= LINUX_VERSION_CODE | ||||
| static void st_ilps22qs_i2c_remove(struct i2c_client *client) | ||||
| { | ||||
| 	st_ilps22qs_remove(&client->dev); | ||||
| } | ||||
| #else /* LINUX_VERSION_CODE */ | ||||
| static int st_ilps22qs_i2c_remove(struct i2c_client *client) | ||||
| { | ||||
| 	return st_ilps22qs_remove(&client->dev); | ||||
| } | ||||
| #endif /* LINUX_VERSION_CODE */ | ||||
|  | ||||
| static const struct i2c_device_id st_ilps22qs_ids[] = { | ||||
| 	{ ST_ILPS22QS_DEV_NAME }, | ||||
| 	{ ST_ILPS28QSW_DEV_NAME }, | ||||
| 	{} | ||||
| }; | ||||
| MODULE_DEVICE_TABLE(i2c, st_ilps22qs_ids); | ||||
|  | ||||
| static const struct of_device_id st_ilps22qs_id_table[] = { | ||||
| 	{ .compatible = "st," ST_ILPS22QS_DEV_NAME }, | ||||
| 	{ .compatible = "st," ST_ILPS28QSW_DEV_NAME }, | ||||
| 	{}, | ||||
| }; | ||||
| MODULE_DEVICE_TABLE(of, st_ilps22qs_id_table); | ||||
|  | ||||
| static struct i2c_driver st_ilps22qs_i2c_driver = { | ||||
| 	.driver = { | ||||
| 		.owner = THIS_MODULE, | ||||
| 		.name = "st_" ST_ILPS22QS_DEV_NAME "_i2c", | ||||
| 		.pm = &st_ilps22qs_pm_ops, | ||||
| 		.of_match_table = of_match_ptr(st_ilps22qs_id_table), | ||||
| 	}, | ||||
| 	.probe = st_ilps22qs_i2c_probe, | ||||
| 	.remove = st_ilps22qs_i2c_remove, | ||||
| 	.id_table = st_ilps22qs_ids, | ||||
| }; | ||||
| module_i2c_driver(st_ilps22qs_i2c_driver); | ||||
|  | ||||
| MODULE_AUTHOR("MEMS Software Solutions Team"); | ||||
| MODULE_DESCRIPTION("STMicroelectronics ilps22qs i2c driver"); | ||||
| MODULE_LICENSE("GPL v2"); | ||||
| @@ -0,0 +1,6 @@ | ||||
|  | ||||
| config INPUT_LSM303AGR | ||||
|          tristate "STM LSM303AGR sensor" | ||||
|          depends on I2C && SYSFS | ||||
|          help | ||||
|            This driver support the STMicroelectronics LSM303AGR sensor. | ||||
| @@ -0,0 +1,7 @@ | ||||
| # | ||||
| # Makefile for the input misc lsm303agr driver. | ||||
| # | ||||
|  | ||||
| # Each configuration option enables a list of files. | ||||
|  | ||||
| obj-$(CONFIG_INPUT_LSM303AGR) += lsm303agr_acc.o lsm303agr_mag.o lsm303agr_acc_i2c.o lsm303agr_mag_i2c.o | ||||
| @@ -0,0 +1,885 @@ | ||||
| /* | ||||
|  * STMicroelectronics lsm303agr_acc.c driver | ||||
|  * | ||||
|  * Copyright 2016 STMicroelectronics Inc. | ||||
|  * | ||||
|  * Giuseppe Barba <giuseppe.barba@st.com> | ||||
|  * | ||||
|  * Licensed under the GPL-2. | ||||
|  */ | ||||
|  | ||||
| #include <linux/err.h> | ||||
| #include <linux/errno.h> | ||||
| #include <linux/delay.h> | ||||
| #include <linux/fs.h> | ||||
| #include <linux/i2c.h> | ||||
| #include <linux/input.h> | ||||
| #include <linux/uaccess.h> | ||||
| #include <linux/workqueue.h> | ||||
| #include <linux/irq.h> | ||||
| #include <linux/gpio.h> | ||||
| #include <linux/interrupt.h> | ||||
| #include <linux/kernel.h> | ||||
| #include <linux/device.h> | ||||
| #include <linux/module.h> | ||||
| #include <linux/moduleparam.h> | ||||
| #include <linux/version.h> | ||||
|  | ||||
| #include "lsm303agr_core.h" | ||||
|  | ||||
| #define LSM303AGR_ACC_DEV_NAME	"lsm303agr_acc" | ||||
|  | ||||
| #define LSM303AGR_ACC_MIN_POLL_PERIOD_MS 1 | ||||
|  | ||||
| /* I2C slave address */ | ||||
| #define LSM303AGR_ACC_I2C_SAD	0x29 | ||||
| /* Accelerometer Sensor Full Scale */ | ||||
| #define	LSM303AGR_ACC_FS_MSK	0x20 | ||||
| #define LSM303AGR_ACC_G_2G	0x00 | ||||
| #define LSM303AGR_ACC_G_8G	0x20 | ||||
|  | ||||
| #define AXISDATA_REG		0x28 | ||||
| #define WHOAMI_LSM303AGR_ACC	0x33 | ||||
| #define WHO_AM_I		0x0F | ||||
| #define CTRL_REG1		0x20 | ||||
| #define CTRL_REG2		0x23 | ||||
|  | ||||
| #define LSM303AGR_ACC_PM_OFF		0x00 | ||||
| #define LSM303AGR_ACC_ENABLE_ALL_AXIS	0x07 | ||||
| #define LSM303AGR_ACC_AXIS_MSK		0x07 | ||||
| #define LSM303AGR_ACC_ODR_MSK		0xf0 | ||||
| #define LSM303AGR_ACC_LP_MSK		0X08 | ||||
| #define LSM303AGR_ACC_HR_MSK		0X08 | ||||
|  | ||||
| /* device opmode */ | ||||
| enum lsm303agr_acc_opmode { | ||||
| 	LSM303AGR_ACC_OPMODE_NORMAL, | ||||
| 	LSM303AGR_ACC_OPMODE_HR, | ||||
| 	LSM303AGR_ACC_OPMODE_LP, | ||||
| }; | ||||
|  | ||||
| /* Device sensitivities [ug/digit] */ | ||||
| #define LSM303AGR_ACC_SENSITIVITY_NORMAL_2G	3900 | ||||
| #define LSM303AGR_ACC_SENSITIVITY_NORMAL_4G	7820 | ||||
| #define LSM303AGR_ACC_SENSITIVITY_NORMAL_8G	15630 | ||||
| #define LSM303AGR_ACC_SENSITIVITY_NORMAL_16G	46900 | ||||
| #define LSM303AGR_ACC_SENSITIVITY_HR_2G		980 | ||||
| #define LSM303AGR_ACC_SENSITIVITY_HR_4G		1950 | ||||
| #define LSM303AGR_ACC_SENSITIVITY_HR_8G		3900 | ||||
| #define LSM303AGR_ACC_SENSITIVITY_HR_16G	11720 | ||||
| #define LSM303AGR_ACC_SENSITIVITY_LP_2G		15630 | ||||
| #define LSM303AGR_ACC_SENSITIVITY_LP_4G		31260 | ||||
| #define LSM303AGR_ACC_SENSITIVITY_LP_8G		62520 | ||||
| #define LSM303AGR_ACC_SENSITIVITY_LP_16G	187580 | ||||
|  | ||||
| /* Device shift values */ | ||||
| #define LSM303AGR_ACC_SHIFT_NORMAL_MODE	6 | ||||
| #define LSM303AGR_ACC_SHIFT_HR_MODE	4 | ||||
| #define LSM303AGR_ACC_SHIFT_LP_MODE	8 | ||||
|  | ||||
| const struct { | ||||
| 	u16 shift; | ||||
| 	u32 sensitivity[4]; | ||||
| } lsm303agr_acc_opmode_table[] = { | ||||
| 	{ | ||||
| 		/* normal mode */ | ||||
| 		LSM303AGR_ACC_SHIFT_NORMAL_MODE, | ||||
| 		{ | ||||
| 			LSM303AGR_ACC_SENSITIVITY_NORMAL_2G, | ||||
| 			LSM303AGR_ACC_SENSITIVITY_NORMAL_4G, | ||||
| 			LSM303AGR_ACC_SENSITIVITY_NORMAL_8G, | ||||
| 			LSM303AGR_ACC_SENSITIVITY_NORMAL_16G | ||||
| 		} | ||||
| 	}, | ||||
| 	{ | ||||
| 		/* hr mode */ | ||||
| 		LSM303AGR_ACC_SHIFT_HR_MODE, | ||||
| 		{ | ||||
| 			LSM303AGR_ACC_SENSITIVITY_HR_2G, | ||||
| 			LSM303AGR_ACC_SENSITIVITY_HR_4G, | ||||
| 			LSM303AGR_ACC_SENSITIVITY_HR_8G, | ||||
| 			LSM303AGR_ACC_SENSITIVITY_HR_16G | ||||
| 		} | ||||
| 	}, | ||||
| 	{ | ||||
| 		/* lp mode */ | ||||
| 		LSM303AGR_ACC_SHIFT_LP_MODE, | ||||
| 		{ | ||||
| 			LSM303AGR_ACC_SENSITIVITY_LP_2G, | ||||
| 			LSM303AGR_ACC_SENSITIVITY_LP_4G, | ||||
| 			LSM303AGR_ACC_SENSITIVITY_LP_8G, | ||||
| 			LSM303AGR_ACC_SENSITIVITY_LP_16G | ||||
| 		} | ||||
| 	} | ||||
| }; | ||||
|  | ||||
| #define LSM303AGR_ACC_ODR10	0x20  /* 10Hz output data rate */ | ||||
| #define LSM303AGR_ACC_ODR50	0x40  /* 50Hz output data rate */ | ||||
| #define LSM303AGR_ACC_ODR100	0x50  /* 100Hz output data rate */ | ||||
| #define LSM303AGR_ACC_ODR200	0x60  /* 200Hz output data rate */ | ||||
|  | ||||
| /* read and write with mask a given register */ | ||||
| static int lsm303agr_acc_write_data_with_mask(struct lsm303agr_common_data *cdata, | ||||
| 					      u8 reg_addr, u8 mask, u8 *data) | ||||
| { | ||||
| 	int err; | ||||
| 	u8 new_data, old_data = 0; | ||||
|  | ||||
| 	err = cdata->tf->read(cdata->dev, reg_addr, 1, &old_data); | ||||
| 	if (err < 0) | ||||
| 		return err; | ||||
|  | ||||
| 	new_data = ((old_data & (~mask)) | ((*data) & mask)); | ||||
|  | ||||
| #ifdef LSM303AGR_ACC_DEBUG | ||||
| 	dev_info(cdata->dev, "%s %02x o=%02x d=%02x n=%02x\n", | ||||
| 		 LSM303AGR_ACC_DEV_NAME, reg_addr, old_data, *data, new_data); | ||||
| #endif | ||||
|  | ||||
| 	/* Save for caller usage the data that is about to be written */ | ||||
| 	*data = new_data; | ||||
|  | ||||
| 	if (new_data == old_data) | ||||
| 		return 1; | ||||
|  | ||||
| 	return cdata->tf->write(cdata->dev, reg_addr, 1, &new_data); | ||||
| } | ||||
|  | ||||
| static int lsm303agr_acc_input_init(struct lsm303agr_sensor_data *sdata, | ||||
| 				    const char* description) | ||||
| { | ||||
| 	int err; | ||||
|  | ||||
| 	sdata->input_dev = input_allocate_device(); | ||||
| 	if (!sdata->input_dev) { | ||||
| 		dev_err(sdata->cdata->dev, "input device allocation failed\n"); | ||||
| 		return -ENOMEM; | ||||
| 	} | ||||
|  | ||||
| 	sdata->input_dev->name = description; | ||||
| 	sdata->input_dev->id.bustype = sdata->cdata->bus_type; | ||||
| 	sdata->input_dev->dev.parent = sdata->cdata->dev; | ||||
|  | ||||
| 	input_set_drvdata(sdata->input_dev, sdata); | ||||
|  | ||||
| 	/* Set the input event characteristics of the probed sensor driver */ | ||||
| 	set_bit(INPUT_EVENT_TYPE, sdata->input_dev->evbit); | ||||
| 	set_bit(INPUT_EVENT_TIME_MSB, sdata->input_dev->mscbit); | ||||
| 	set_bit(INPUT_EVENT_TIME_LSB, sdata->input_dev->mscbit); | ||||
| 	set_bit(INPUT_EVENT_X, sdata->input_dev->mscbit); | ||||
| 	set_bit(INPUT_EVENT_Y, sdata->input_dev->mscbit); | ||||
| 	set_bit(INPUT_EVENT_Z, sdata->input_dev->mscbit); | ||||
|  | ||||
| 	err = input_register_device(sdata->input_dev); | ||||
| 	if (err) { | ||||
| 		dev_err(sdata->cdata->dev, | ||||
| 			"unable to register input device %s\n", | ||||
| 			sdata->input_dev->name); | ||||
| 		input_free_device(sdata->input_dev); | ||||
| 		return err; | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| struct { | ||||
| 	unsigned int cutoff_ms; | ||||
| 	unsigned int mask; | ||||
| } lsm303agr_acc_odr_table[] = { | ||||
| 	{    5, LSM303AGR_ACC_ODR200  }, /* ODR = 200Hz */ | ||||
| 	{   10, LSM303AGR_ACC_ODR100  }, /* ODR = 100Hz */ | ||||
| 	{   20, LSM303AGR_ACC_ODR50   }, /* ODR = 50Hz */ | ||||
| 	{  100, LSM303AGR_ACC_ODR10   }, /* ODR = 10Hz */ | ||||
| }; | ||||
|  | ||||
| static int lsm303agr_acc_hw_init(struct lsm303agr_common_data *cdata) | ||||
| { | ||||
| 	int err; | ||||
| 	u8 buf, wai = 0; | ||||
|  | ||||
| #ifdef LSM303AGR_ACC_DEBUG | ||||
| 	pr_info("%s: hw init start\n", LSM303AGR_ACC_DEV_NAME); | ||||
| #endif | ||||
|  | ||||
| 	err = cdata->tf->read(cdata->dev, WHO_AM_I, 1, &wai); | ||||
| 	if (err < 0) { | ||||
| 		dev_warn(cdata->dev, "Error reading WHO_AM_I\n"); | ||||
| 		goto error; | ||||
| 	} | ||||
|  | ||||
| 	if (wai != WHOAMI_LSM303AGR_ACC) { | ||||
| 		dev_err(cdata->dev, | ||||
| 			"device unknown (0x%02x-0x%02x)\n", | ||||
| 			WHOAMI_LSM303AGR_ACC, wai); | ||||
| 		err = -1; /* choose the right coded error */ | ||||
| 		goto error; | ||||
| 	} | ||||
|  | ||||
| 	buf = cdata->sensors[LSM303AGR_ACC_SENSOR].c_odr; | ||||
| 	err = lsm303agr_acc_write_data_with_mask(cdata, CTRL_REG1, | ||||
| 						 LSM303AGR_ACC_ODR_MSK, &buf); | ||||
| 	if (err < 0) | ||||
| 		goto error; | ||||
|  | ||||
| 	cdata->hw_initialized = 1; | ||||
|  | ||||
| #ifdef LSM303AGR_ACC_DEBUG | ||||
| 	pr_info("%s: hw init done\n", LSM303AGR_ACC_DEV_NAME); | ||||
| #endif | ||||
| 	return 0; | ||||
|  | ||||
| error: | ||||
| 	cdata->hw_initialized = 0; | ||||
| 	dev_err(cdata->dev, "hw init error 0x%02x: %d\n", buf, err); | ||||
|  | ||||
| 	return err; | ||||
| } | ||||
|  | ||||
| static void lsm303agr_acc_device_power_off(struct lsm303agr_common_data *cdata) | ||||
| { | ||||
| 	int err; | ||||
| 	u8 buf = LSM303AGR_ACC_PM_OFF; | ||||
|  | ||||
| 	err = lsm303agr_acc_write_data_with_mask(cdata, CTRL_REG1, | ||||
| 						 LSM303AGR_ACC_ODR_MSK, &buf); | ||||
| 	if (err < 0) | ||||
| 		dev_err(cdata->dev, "soft power off failed: %d\n", err); | ||||
|  | ||||
| 	if (cdata->hw_initialized) | ||||
| 		cdata->hw_initialized = 0; | ||||
| } | ||||
|  | ||||
| static int lsm303agr_acc_device_power_on(struct lsm303agr_common_data *cdata) | ||||
| { | ||||
| 	if (!cdata->hw_initialized) { | ||||
| 		int err = lsm303agr_acc_hw_init(cdata); | ||||
| 		if (err < 0) { | ||||
| 			lsm303agr_acc_device_power_off(cdata); | ||||
| 			return err; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static int lsm303agr_acc_update_fs_range(struct lsm303agr_common_data *cdata, | ||||
| 					 u8 new_fs_range) | ||||
| { | ||||
| 	int err; | ||||
| 	u8 indx; | ||||
| 	u16 opmode; | ||||
| 	unsigned int new_sensitivity; | ||||
| 	struct lsm303agr_sensor_data *sdata; | ||||
|  | ||||
| 	sdata = &cdata->sensors[LSM303AGR_ACC_SENSOR]; | ||||
| 	opmode = sdata->opmode; | ||||
|  | ||||
| 	switch (new_fs_range) { | ||||
| 	case LSM303AGR_ACC_G_2G: | ||||
| 		indx = 0; | ||||
| 		break; | ||||
| 	case LSM303AGR_ACC_G_8G: | ||||
| 		indx = 2; | ||||
| 		break; | ||||
| 	default: | ||||
| 		dev_err(cdata->dev, "invalid fs range requested: %u\n", | ||||
| 			new_fs_range); | ||||
| 		return -EINVAL; | ||||
| 	} | ||||
|  | ||||
| 	/* Updates configuration register 4 which contains fs range setting */ | ||||
| 	err = lsm303agr_acc_write_data_with_mask(cdata, CTRL_REG2, | ||||
| 						 LSM303AGR_ACC_FS_MSK, | ||||
| 						 &new_fs_range); | ||||
| 	if (err < 0) | ||||
| 		goto error; | ||||
|  | ||||
| 	new_sensitivity = lsm303agr_acc_opmode_table[opmode].sensitivity[indx]; | ||||
| 	sdata->sensitivity = new_sensitivity; | ||||
|  | ||||
| #ifdef LSM303AGR_ACC_DEBUG | ||||
| 	dev_info(cdata->dev, "%s shift=%d, sens=%d, opm=%d\n", | ||||
| 		 LSM303AGR_ACC_DEV_NAME, sdata->shift, sdata->sensitivity, | ||||
| 		 sdata->opmode); | ||||
| #endif | ||||
|  | ||||
| 	return err; | ||||
| error: | ||||
| 	dev_err(cdata->dev, "update fs range failed %d\n", err); | ||||
|  | ||||
| 	return err; | ||||
| } | ||||
|  | ||||
| static int lsm303agr_acc_update_odr(struct lsm303agr_common_data *cdata, | ||||
| 							int poll_interval) | ||||
| { | ||||
| 	u8 buf; | ||||
| 	int i, err = -1; | ||||
| 	struct lsm303agr_sensor_data *sdata; | ||||
|  | ||||
| 	/** | ||||
| 	 * Following, looks for the longest possible odr | ||||
| 	 * interval od -x /dev/input/event0 scrolling the | ||||
| 	 * odr_table vector from the end (shortest interval) backward (longest | ||||
| 	 * interval), to support the poll_interval requested by the system. | ||||
| 	 * It must be the longest interval lower then the poll interval | ||||
| 	 */ | ||||
| 	for (i = ARRAY_SIZE(lsm303agr_acc_odr_table) - 1; i >= 0; i--) { | ||||
| 		if ((lsm303agr_acc_odr_table[i].cutoff_ms <= poll_interval) || | ||||
| 		    (i == 0)) | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	sdata = &cdata->sensors[LSM303AGR_ACC_SENSOR]; | ||||
| 	/* also save requested odr */ | ||||
| 	buf = (sdata->c_odr = lsm303agr_acc_odr_table[i].mask) | | ||||
| 	      LSM303AGR_ACC_ENABLE_ALL_AXIS; | ||||
|  | ||||
| 	/* | ||||
| 	 * If device is currently enabled, we need to write new | ||||
| 	 * configuration out to it | ||||
| 	 */ | ||||
| 	if (atomic_read(&cdata->enabled)) { | ||||
| 		err = lsm303agr_acc_write_data_with_mask(cdata, CTRL_REG1, | ||||
| 							 LSM303AGR_ACC_ODR_MSK | | ||||
| 							 LSM303AGR_ACC_AXIS_MSK, | ||||
| 							 &buf); | ||||
| 		if (err < 0) | ||||
| 			goto error; | ||||
| 	} | ||||
|  | ||||
| #ifdef LSM303AGR_ACC_DEBUG | ||||
| 	dev_info(cdata->dev, "update odr to 0x%02x,0x%02x: %d\n", | ||||
| 			CTRL_REG1, buf, err); | ||||
| #endif | ||||
|  | ||||
| 	return err; | ||||
|  | ||||
| error: | ||||
| 	dev_err(cdata->dev, "update odr failed 0x%02x,0x%02x: %d\n", | ||||
| 			CTRL_REG1, buf, err); | ||||
|  | ||||
| 	return err; | ||||
| } | ||||
|  | ||||
| static int lsm303agr_acc_update_opmode(struct lsm303agr_common_data *cdata, | ||||
| 				       unsigned short opmode) | ||||
| { | ||||
| 	int err; | ||||
| 	struct lsm303agr_sensor_data *sdata; | ||||
| 	u8 lp = 0, hr = 0, indx = 0; | ||||
|  | ||||
| 	switch (opmode) { | ||||
| 	case LSM303AGR_ACC_OPMODE_NORMAL: | ||||
| 		break; | ||||
| 	case LSM303AGR_ACC_OPMODE_HR: | ||||
| 		hr = (1 << __ffs(LSM303AGR_ACC_LP_MSK)); | ||||
| 		break; | ||||
| 	case LSM303AGR_ACC_OPMODE_LP: | ||||
| 		lp = (1 << __ffs(LSM303AGR_ACC_HR_MSK)); | ||||
| 		break; | ||||
| 	default: | ||||
| 		return -EINVAL; | ||||
| 	} | ||||
|  | ||||
| 	/* Set LP bit in CTRL_REG1 */ | ||||
| 	err = lsm303agr_acc_write_data_with_mask(cdata, CTRL_REG1, | ||||
| 						 LSM303AGR_ACC_LP_MSK, &lp); | ||||
| 	if (err < 0) | ||||
| 		goto error; | ||||
|  | ||||
| 	/* Set HR bit in CTRL_REG4 */ | ||||
| 	err = lsm303agr_acc_write_data_with_mask(cdata, CTRL_REG2, | ||||
| 						 LSM303AGR_ACC_HR_MSK, | ||||
| 						 &hr); | ||||
| 	if (err < 0) | ||||
| 		goto error; | ||||
|  | ||||
| 	/* Change platform data */ | ||||
| 	sdata = &cdata->sensors[LSM303AGR_ACC_SENSOR]; | ||||
| 	sdata->opmode = opmode; | ||||
| 	sdata->shift = lsm303agr_acc_opmode_table[opmode].shift; | ||||
|  | ||||
| 	switch (sdata->fs_range) { | ||||
| 	case LSM303AGR_ACC_G_2G: | ||||
| 		indx = 0; | ||||
| 		break; | ||||
| 	case LSM303AGR_ACC_G_8G: | ||||
| 		indx = 2; | ||||
| 		break; | ||||
| 	} | ||||
| 	sdata->sensitivity = lsm303agr_acc_opmode_table[opmode].sensitivity[indx]; | ||||
|  | ||||
| #ifdef LSM303AGR_ACC_DEBUG | ||||
| 	dev_info(cdata->dev, "%s shift=%d, sens=%d, opm=%d\n", | ||||
| 		 LSM303AGR_ACC_DEV_NAME, sdata->shift, sdata->sensitivity, | ||||
| 		 sdata->opmode); | ||||
| #endif | ||||
|  | ||||
| 	return err; | ||||
|  | ||||
| error: | ||||
| 	dev_err(cdata->dev, "update opmode failed: %d\n", err); | ||||
|  | ||||
| 	return err; | ||||
| } | ||||
|  | ||||
| static int | ||||
| lsm303agr_acc_get_acceleration_data(struct lsm303agr_common_data *cdata, int *xyz) | ||||
| { | ||||
| 	int err; | ||||
| 	/* Data bytes from hardware xL, xH, yL, yH, zL, zH */ | ||||
| 	u8 acc_data[6]; | ||||
| 	/* x,y,z hardware data */ | ||||
| 	u32 sensitivity, shift; | ||||
|  | ||||
| 	err = cdata->tf->read(cdata->dev, AXISDATA_REG, 6, acc_data); | ||||
| 	if (err < 0) | ||||
| 		return err; | ||||
|  | ||||
| 	/* Get the current sensitivity and shift values */ | ||||
| 	sensitivity = cdata->sensors[LSM303AGR_ACC_SENSOR].sensitivity; | ||||
| 	shift = cdata->sensors[LSM303AGR_ACC_SENSOR].shift; | ||||
|  | ||||
| 	/* Transform LSBs into ug */ | ||||
| 	xyz[0] = (s32)((s16)(acc_data[0] | (acc_data[1] << 8)) >> shift) * sensitivity; | ||||
| 	xyz[1] = (s32)((s16)(acc_data[2] | (acc_data[3] << 8)) >> shift) * sensitivity; | ||||
| 	xyz[2] = (s32)((s16)(acc_data[4] | (acc_data[5] << 8)) >> shift) * sensitivity; | ||||
|  | ||||
| #ifdef LSM303AGR_ACC_DEBUG | ||||
| 	dev_info(cdata->dev, "%s read x=%d, y=%d, z=%d\n", | ||||
| 		 LSM303AGR_ACC_DEV_NAME, xyz[0], xyz[1], xyz[2]); | ||||
| #endif | ||||
|  | ||||
| 	return err; | ||||
| } | ||||
|  | ||||
| static void lsm303agr_acc_report_values(struct lsm303agr_common_data *cdata, | ||||
| 					int *xyz, s64 timestamp) | ||||
| { | ||||
| 	struct lsm303agr_sensor_data *sdata; | ||||
|  | ||||
| 	sdata = &cdata->sensors[LSM303AGR_ACC_SENSOR]; | ||||
| 	input_event(sdata->input_dev, INPUT_EVENT_TYPE, INPUT_EVENT_X, xyz[0]); | ||||
| 	input_event(sdata->input_dev, INPUT_EVENT_TYPE, INPUT_EVENT_Y, xyz[1]); | ||||
| 	input_event(sdata->input_dev, INPUT_EVENT_TYPE, INPUT_EVENT_Z, xyz[2]); | ||||
| 	input_event(sdata->input_dev, INPUT_EVENT_TYPE, INPUT_EVENT_TIME_MSB, | ||||
| 		    timestamp >> 32); | ||||
| 	input_event(sdata->input_dev, INPUT_EVENT_TYPE, INPUT_EVENT_TIME_LSB, | ||||
| 		    timestamp & 0xffffffff); | ||||
| 	input_sync(sdata->input_dev); | ||||
| } | ||||
|  | ||||
| int lsm303agr_acc_enable(struct lsm303agr_common_data *cdata) | ||||
| { | ||||
| 	if (!atomic_cmpxchg(&cdata->enabled, 0, 1)) { | ||||
| 		int err; | ||||
| 		struct lsm303agr_sensor_data *sdata; | ||||
|  | ||||
| 		mutex_lock(&cdata->lock); | ||||
|  | ||||
| 		sdata = &cdata->sensors[LSM303AGR_ACC_SENSOR]; | ||||
| 		err = lsm303agr_acc_device_power_on(cdata); | ||||
| 		if (err < 0) { | ||||
| 			atomic_set(&cdata->enabled, 0); | ||||
| 			return err; | ||||
| 		} | ||||
| 		schedule_delayed_work(&sdata->input_work, | ||||
| 				      msecs_to_jiffies(sdata->poll_interval)); | ||||
|  | ||||
| 		mutex_unlock(&cdata->lock); | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
| EXPORT_SYMBOL(lsm303agr_acc_enable); | ||||
|  | ||||
| int lsm303agr_acc_disable(struct lsm303agr_common_data *cdata) | ||||
| { | ||||
| 	if (atomic_cmpxchg(&cdata->enabled, 1, 0)) { | ||||
| 		struct lsm303agr_sensor_data *sdata; | ||||
|  | ||||
| 		sdata = &cdata->sensors[LSM303AGR_ACC_SENSOR]; | ||||
| 		cancel_delayed_work_sync(&sdata->input_work); | ||||
|  | ||||
| 		mutex_lock(&cdata->lock); | ||||
| 		lsm303agr_acc_device_power_off(cdata); | ||||
| 		mutex_unlock(&cdata->lock); | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
| EXPORT_SYMBOL(lsm303agr_acc_disable); | ||||
|  | ||||
| static ssize_t attr_get_sched_num_acc(struct device *dev, | ||||
| 				      struct device_attribute *attr, char *buf) | ||||
| { | ||||
| 	int val; | ||||
| 	struct lsm303agr_common_data *cdata = dev_get_drvdata(dev); | ||||
|  | ||||
| 	mutex_lock(&cdata->lock); | ||||
| 	val = cdata->sensors[LSM303AGR_ACC_SENSOR].schedule_num; | ||||
| 	mutex_unlock(&cdata->lock); | ||||
|  | ||||
| 	return sprintf(buf, "%d\n", val); | ||||
| } | ||||
|  | ||||
| static ssize_t attr_set_sched_num_acc(struct device *dev, | ||||
| 				      struct device_attribute *attr, | ||||
| 				      const char *buf, size_t size) | ||||
| { | ||||
| 	unsigned long sched_num; | ||||
| 	struct lsm303agr_common_data *cdata = dev_get_drvdata(dev); | ||||
|  | ||||
| 	if (kstrtoul(buf, 10, &sched_num)) | ||||
| 		return -EINVAL; | ||||
|  | ||||
| 	mutex_lock(&cdata->lock); | ||||
| 	cdata->sensors[LSM303AGR_ACC_SENSOR].schedule_num = sched_num; | ||||
| 	mutex_unlock(&cdata->lock); | ||||
|  | ||||
| 	return size; | ||||
| } | ||||
|  | ||||
| static ssize_t attr_get_polling_rate_acc(struct device *dev, | ||||
| 					 struct device_attribute *attr, | ||||
| 					 char *buf) | ||||
| { | ||||
| 	int val; | ||||
| 	struct lsm303agr_common_data *cdata = dev_get_drvdata(dev); | ||||
|  | ||||
| 	mutex_lock(&cdata->lock); | ||||
| 	val = cdata->sensors[LSM303AGR_ACC_SENSOR].poll_interval; | ||||
| 	mutex_unlock(&cdata->lock); | ||||
|  | ||||
| 	return sprintf(buf, "%d\n", val); | ||||
| } | ||||
|  | ||||
| static ssize_t attr_set_polling_rate_acc(struct device *dev, | ||||
| 					 struct device_attribute *attr, | ||||
| 					 const char *buf, size_t size) | ||||
| { | ||||
| 	unsigned long interval_ms; | ||||
| 	struct lsm303agr_sensor_data *sdata; | ||||
| 	struct lsm303agr_common_data *cdata = dev_get_drvdata(dev); | ||||
|  | ||||
| 	if (kstrtoul(buf, 10, &interval_ms)) | ||||
| 		return -EINVAL; | ||||
|  | ||||
| 	if (!interval_ms) | ||||
| 		return -EINVAL; | ||||
|  | ||||
| 	sdata = &cdata->sensors[LSM303AGR_ACC_SENSOR]; | ||||
| 	interval_ms = max_t(unsigned int, (unsigned int)interval_ms, | ||||
| 			    sdata->min_interval); | ||||
|  | ||||
| 	mutex_lock(&cdata->lock); | ||||
| 	sdata->poll_interval = interval_ms; | ||||
| 	lsm303agr_acc_update_odr(cdata, interval_ms); | ||||
| 	mutex_unlock(&cdata->lock); | ||||
|  | ||||
| 	return size; | ||||
| } | ||||
|  | ||||
| static ssize_t attr_get_range_acc(struct device *dev, | ||||
| 				  struct device_attribute *attr, | ||||
| 				  char *buf) | ||||
| { | ||||
| 	struct lsm303agr_sensor_data *sdata; | ||||
| 	char range = 2; | ||||
| 	struct lsm303agr_common_data *cdata = dev_get_drvdata(dev); | ||||
|  | ||||
| 	sdata = &cdata->sensors[LSM303AGR_ACC_SENSOR]; | ||||
|  | ||||
| 	mutex_lock(&cdata->lock); | ||||
| 	switch (sdata->fs_range) { | ||||
| 	case LSM303AGR_ACC_G_2G: | ||||
| 		range = 2; | ||||
| 		break; | ||||
| 	case LSM303AGR_ACC_G_8G: | ||||
| 		range = 8; | ||||
| 		break; | ||||
| 	} | ||||
| 	mutex_unlock(&cdata->lock); | ||||
|  | ||||
| 	return sprintf(buf, "%d\n", range); | ||||
| } | ||||
|  | ||||
| static ssize_t attr_set_range_acc(struct device *dev, | ||||
| 				  struct device_attribute *attr, | ||||
| 				  const char *buf, size_t size) | ||||
| { | ||||
| 	u8 range; | ||||
| 	int err; | ||||
| 	unsigned long val; | ||||
| 	struct lsm303agr_sensor_data *sdata; | ||||
| 	struct lsm303agr_common_data *cdata = dev_get_drvdata(dev); | ||||
|  | ||||
| 	sdata = &cdata->sensors[LSM303AGR_ACC_SENSOR]; | ||||
| 	if (kstrtoul(buf, 10, &val)) | ||||
| 		return -EINVAL; | ||||
|  | ||||
| 	switch (val) { | ||||
| 	case 2: | ||||
| 		range = LSM303AGR_ACC_G_2G; | ||||
| 		break; | ||||
| 	case 8: | ||||
| 		range = LSM303AGR_ACC_G_8G; | ||||
| 		break; | ||||
| 	default: | ||||
| 		dev_err(cdata->dev, | ||||
| 			"invalid range request: %lu, discarded\n", val); | ||||
| 		return -EINVAL; | ||||
| 	} | ||||
|  | ||||
| 	mutex_lock(&cdata->lock); | ||||
| 	err = lsm303agr_acc_update_fs_range(cdata, range); | ||||
| 	if (err < 0) { | ||||
| 		mutex_unlock(&cdata->lock); | ||||
| 		return err; | ||||
| 	} | ||||
| 	sdata->fs_range = range; | ||||
| 	mutex_unlock(&cdata->lock); | ||||
|  | ||||
| 	dev_info(cdata->dev, "range set to: %lu g\n", val); | ||||
|  | ||||
| 	return size; | ||||
| } | ||||
|  | ||||
| static ssize_t attr_get_opmode_acc(struct device *dev, | ||||
| 				   struct device_attribute *attr, | ||||
| 				   char *buf) | ||||
| { | ||||
| 	char opmode; | ||||
| 	struct lsm303agr_common_data *cdata = dev_get_drvdata(dev); | ||||
|  | ||||
| 	mutex_lock(&cdata->lock); | ||||
| 	opmode = cdata->sensors[LSM303AGR_ACC_SENSOR].opmode; | ||||
| 	mutex_unlock(&cdata->lock); | ||||
|  | ||||
| 	return sprintf(buf, "%d\n", opmode); | ||||
| } | ||||
|  | ||||
| static ssize_t attr_set_opmode_acc(struct device *dev, | ||||
| 				   struct device_attribute *attr, | ||||
| 				   const char *buf, size_t size) | ||||
| { | ||||
| 	int err; | ||||
| 	u16 opmode; | ||||
| 	unsigned long val; | ||||
| 	struct lsm303agr_common_data *cdata = dev_get_drvdata(dev); | ||||
|  | ||||
| 	if (kstrtoul(buf, 10, &val)) | ||||
| 		return -EINVAL; | ||||
|  | ||||
| 	/* Check if argument is valid opmode */ | ||||
| 	switch (val) { | ||||
| 	case LSM303AGR_ACC_OPMODE_NORMAL: | ||||
| 	case LSM303AGR_ACC_OPMODE_HR: | ||||
| 	case LSM303AGR_ACC_OPMODE_LP: | ||||
| 		opmode = val; | ||||
| 		break; | ||||
| 	default: | ||||
| 		dev_err(cdata->dev, | ||||
| 			"invalid range request: %lu, discarded\n", val); | ||||
| 		return -EINVAL; | ||||
| 	} | ||||
|  | ||||
| 	mutex_lock(&cdata->lock); | ||||
| 	err = lsm303agr_acc_update_opmode(cdata, opmode); | ||||
| 	if (err < 0) { | ||||
| 		mutex_unlock(&cdata->lock); | ||||
| 		return err; | ||||
| 	} | ||||
| 	mutex_unlock(&cdata->lock); | ||||
|  | ||||
| 	dev_info(cdata->dev, "opmode set to: %u\n", opmode); | ||||
|  | ||||
| 	return size; | ||||
| } | ||||
|  | ||||
| static ssize_t attr_get_enable_acc(struct device *dev, | ||||
| 				   struct device_attribute *attr, | ||||
| 				   char *buf) | ||||
| { | ||||
| 	struct lsm303agr_common_data *cdata = dev_get_drvdata(dev); | ||||
| 	int val = atomic_read(&cdata->enabled); | ||||
|  | ||||
| 	return sprintf(buf, "%d\n", val); | ||||
| } | ||||
|  | ||||
| static ssize_t attr_set_enable_acc(struct device *dev, | ||||
| 				   struct device_attribute *attr, | ||||
| 				   const char *buf, size_t size) | ||||
| { | ||||
| 	struct lsm303agr_common_data *cdata = dev_get_drvdata(dev); | ||||
| 	unsigned long val; | ||||
|  | ||||
| 	if (kstrtoul(buf, 10, &val)) | ||||
| 		return -EINVAL; | ||||
|  | ||||
| 	if (val) | ||||
| 		lsm303agr_acc_enable(cdata); | ||||
| 	else | ||||
| 		lsm303agr_acc_disable(cdata); | ||||
|  | ||||
| 	return size; | ||||
| } | ||||
|  | ||||
| static struct device_attribute attributes[] = { | ||||
|  | ||||
| 	__ATTR(pollrate_ms, 0664, attr_get_polling_rate_acc, | ||||
| 	       attr_set_polling_rate_acc), | ||||
| 	__ATTR(range, 0664, attr_get_range_acc, attr_set_range_acc), | ||||
| 	__ATTR(opmode, 0664, attr_get_opmode_acc, attr_set_opmode_acc), | ||||
| 	__ATTR(enable_device, 0664, attr_get_enable_acc, attr_set_enable_acc), | ||||
| 	__ATTR(schedule_num, 0664, attr_get_sched_num_acc, | ||||
| 	       attr_set_sched_num_acc), | ||||
| }; | ||||
|  | ||||
| static int create_sysfs_interfaces(struct device *dev) | ||||
| { | ||||
| 	int i; | ||||
|  | ||||
| 	for (i = 0; i < ARRAY_SIZE(attributes); i++) | ||||
| 		if (device_create_file(dev, attributes + i)) | ||||
| 			goto error; | ||||
| 	return 0; | ||||
|  | ||||
| error: | ||||
| 	for (; i >= 0; i--) | ||||
| 		device_remove_file(dev, attributes + i); | ||||
|  | ||||
| 	dev_err(dev, "%s:Unable to create interface\n", __func__); | ||||
|  | ||||
| 	return -1; | ||||
| } | ||||
|  | ||||
| static int remove_sysfs_interfaces(struct device *dev) | ||||
| { | ||||
| 	int i; | ||||
|  | ||||
| 	for (i = 0; i < ARRAY_SIZE(attributes); i++) | ||||
| 		device_remove_file(dev, attributes + i); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static void lsm303agr_acc_input_work_func(struct work_struct *work) | ||||
| { | ||||
| 	struct lsm303agr_common_data *cdata; | ||||
| 	struct lsm303agr_sensor_data *sdata; | ||||
| 	int err, xyz[3] = {}; | ||||
|  | ||||
| 	sdata = container_of((struct delayed_work *)work, | ||||
| 			     struct lsm303agr_sensor_data, input_work); | ||||
| 	cdata = sdata->cdata; | ||||
|  | ||||
| 	mutex_lock(&cdata->lock); | ||||
| 	sdata->schedule_num++; | ||||
| 	err = lsm303agr_acc_get_acceleration_data(cdata, xyz); | ||||
| 	if (err < 0) | ||||
| 		dev_err(cdata->dev, "get_acceleration_data failed\n"); | ||||
| 	else | ||||
| 		lsm303agr_acc_report_values(cdata, xyz, lsm303agr_get_time_ns()); | ||||
|  | ||||
| 	schedule_delayed_work(&sdata->input_work, msecs_to_jiffies( | ||||
| 			      sdata->poll_interval)); | ||||
| 	mutex_unlock(&cdata->lock); | ||||
| } | ||||
|  | ||||
| static void lsm303agr_acc_input_cleanup(struct lsm303agr_common_data *cdata) | ||||
| { | ||||
| 	struct lsm303agr_sensor_data *sdata; | ||||
|  | ||||
| 	sdata = &cdata->sensors[LSM303AGR_ACC_SENSOR]; | ||||
| 	input_unregister_device(sdata->input_dev); | ||||
| 	input_free_device(sdata->input_dev); | ||||
| } | ||||
|  | ||||
| int lsm303agr_acc_probe(struct lsm303agr_common_data *cdata) | ||||
| { | ||||
| 	int err; | ||||
| 	struct lsm303agr_sensor_data *sdata; | ||||
|  | ||||
| 	mutex_lock(&cdata->lock); | ||||
| 	/* init sensor data structure */ | ||||
| 	sdata = &cdata->sensors[LSM303AGR_ACC_SENSOR]; | ||||
|  | ||||
| 	sdata->cdata = cdata; | ||||
| 	sdata->poll_interval = 100; | ||||
| 	sdata->min_interval = LSM303AGR_ACC_MIN_POLL_PERIOD_MS; | ||||
|  | ||||
| 	err = lsm303agr_acc_device_power_on(cdata); | ||||
| 	if (err < 0) { | ||||
| 		dev_err(cdata->dev, "power on failed: %d\n", err); | ||||
| 		goto  err_power_off; | ||||
| 	} | ||||
|  | ||||
| 	atomic_set(&cdata->enabled, 1); | ||||
|  | ||||
| 	err = lsm303agr_acc_update_fs_range(cdata, LSM303AGR_ACC_G_2G); | ||||
| 	if (err < 0) { | ||||
| 		dev_err(cdata->dev, "update_fs_range failed\n"); | ||||
| 		goto  err_power_off; | ||||
| 	} | ||||
|  | ||||
| 	err = lsm303agr_acc_update_odr(cdata, sdata->poll_interval); | ||||
| 	if (err < 0) { | ||||
| 		dev_err(cdata->dev, "update_odr failed\n"); | ||||
| 		goto  err_power_off; | ||||
| 	} | ||||
|  | ||||
| 	err = lsm303agr_acc_update_opmode(cdata, LSM303AGR_ACC_OPMODE_NORMAL); | ||||
| 	if (err < 0) { | ||||
| 		dev_err(cdata->dev, "update_opmode failed\n"); | ||||
| 		goto  err_power_off; | ||||
| 	} | ||||
|  | ||||
| 	err = lsm303agr_acc_input_init(sdata, LSM303AGR_ACC_DEV_NAME); | ||||
| 	if (err < 0) { | ||||
| 		dev_err(cdata->dev, "input init failed\n"); | ||||
| 		goto err_power_off; | ||||
| 	} | ||||
| 	INIT_DELAYED_WORK(&sdata->input_work, lsm303agr_acc_input_work_func); | ||||
|  | ||||
|  | ||||
| 	err = create_sysfs_interfaces(cdata->dev); | ||||
| 	if (err < 0) { | ||||
| 		dev_err(cdata->dev, | ||||
| 		   "device LSM303AGR_ACC_DEV_NAME sysfs register failed\n"); | ||||
| 		goto err_input_cleanup; | ||||
| 	} | ||||
|  | ||||
| 	lsm303agr_acc_device_power_off(cdata); | ||||
|  | ||||
| 	/* As default, do not report information */ | ||||
| 	atomic_set(&cdata->enabled, 0); | ||||
|  | ||||
| 	dev_info(cdata->dev, "%s: probed\n", LSM303AGR_ACC_DEV_NAME); | ||||
|  | ||||
| 	mutex_unlock(&cdata->lock); | ||||
|  | ||||
| 	return 0; | ||||
|  | ||||
| err_input_cleanup: | ||||
| 	lsm303agr_acc_input_cleanup(cdata); | ||||
| err_power_off: | ||||
| 	lsm303agr_acc_device_power_off(cdata); | ||||
| 	mutex_unlock(&cdata->lock); | ||||
| 	pr_err("%s: Driver Init failed\n", LSM303AGR_ACC_DEV_NAME); | ||||
|  | ||||
| 	return err; | ||||
| } | ||||
| EXPORT_SYMBOL(lsm303agr_acc_probe); | ||||
|  | ||||
| void lsm303agr_acc_remove(struct lsm303agr_common_data *cdata) | ||||
| { | ||||
| 	lsm303agr_acc_disable(cdata); | ||||
| 	lsm303agr_acc_input_cleanup(cdata); | ||||
| 	remove_sysfs_interfaces(cdata->dev); | ||||
| } | ||||
| EXPORT_SYMBOL(lsm303agr_acc_remove); | ||||
|  | ||||
| MODULE_LICENSE("GPL v2"); | ||||
|  | ||||
| @@ -0,0 +1,207 @@ | ||||
| /* | ||||
|  * STMicroelectronics lsm303agr_acc_i2c.c driver | ||||
|  * | ||||
|  * Copyright 2016 STMicroelectronics Inc. | ||||
|  * | ||||
|  * Giuseppe Barba <giuseppe.barba@st.com> | ||||
|  * | ||||
|  * Licensed under the GPL-2. | ||||
|  */ | ||||
|  | ||||
| #include <linux/err.h> | ||||
| #include <linux/errno.h> | ||||
| #include <linux/slab.h> | ||||
| #include <linux/delay.h> | ||||
| #include <linux/i2c.h> | ||||
| #include <linux/input.h> | ||||
| #include <linux/uaccess.h> | ||||
| #include <linux/workqueue.h> | ||||
| #include <linux/irq.h> | ||||
| #include <linux/interrupt.h> | ||||
| #include <linux/kernel.h> | ||||
| #include <linux/device.h> | ||||
| #include <linux/module.h> | ||||
| #include <linux/moduleparam.h> | ||||
| #include <linux/version.h> | ||||
|  | ||||
| #include "lsm303agr_core.h" | ||||
|  | ||||
| #define I2C_AUTO_INCREMENT	0x80 | ||||
|  | ||||
| /* XXX: caller must hold cdata->lock */ | ||||
| static int lsm303agr_acc_i2c_read(struct device *dev, u8 reg_addr, int len, | ||||
| 				  u8 *data) | ||||
| { | ||||
| 	struct i2c_msg msg[2]; | ||||
| 	struct i2c_client *client = to_i2c_client(dev); | ||||
|  | ||||
| 	if (len > 1) | ||||
| 		reg_addr |= I2C_AUTO_INCREMENT; | ||||
|  | ||||
| 	msg[0].addr = client->addr; | ||||
| 	msg[0].flags = client->flags; | ||||
| 	msg[0].len = 1; | ||||
| 	msg[0].buf = ®_addr; | ||||
|  | ||||
| 	msg[1].addr = client->addr; | ||||
| 	msg[1].flags = client->flags | I2C_M_RD; | ||||
| 	msg[1].len = len; | ||||
| 	msg[1].buf = data; | ||||
|  | ||||
| 	return i2c_transfer(client->adapter, msg, 2); | ||||
| } | ||||
|  | ||||
| /* XXX: caller must hold cdata->lock */ | ||||
| static int lsm303agr_acc_i2c_write(struct device *dev, u8 reg_addr, int len, | ||||
| 				   u8 *data) | ||||
| { | ||||
| 	u8 send[len + 1]; | ||||
| 	struct i2c_msg msg; | ||||
| 	struct i2c_client *client = to_i2c_client(dev); | ||||
|  | ||||
| 	if (len > 1) | ||||
| 		reg_addr |= I2C_AUTO_INCREMENT; | ||||
|  | ||||
| 	send[0] = reg_addr; | ||||
| 	memcpy(&send[1], data, len * sizeof(u8)); | ||||
| 	len++; | ||||
|  | ||||
| 	msg.addr = client->addr; | ||||
| 	msg.flags = client->flags; | ||||
| 	msg.len = len; | ||||
| 	msg.buf = send; | ||||
|  | ||||
| 	return i2c_transfer(client->adapter, &msg, 1); | ||||
| } | ||||
|  | ||||
| /* I2C IO routines */ | ||||
| static const struct lsm303agr_transfer_function lsm303agr_acc_i2c_tf = { | ||||
| 	.write = lsm303agr_acc_i2c_write, | ||||
| 	.read = lsm303agr_acc_i2c_read, | ||||
| }; | ||||
|  | ||||
| #ifdef CONFIG_PM_SLEEP | ||||
| static int lsm303agr_acc_resume(struct device *dev) | ||||
| { | ||||
| 	struct i2c_client *client = to_i2c_client(dev); | ||||
| 	struct lsm303agr_common_data *cdata = i2c_get_clientdata(client); | ||||
|  | ||||
| 	if (cdata->on_before_suspend) | ||||
| 		return lsm303agr_acc_enable(cdata); | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| static int lsm303agr_acc_suspend(struct device *dev) | ||||
| { | ||||
| 	struct i2c_client *client = to_i2c_client(dev); | ||||
| 	struct lsm303agr_common_data *cdata = i2c_get_clientdata(client); | ||||
|  | ||||
| 	cdata->on_before_suspend = atomic_read(&cdata->enabled); | ||||
| 	return lsm303agr_acc_disable(cdata); | ||||
| } | ||||
|  | ||||
| static SIMPLE_DEV_PM_OPS(lsm303agr_acc_pm_ops, | ||||
| 				lsm303agr_acc_suspend, | ||||
| 				lsm303agr_acc_resume); | ||||
|  | ||||
| #define LSM303AGR_ACC_PM_OPS	(&lsm303agr_acc_pm_ops) | ||||
| #else /* CONFIG_PM_SLEEP */ | ||||
| #define LSM303AGR_ACC_PM_OPS	NULL | ||||
| #endif /* CONFIG_PM_SLEEP */ | ||||
|  | ||||
| static int lsm303agr_acc_i2c_probe(struct i2c_client *client, | ||||
| 				   const struct i2c_device_id *id) | ||||
| { | ||||
| 	int err; | ||||
| 	struct lsm303agr_common_data *cdata; | ||||
|  | ||||
| 	dev_info(&client->dev, "probe start.\n"); | ||||
|  | ||||
| 	/* Alloc Common data structure */ | ||||
| 	cdata = kzalloc(sizeof(struct lsm303agr_common_data), GFP_KERNEL); | ||||
| 	if (!cdata) { | ||||
| 		dev_err(&client->dev, "failed to allocate module data\n"); | ||||
| 		return -ENOMEM; | ||||
| 	} | ||||
|  | ||||
| 	cdata->sensor_num = LSM303AGR_MAX_SENSORS_NUM; | ||||
| 	cdata->dev = &client->dev; | ||||
| 	cdata->name = client->name; | ||||
| 	cdata->bus_type = BUS_I2C; | ||||
| 	cdata->tf = &lsm303agr_acc_i2c_tf; | ||||
|  | ||||
| 	i2c_set_clientdata(client, cdata); | ||||
|  | ||||
| 	mutex_init(&cdata->lock); | ||||
|  | ||||
| 	err = lsm303agr_acc_probe(cdata); | ||||
| 	if (err < 0) { | ||||
| 		kfree(cdata); | ||||
|  | ||||
| 		return err; | ||||
| 	} | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| #if KERNEL_VERSION(6, 1, 0) <= LINUX_VERSION_CODE | ||||
| static void lsm303agr_acc_i2c_remove(struct i2c_client *client) | ||||
| { | ||||
| 	struct lsm303agr_common_data *cdata = i2c_get_clientdata(client); | ||||
|  | ||||
| 	dev_info(cdata->dev, "driver removing\n"); | ||||
|  | ||||
| 	lsm303agr_acc_remove(cdata); | ||||
| 	kfree(cdata); | ||||
| } | ||||
| #else | ||||
| static int lsm303agr_acc_i2c_remove(struct i2c_client *client) | ||||
| { | ||||
| 	struct lsm303agr_common_data *cdata = i2c_get_clientdata(client); | ||||
|  | ||||
| 	dev_info(cdata->dev, "driver removing\n"); | ||||
|  | ||||
| 	lsm303agr_acc_remove(cdata); | ||||
| 	kfree(cdata); | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
| #endif | ||||
|  | ||||
| static const struct i2c_device_id lsm303agr_acc_i2c_id[] = { | ||||
| 	{ "lsm303agr_acc", 0 }, | ||||
| 	{ }, | ||||
| }; | ||||
| MODULE_DEVICE_TABLE(i2c, lsm303agr_acc_i2c_id); | ||||
|  | ||||
| #ifdef CONFIG_OF | ||||
| static const struct of_device_id lsm303agr_acc_i2c_id_table[] = { | ||||
| 	{.compatible = "st,lsm303agr_acc", }, | ||||
| 	{ }, | ||||
| }; | ||||
| MODULE_DEVICE_TABLE(of, lsm303agr_acc_i2c_id_table); | ||||
| #endif /* CONFIG_OF */ | ||||
|  | ||||
| static struct i2c_driver lsm303agr_acc_i2c_driver = { | ||||
| 	.driver = { | ||||
| 		.owner = THIS_MODULE, | ||||
| 		.name = "lsm303agr_acc", | ||||
| 		.pm = LSM303AGR_ACC_PM_OPS, | ||||
| #ifdef CONFIG_OF | ||||
| 		.of_match_table = lsm303agr_acc_i2c_id_table, | ||||
| #endif /* CONFIG_OF */ | ||||
| 	}, | ||||
| 	.probe = lsm303agr_acc_i2c_probe, | ||||
| 	.remove = lsm303agr_acc_i2c_remove, | ||||
| 	.id_table = lsm303agr_acc_i2c_id, | ||||
| }; | ||||
|  | ||||
| module_i2c_driver(lsm303agr_acc_i2c_driver); | ||||
|  | ||||
| MODULE_DESCRIPTION("lsm303agr accelerometer i2c driver"); | ||||
| MODULE_AUTHOR("Armando Visconti"); | ||||
| MODULE_AUTHOR("Matteo Dameno"); | ||||
| MODULE_AUTHOR("Denis Ciocca"); | ||||
| MODULE_AUTHOR("STMicroelectronics"); | ||||
| MODULE_LICENSE("GPL v2"); | ||||
|  | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user