18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2008-2009 Atheros Communications Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any
58c2ecf20Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above
68c2ecf20Sopenharmony_ci * copyright notice and this permission notice appear in all copies.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
98c2ecf20Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
108c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
118c2ecf20Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
128c2ecf20Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
138c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
148c2ecf20Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
158c2ecf20Sopenharmony_ci */
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#ifndef REGD_H
188c2ecf20Sopenharmony_ci#define REGD_H
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#include <linux/nl80211.h>
218c2ecf20Sopenharmony_ci#include <net/cfg80211.h>
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#include "ath.h"
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_cienum ctl_group {
268c2ecf20Sopenharmony_ci	CTL_FCC = 0x10,
278c2ecf20Sopenharmony_ci	CTL_MKK = 0x40,
288c2ecf20Sopenharmony_ci	CTL_ETSI = 0x30,
298c2ecf20Sopenharmony_ci};
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define SD_NO_CTL               0xE0
328c2ecf20Sopenharmony_ci#define NO_CTL                  0xff
338c2ecf20Sopenharmony_ci#define CTL_11A                 0
348c2ecf20Sopenharmony_ci#define CTL_11B                 1
358c2ecf20Sopenharmony_ci#define CTL_11G                 2
368c2ecf20Sopenharmony_ci#define CTL_2GHT20              5
378c2ecf20Sopenharmony_ci#define CTL_5GHT20              6
388c2ecf20Sopenharmony_ci#define CTL_2GHT40              7
398c2ecf20Sopenharmony_ci#define CTL_5GHT40              8
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define CTRY_DEBUG 0x1ff
428c2ecf20Sopenharmony_ci#define CTRY_DEFAULT 0
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#define COUNTRY_ERD_FLAG        0x8000
458c2ecf20Sopenharmony_ci#define WORLDWIDE_ROAMING_FLAG  0x4000
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#define MULTI_DOMAIN_MASK 0xFF00
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#define WORLD_SKU_MASK          0x00F0
508c2ecf20Sopenharmony_ci#define WORLD_SKU_PREFIX        0x0060
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define CHANNEL_HALF_BW         10
538c2ecf20Sopenharmony_ci#define CHANNEL_QUARTER_BW      5
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_cistruct country_code_to_enum_rd {
568c2ecf20Sopenharmony_ci	u16 countryCode;
578c2ecf20Sopenharmony_ci	u16 regDmnEnum;
588c2ecf20Sopenharmony_ci	const char *isoName;
598c2ecf20Sopenharmony_ci};
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cienum CountryCode {
628c2ecf20Sopenharmony_ci	CTRY_ALBANIA = 8,
638c2ecf20Sopenharmony_ci	CTRY_ALGERIA = 12,
648c2ecf20Sopenharmony_ci	CTRY_ARGENTINA = 32,
658c2ecf20Sopenharmony_ci	CTRY_ARMENIA = 51,
668c2ecf20Sopenharmony_ci	CTRY_ARUBA = 533,
678c2ecf20Sopenharmony_ci	CTRY_AUSTRALIA = 36,
688c2ecf20Sopenharmony_ci	CTRY_AUSTRIA = 40,
698c2ecf20Sopenharmony_ci	CTRY_AZERBAIJAN = 31,
708c2ecf20Sopenharmony_ci	CTRY_BAHAMAS = 44,
718c2ecf20Sopenharmony_ci	CTRY_BAHRAIN = 48,
728c2ecf20Sopenharmony_ci	CTRY_BANGLADESH = 50,
738c2ecf20Sopenharmony_ci	CTRY_BARBADOS = 52,
748c2ecf20Sopenharmony_ci	CTRY_BELARUS = 112,
758c2ecf20Sopenharmony_ci	CTRY_BELGIUM = 56,
768c2ecf20Sopenharmony_ci	CTRY_BELIZE = 84,
778c2ecf20Sopenharmony_ci	CTRY_BERMUDA = 60,
788c2ecf20Sopenharmony_ci	CTRY_BOLIVIA = 68,
798c2ecf20Sopenharmony_ci	CTRY_BOSNIA_HERZ = 70,
808c2ecf20Sopenharmony_ci	CTRY_BRAZIL = 76,
818c2ecf20Sopenharmony_ci	CTRY_BRUNEI_DARUSSALAM = 96,
828c2ecf20Sopenharmony_ci	CTRY_BULGARIA = 100,
838c2ecf20Sopenharmony_ci	CTRY_CAMBODIA = 116,
848c2ecf20Sopenharmony_ci	CTRY_CANADA = 124,
858c2ecf20Sopenharmony_ci	CTRY_CHILE = 152,
868c2ecf20Sopenharmony_ci	CTRY_CHINA = 156,
878c2ecf20Sopenharmony_ci	CTRY_COLOMBIA = 170,
888c2ecf20Sopenharmony_ci	CTRY_COSTA_RICA = 188,
898c2ecf20Sopenharmony_ci	CTRY_CROATIA = 191,
908c2ecf20Sopenharmony_ci	CTRY_CYPRUS = 196,
918c2ecf20Sopenharmony_ci	CTRY_CZECH = 203,
928c2ecf20Sopenharmony_ci	CTRY_DENMARK = 208,
938c2ecf20Sopenharmony_ci	CTRY_DOMINICAN_REPUBLIC = 214,
948c2ecf20Sopenharmony_ci	CTRY_ECUADOR = 218,
958c2ecf20Sopenharmony_ci	CTRY_EGYPT = 818,
968c2ecf20Sopenharmony_ci	CTRY_EL_SALVADOR = 222,
978c2ecf20Sopenharmony_ci	CTRY_ESTONIA = 233,
988c2ecf20Sopenharmony_ci	CTRY_FAEROE_ISLANDS = 234,
998c2ecf20Sopenharmony_ci	CTRY_FINLAND = 246,
1008c2ecf20Sopenharmony_ci	CTRY_FRANCE = 250,
1018c2ecf20Sopenharmony_ci	CTRY_GEORGIA = 268,
1028c2ecf20Sopenharmony_ci	CTRY_GERMANY = 276,
1038c2ecf20Sopenharmony_ci	CTRY_GREECE = 300,
1048c2ecf20Sopenharmony_ci	CTRY_GREENLAND = 304,
1058c2ecf20Sopenharmony_ci	CTRY_GRENADA = 308,
1068c2ecf20Sopenharmony_ci	CTRY_GUAM = 316,
1078c2ecf20Sopenharmony_ci	CTRY_GUATEMALA = 320,
1088c2ecf20Sopenharmony_ci	CTRY_HAITI = 332,
1098c2ecf20Sopenharmony_ci	CTRY_HONDURAS = 340,
1108c2ecf20Sopenharmony_ci	CTRY_HONG_KONG = 344,
1118c2ecf20Sopenharmony_ci	CTRY_HUNGARY = 348,
1128c2ecf20Sopenharmony_ci	CTRY_ICELAND = 352,
1138c2ecf20Sopenharmony_ci	CTRY_INDIA = 356,
1148c2ecf20Sopenharmony_ci	CTRY_INDONESIA = 360,
1158c2ecf20Sopenharmony_ci	CTRY_IRAN = 364,
1168c2ecf20Sopenharmony_ci	CTRY_IRAQ = 368,
1178c2ecf20Sopenharmony_ci	CTRY_IRELAND = 372,
1188c2ecf20Sopenharmony_ci	CTRY_ISRAEL = 376,
1198c2ecf20Sopenharmony_ci	CTRY_ITALY = 380,
1208c2ecf20Sopenharmony_ci	CTRY_JAMAICA = 388,
1218c2ecf20Sopenharmony_ci	CTRY_JAPAN = 392,
1228c2ecf20Sopenharmony_ci	CTRY_JORDAN = 400,
1238c2ecf20Sopenharmony_ci	CTRY_KAZAKHSTAN = 398,
1248c2ecf20Sopenharmony_ci	CTRY_KENYA = 404,
1258c2ecf20Sopenharmony_ci	CTRY_KOREA_NORTH = 408,
1268c2ecf20Sopenharmony_ci	CTRY_KOREA_ROC = 410,
1278c2ecf20Sopenharmony_ci	CTRY_KOREA_ROC2 = 411,
1288c2ecf20Sopenharmony_ci	CTRY_KOREA_ROC3 = 412,
1298c2ecf20Sopenharmony_ci	CTRY_KUWAIT = 414,
1308c2ecf20Sopenharmony_ci	CTRY_LATVIA = 428,
1318c2ecf20Sopenharmony_ci	CTRY_LEBANON = 422,
1328c2ecf20Sopenharmony_ci	CTRY_LIBYA = 434,
1338c2ecf20Sopenharmony_ci	CTRY_LIECHTENSTEIN = 438,
1348c2ecf20Sopenharmony_ci	CTRY_LITHUANIA = 440,
1358c2ecf20Sopenharmony_ci	CTRY_LUXEMBOURG = 442,
1368c2ecf20Sopenharmony_ci	CTRY_MACAU = 446,
1378c2ecf20Sopenharmony_ci	CTRY_MACEDONIA = 807,
1388c2ecf20Sopenharmony_ci	CTRY_MALAYSIA = 458,
1398c2ecf20Sopenharmony_ci	CTRY_MALTA = 470,
1408c2ecf20Sopenharmony_ci	CTRY_MAURITIUS = 480,
1418c2ecf20Sopenharmony_ci	CTRY_MEXICO = 484,
1428c2ecf20Sopenharmony_ci	CTRY_MONACO = 492,
1438c2ecf20Sopenharmony_ci	CTRY_MONTENEGRO = 499,
1448c2ecf20Sopenharmony_ci	CTRY_MOROCCO = 504,
1458c2ecf20Sopenharmony_ci	CTRY_NEPAL = 524,
1468c2ecf20Sopenharmony_ci	CTRY_NETHERLANDS = 528,
1478c2ecf20Sopenharmony_ci	CTRY_NETHERLANDS_ANTILLES = 530,
1488c2ecf20Sopenharmony_ci	CTRY_NEW_ZEALAND = 554,
1498c2ecf20Sopenharmony_ci	CTRY_NICARAGUA = 558,
1508c2ecf20Sopenharmony_ci	CTRY_NORWAY = 578,
1518c2ecf20Sopenharmony_ci	CTRY_OMAN = 512,
1528c2ecf20Sopenharmony_ci	CTRY_PAKISTAN = 586,
1538c2ecf20Sopenharmony_ci	CTRY_PANAMA = 591,
1548c2ecf20Sopenharmony_ci	CTRY_PAPUA_NEW_GUINEA = 598,
1558c2ecf20Sopenharmony_ci	CTRY_PARAGUAY = 600,
1568c2ecf20Sopenharmony_ci	CTRY_PERU = 604,
1578c2ecf20Sopenharmony_ci	CTRY_PHILIPPINES = 608,
1588c2ecf20Sopenharmony_ci	CTRY_POLAND = 616,
1598c2ecf20Sopenharmony_ci	CTRY_PORTUGAL = 620,
1608c2ecf20Sopenharmony_ci	CTRY_PUERTO_RICO = 630,
1618c2ecf20Sopenharmony_ci	CTRY_QATAR = 634,
1628c2ecf20Sopenharmony_ci	CTRY_ROMANIA = 642,
1638c2ecf20Sopenharmony_ci	CTRY_RUSSIA = 643,
1648c2ecf20Sopenharmony_ci	CTRY_SAUDI_ARABIA = 682,
1658c2ecf20Sopenharmony_ci	CTRY_SERBIA = 688,
1668c2ecf20Sopenharmony_ci	CTRY_SERBIA_MONTENEGRO = 891,
1678c2ecf20Sopenharmony_ci	CTRY_SINGAPORE = 702,
1688c2ecf20Sopenharmony_ci	CTRY_SLOVAKIA = 703,
1698c2ecf20Sopenharmony_ci	CTRY_SLOVENIA = 705,
1708c2ecf20Sopenharmony_ci	CTRY_SOUTH_AFRICA = 710,
1718c2ecf20Sopenharmony_ci	CTRY_SPAIN = 724,
1728c2ecf20Sopenharmony_ci	CTRY_SRI_LANKA = 144,
1738c2ecf20Sopenharmony_ci	CTRY_SWEDEN = 752,
1748c2ecf20Sopenharmony_ci	CTRY_SWITZERLAND = 756,
1758c2ecf20Sopenharmony_ci	CTRY_SYRIA = 760,
1768c2ecf20Sopenharmony_ci	CTRY_TAIWAN = 158,
1778c2ecf20Sopenharmony_ci	CTRY_TANZANIA = 834,
1788c2ecf20Sopenharmony_ci	CTRY_THAILAND = 764,
1798c2ecf20Sopenharmony_ci	CTRY_TRINIDAD_Y_TOBAGO = 780,
1808c2ecf20Sopenharmony_ci	CTRY_TUNISIA = 788,
1818c2ecf20Sopenharmony_ci	CTRY_TURKEY = 792,
1828c2ecf20Sopenharmony_ci	CTRY_UAE = 784,
1838c2ecf20Sopenharmony_ci	CTRY_UGANDA = 800,
1848c2ecf20Sopenharmony_ci	CTRY_UKRAINE = 804,
1858c2ecf20Sopenharmony_ci	CTRY_UNITED_KINGDOM = 826,
1868c2ecf20Sopenharmony_ci	CTRY_UNITED_STATES = 840,
1878c2ecf20Sopenharmony_ci	CTRY_UNITED_STATES2 = 841,
1888c2ecf20Sopenharmony_ci	CTRY_UNITED_STATES_FCC49 = 842,
1898c2ecf20Sopenharmony_ci	CTRY_UNITED_STATES3 = 843,
1908c2ecf20Sopenharmony_ci	CTRY_URUGUAY = 858,
1918c2ecf20Sopenharmony_ci	CTRY_UZBEKISTAN = 860,
1928c2ecf20Sopenharmony_ci	CTRY_VENEZUELA = 862,
1938c2ecf20Sopenharmony_ci	CTRY_VIET_NAM = 704,
1948c2ecf20Sopenharmony_ci	CTRY_YEMEN = 887,
1958c2ecf20Sopenharmony_ci	CTRY_ZIMBABWE = 716,
1968c2ecf20Sopenharmony_ci	CTRY_JAPAN1 = 393,
1978c2ecf20Sopenharmony_ci	CTRY_JAPAN2 = 394,
1988c2ecf20Sopenharmony_ci	CTRY_JAPAN3 = 395,
1998c2ecf20Sopenharmony_ci	CTRY_JAPAN4 = 396,
2008c2ecf20Sopenharmony_ci	CTRY_JAPAN5 = 397,
2018c2ecf20Sopenharmony_ci	CTRY_JAPAN6 = 4006,
2028c2ecf20Sopenharmony_ci	CTRY_JAPAN7 = 4007,
2038c2ecf20Sopenharmony_ci	CTRY_JAPAN8 = 4008,
2048c2ecf20Sopenharmony_ci	CTRY_JAPAN9 = 4009,
2058c2ecf20Sopenharmony_ci	CTRY_JAPAN10 = 4010,
2068c2ecf20Sopenharmony_ci	CTRY_JAPAN11 = 4011,
2078c2ecf20Sopenharmony_ci	CTRY_JAPAN12 = 4012,
2088c2ecf20Sopenharmony_ci	CTRY_JAPAN13 = 4013,
2098c2ecf20Sopenharmony_ci	CTRY_JAPAN14 = 4014,
2108c2ecf20Sopenharmony_ci	CTRY_JAPAN15 = 4015,
2118c2ecf20Sopenharmony_ci	CTRY_JAPAN16 = 4016,
2128c2ecf20Sopenharmony_ci	CTRY_JAPAN17 = 4017,
2138c2ecf20Sopenharmony_ci	CTRY_JAPAN18 = 4018,
2148c2ecf20Sopenharmony_ci	CTRY_JAPAN19 = 4019,
2158c2ecf20Sopenharmony_ci	CTRY_JAPAN20 = 4020,
2168c2ecf20Sopenharmony_ci	CTRY_JAPAN21 = 4021,
2178c2ecf20Sopenharmony_ci	CTRY_JAPAN22 = 4022,
2188c2ecf20Sopenharmony_ci	CTRY_JAPAN23 = 4023,
2198c2ecf20Sopenharmony_ci	CTRY_JAPAN24 = 4024,
2208c2ecf20Sopenharmony_ci	CTRY_JAPAN25 = 4025,
2218c2ecf20Sopenharmony_ci	CTRY_JAPAN26 = 4026,
2228c2ecf20Sopenharmony_ci	CTRY_JAPAN27 = 4027,
2238c2ecf20Sopenharmony_ci	CTRY_JAPAN28 = 4028,
2248c2ecf20Sopenharmony_ci	CTRY_JAPAN29 = 4029,
2258c2ecf20Sopenharmony_ci	CTRY_JAPAN30 = 4030,
2268c2ecf20Sopenharmony_ci	CTRY_JAPAN31 = 4031,
2278c2ecf20Sopenharmony_ci	CTRY_JAPAN32 = 4032,
2288c2ecf20Sopenharmony_ci	CTRY_JAPAN33 = 4033,
2298c2ecf20Sopenharmony_ci	CTRY_JAPAN34 = 4034,
2308c2ecf20Sopenharmony_ci	CTRY_JAPAN35 = 4035,
2318c2ecf20Sopenharmony_ci	CTRY_JAPAN36 = 4036,
2328c2ecf20Sopenharmony_ci	CTRY_JAPAN37 = 4037,
2338c2ecf20Sopenharmony_ci	CTRY_JAPAN38 = 4038,
2348c2ecf20Sopenharmony_ci	CTRY_JAPAN39 = 4039,
2358c2ecf20Sopenharmony_ci	CTRY_JAPAN40 = 4040,
2368c2ecf20Sopenharmony_ci	CTRY_JAPAN41 = 4041,
2378c2ecf20Sopenharmony_ci	CTRY_JAPAN42 = 4042,
2388c2ecf20Sopenharmony_ci	CTRY_JAPAN43 = 4043,
2398c2ecf20Sopenharmony_ci	CTRY_JAPAN44 = 4044,
2408c2ecf20Sopenharmony_ci	CTRY_JAPAN45 = 4045,
2418c2ecf20Sopenharmony_ci	CTRY_JAPAN46 = 4046,
2428c2ecf20Sopenharmony_ci	CTRY_JAPAN47 = 4047,
2438c2ecf20Sopenharmony_ci	CTRY_JAPAN48 = 4048,
2448c2ecf20Sopenharmony_ci	CTRY_JAPAN49 = 4049,
2458c2ecf20Sopenharmony_ci	CTRY_JAPAN50 = 4050,
2468c2ecf20Sopenharmony_ci	CTRY_JAPAN51 = 4051,
2478c2ecf20Sopenharmony_ci	CTRY_JAPAN52 = 4052,
2488c2ecf20Sopenharmony_ci	CTRY_JAPAN53 = 4053,
2498c2ecf20Sopenharmony_ci	CTRY_JAPAN54 = 4054,
2508c2ecf20Sopenharmony_ci	CTRY_JAPAN55 = 4055,
2518c2ecf20Sopenharmony_ci	CTRY_JAPAN56 = 4056,
2528c2ecf20Sopenharmony_ci	CTRY_JAPAN57 = 4057,
2538c2ecf20Sopenharmony_ci	CTRY_JAPAN58 = 4058,
2548c2ecf20Sopenharmony_ci	CTRY_JAPAN59 = 4059,
2558c2ecf20Sopenharmony_ci	CTRY_AUSTRALIA2 = 5000,
2568c2ecf20Sopenharmony_ci	CTRY_CANADA2 = 5001,
2578c2ecf20Sopenharmony_ci	CTRY_BELGIUM2 = 5002
2588c2ecf20Sopenharmony_ci};
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_cibool ath_is_world_regd(struct ath_regulatory *reg);
2618c2ecf20Sopenharmony_cibool ath_is_49ghz_allowed(u16 redomain);
2628c2ecf20Sopenharmony_ciu16 ath_regd_find_country_by_name(char *alpha2);
2638c2ecf20Sopenharmony_ciint ath_regd_init(struct ath_regulatory *reg, struct wiphy *wiphy,
2648c2ecf20Sopenharmony_ci		  void (*reg_notifier)(struct wiphy *wiphy,
2658c2ecf20Sopenharmony_ci				       struct regulatory_request *request));
2668c2ecf20Sopenharmony_ciu32 ath_regd_get_band_ctl(struct ath_regulatory *reg,
2678c2ecf20Sopenharmony_ci			  enum nl80211_band band);
2688c2ecf20Sopenharmony_civoid ath_reg_notifier_apply(struct wiphy *wiphy,
2698c2ecf20Sopenharmony_ci			    struct regulatory_request *request,
2708c2ecf20Sopenharmony_ci			    struct ath_regulatory *reg);
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci#endif
273