Re: [PATCH v5 0/6] MIPS: ralink: add CPU clock detection and clock driver for MT7621
Hi all, On Sun, Dec 20, 2020 at 10:37 AM Sergio Paracuellos wrote: > > This patchset ports CPU clock detection for MT7621 from OpenWrt > and adds a complete clock plan for the mt7621 SOC. > > The documentation for this SOC only talks about two registers > regarding to the clocks: > * SYSC_REG_CPLL_CLKCFG0 - provides some information about boostrapped > refclock. PLL and dividers used for CPU and some sort of BUS (AHB?). > * SYSC_REG_CPLL_CLKCFG1 - a banch of gates to enable/disable clocks for > all or some ip cores. > > No documentation about a probably existent set of dividers for each ip > core is included in the datasheets. So we cannot make anything better, > AFAICT. > > Looking into driver code, and some openWRT patched there are > another frequences which are used in some drivers (uart, sd...). > According to all of this information the clock plan for this > SoC is set as follows: > - Main top clock "xtal" from where all the rest of the world is >derived. > - CPU clock "cpu" derived from "xtal" frequencies and a bunch of >register reads and predividers. > - BUS clock "bus" derived from "cpu" and with (cpu / 4) MHz. > - Fixed clocks from "xtal": > * "50m": 50 MHz. > * "125m": 125 MHz. > * "150m": 150 MHz. > * "250m": 250 MHz. > * "270m": 270 MHz. > > We also have a buch of gate clocks with their parents: > - "hsdma": "150m" > - "fe": "250m" > - "sp_divtx": "270m" > - "timer": "50m" > - "pcm": "270m" > - "pio": "50m" > - "gdma": "bus" > - "nand": "125m" > - "i2c": "50m" > - "i2s": "270m" > - "spi": "bus" > - "uart1": "50m" > - "uart2": "50m" > - "uart3": "50m" > - "eth": "50m" > - "pcie0": "125m" > - "pcie1": "125m" > - "pcie2": "125m" > - "crypto": "250m" > - "shxc": "50m" > > There was a previous attempt of doing this here[0] but the author > (Chuanhong Guo) did not wanted to make assumptions of a clock plan > for the platform that time. It seems that now he has a better idea of > how the clocks are dispossed for this SoC so he share code[1] where > some frequencies and clock parents for the gates are coded from a > real mediatek private clock plan. > > I do really want this to be upstreamed so according to the comments > in previous attempt[0] from Oleksij Rempel and the frequencies in > code[1] I have tried to do this by myself. > > All of this patches have been tested in a GNUBee PC1 resulting in a > working platform. > > Changes in v5: > - Avoid the use of syscon. All drivers of this platform are just using >platform operations defined in 'asm/mach-ralink/ralink_regs.h'. We also >need them for some PLL registers that are not in the sys control area. >Hence, since we must use this dependency avoid to define clock driver >as a child of the sysc node in the device tree and follow current >platform code style. > - Update bindings documentation to don't refer the syscon and make >remove 'clock-output-names' property from required ones. > - Use 'asm/mach-ralink/ralink_regs.h' platform read and write operations >instead of regmap from the syscon node. > - Remove 'mt7621_clk_provider' and directly declare 'clk_hw_onecell_data' >pointer in 'mt7621_clk_init' and pass from there into different register >functions. Remove pointers to 'mt7621_clk_provider' in the rest fo structs >used in this driver. > - Remove MHZ macro and just pass values directly in hertzs. > - Avoid 'CLK_IGNORE_UNUSED' flag for gates and add a new function called >'mt7621_prepare_enable_clocks' to prepare all of them to make clocks >referenced and don't affect current driver code. > - Remove COMPILE_TEST from Kconfig because of the use of especific arch >stuff. > - Fix commit message where a typo for "frequencies" word was present. > - Make use of parent_clk_data in 'CLK_BASE' macro. > - Remove MODULE_* macros from code since this is not a module. > - Remove not needed includes. > - Hardcode "xtal" as parent in FIXED macro. > - Change 'else if' clause into 'if' clause since a return statement was >being used in 'mt7621_xtal_recalc_rate'. > > NOTES: >- Driver is still being declared using 'CLK_OF_DECLARE' for all the > clocks. I have explored the possibility to make some of them available > afterwards using 'CLK_OF_DECLARE_DRIVER' for top clocks and the rest > using a platform driver. The resulting code was uglier since we only want > to use the same device tree node and the top clocks must be copied again > for the new platform register stuff to properly have a good hierarchy. > New globals needs to be introduced and in this particular case I don't > really see the benefits of doing in this way. I am totally ok to have all > the clocks registered at early stage since from other drivers perspective > we only really need to enable gates. So, I prefer to have them in that > way if it is not a real problem, of course. Any comments on this? Is ok to maintain this as
[PATCH 0/6] wlan-ng: checkpatch.pl cleanup series
Hi, This patch series cleans up all the checkpatch.pl related warnings in the wlan-ng module. I tried to resolve those issues in a sensible manner. Johannes Czekay (6): wlan-ng: clean up line ending wlan-ng: clean up spinlock_t definition wlan-ng: rename macros wlan-ng: clean up line length wlan-ng: clean up alignment wlan-ng: clean up reused macros drivers/staging/wlan-ng/cfg80211.c | 33 --- drivers/staging/wlan-ng/hfa384x.h | 2 +- drivers/staging/wlan-ng/p80211metadef.h| 24 +-- drivers/staging/wlan-ng/p80211metastruct.h | 18 +--- drivers/staging/wlan-ng/p80211netdev.c | 2 +- drivers/staging/wlan-ng/p80211req.c| 6 +-- drivers/staging/wlan-ng/prism2mgmt.c | 48 ++ drivers/staging/wlan-ng/prism2mib.c| 18 8 files changed, 56 insertions(+), 95 deletions(-) -- 2.25.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/6] wlan-ng: clean up alignment
This patch cleans up all the alignment related warnings from checkpatch. Signed-off-by: Johannes Czekay Co-developed-by: Nicolai Fischer Signed-off-by: Nicolai Fischer --- drivers/staging/wlan-ng/cfg80211.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c index 0e44a0f73a6a..ac62746cf92e 100644 --- a/drivers/staging/wlan-ng/cfg80211.c +++ b/drivers/staging/wlan-ng/cfg80211.c @@ -472,8 +472,8 @@ static int prism2_connect(struct wiphy *wiphy, struct net_device *dev, return -EINVAL; result = prism2_domibset_uint32(wlandev, - DIDMIB_DOT11SMT_PRIVACYTBL_WEPDEFAULTKEYID, - sme->key_idx); + DIDMIB_DOT11SMT_PRIVACYTBL_WEPDEFAULTKEYID, + sme->key_idx); if (result) goto exit; @@ -584,8 +584,8 @@ static int prism2_set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, data = MBM_TO_DBM(mbm); result = prism2_domibset_uint32(wlandev, - DIDMIB_DOT11PHY_TXPOWERTABLE_CURRENTTXPOWERLEVEL, - data); + DIDMIB_DOT11PHY_TXPOWERTABLE_CURRENTTXPOWERLEVEL, + data); if (result) { err = -EFAULT; -- 2.25.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/6] wlan-ng: clean up spinlock_t definition
This patch cleans up a "spinlock_t definition without comment" warning in hfa384x.h. Signed-off-by: Johannes Czekay Co-developed-by: Nicolai Fischer Signed-off-by: Nicolai Fischer --- drivers/staging/wlan-ng/hfa384x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 88e894dd3568..13ab9545a066 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -1184,7 +1184,7 @@ struct hfa384x_usbctlx { }; struct hfa384x_usbctlxq { - spinlock_t lock; + spinlock_t lock;/* Lock for CTLX que */ struct list_head pending; struct list_head active; struct list_head completing; -- 2.25.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/6] wlan-ng: clean up line length
This patch cleans up all remaining line length related warnings. Signed-off-by: Johannes Czekay Co-developed-by: Nicolai Fischer Signed-off-by: Nicolai Fischer --- drivers/staging/wlan-ng/cfg80211.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c index bdb1e6677cc7..0e44a0f73a6a 100644 --- a/drivers/staging/wlan-ng/cfg80211.c +++ b/drivers/staging/wlan-ng/cfg80211.c @@ -365,7 +365,8 @@ static int prism2_scan(struct wiphy *wiphy, msg2.beaconperiod.data, ie_buf, ie_len, - (msg2.signal.data - 65536) * 100, /* Conversion to signed type */ + /* Conversion to signed type */ + (msg2.signal.data - 65536) * 100, GFP_KERNEL); if (!bss) { -- 2.25.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/6] wlan-ng: rename macros
This patch renames some of the macros defined in "p80211metadef.h" in order to fix some of the line length related warnings from checkpatch. Since these macros are very long, fitting them within the given line length would be really hard otherwise. Signed-off-by: Johannes Czekay Co-developed-by: Nicolai Fischer Signed-off-by: Nicolai Fischer --- drivers/staging/wlan-ng/cfg80211.c | 18 +- drivers/staging/wlan-ng/p80211metadef.h | 24 drivers/staging/wlan-ng/p80211netdev.c | 2 +- drivers/staging/wlan-ng/p80211req.c | 6 +++--- drivers/staging/wlan-ng/prism2mib.c | 18 +- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c index eda5b5a4e089..bdb1e6677cc7 100644 --- a/drivers/staging/wlan-ng/cfg80211.c +++ b/drivers/staging/wlan-ng/cfg80211.c @@ -159,7 +159,7 @@ static int prism2_add_key(struct wiphy *wiphy, struct net_device *dev, } if (prism2_domibset_uint32(wlandev, - DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID, + DIDMIB_DOT11SMT_PRIVACYTBL_WEPDEFAULTKEYID, key_index)) return -EFAULT; @@ -232,7 +232,7 @@ static int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, struct wlandevice *wlandev = dev->ml_priv; return prism2_domibset_uint32(wlandev, - DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID, + DIDMIB_DOT11SMT_PRIVACYTBL_WEPDEFAULTKEYID, key_index); } @@ -401,7 +401,7 @@ static int prism2_set_wiphy_params(struct wiphy *wiphy, u32 changed) data = wiphy->rts_threshold; result = prism2_domibset_uint32(wlandev, - DIDMIB_DOT11MAC_OPERATIONTABLE_RTSTHRESHOLD, + DIDMIB_DOT11MAC_OPERATIONTBL_RTSTHRESHOLD, data); if (result) { err = -EFAULT; @@ -416,7 +416,7 @@ static int prism2_set_wiphy_params(struct wiphy *wiphy, u32 changed) data = wiphy->frag_threshold; result = prism2_domibset_uint32(wlandev, - DIDMIB_DOT11MAC_OPERATIONTABLE_FRAGMENTATIONTHRESHOLD, + DIDMIB_DOT11MAC_OPERATIONTBL_FRAGMENTATIONTHRESHOLD, data); if (result) { err = -EFAULT; @@ -471,7 +471,7 @@ static int prism2_connect(struct wiphy *wiphy, struct net_device *dev, return -EINVAL; result = prism2_domibset_uint32(wlandev, - DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID, + DIDMIB_DOT11SMT_PRIVACYTBL_WEPDEFAULTKEYID, sme->key_idx); if (result) goto exit; @@ -490,13 +490,13 @@ static int prism2_connect(struct wiphy *wiphy, struct net_device *dev, * seems reasonable anyways */ result = prism2_domibset_uint32(wlandev, - DIDMIB_DOT11SMT_PRIVACYTABLE_PRIVACYINVOKED, + DIDMIB_DOT11SMT_PRIVACYTBL_PRIVACYINVOKED, P80211ENUM_truth_true); if (result) goto exit; result = prism2_domibset_uint32(wlandev, - DIDMIB_DOT11SMT_PRIVACYTABLE_EXCLUDEUNENCRYPTED, + DIDMIB_DOT11SMT_PRIVACYTBL_EXCLUDEUNENCRYPTED, P80211ENUM_truth_true); if (result) goto exit; @@ -506,13 +506,13 @@ static int prism2_connect(struct wiphy *wiphy, struct net_device *dev, * and exclude unencrypted */ result = prism2_domibset_uint32(wlandev, - DIDMIB_DOT11SMT_PRIVACYTABLE_PRIVACYINVOKED, + DIDMIB_DOT11SMT_PRIVACYTBL_PRIVACYINVOKED, P80211ENUM_truth_false); if (result) goto exit; result = prism2_domibset_uint32(wlandev, - DIDMIB_DOT11SMT_PRIVACYTABLE_EXCLUDEUNENCRYPTED, + DIDMIB_DOT11SMT_PRIVACYTBL_EXCLUDEUNENCRYPTED,
[PATCH 6/6] wlan-ng: clean up reused macros
This patch cleans up two "macro argument reuse" warnings by checkpatch. This should also make the code much more readable. Signed-off-by: Johannes Czekay Co-developed-by: Nicolai Fischer Signed-off-by: Nicolai Fischer --- drivers/staging/wlan-ng/p80211metastruct.h | 18 +--- drivers/staging/wlan-ng/prism2mgmt.c | 48 ++ 2 files changed, 14 insertions(+), 52 deletions(-) diff --git a/drivers/staging/wlan-ng/p80211metastruct.h b/drivers/staging/wlan-ng/p80211metastruct.h index 4adc64580185..e963227f797c 100644 --- a/drivers/staging/wlan-ng/p80211metastruct.h +++ b/drivers/staging/wlan-ng/p80211metastruct.h @@ -114,22 +114,8 @@ struct p80211msg_dot11req_scan_results { struct p80211item_uint32 cfpollreq; struct p80211item_uint32 privacy; struct p80211item_uint32 capinfo; - struct p80211item_uint32 basicrate1; - struct p80211item_uint32 basicrate2; - struct p80211item_uint32 basicrate3; - struct p80211item_uint32 basicrate4; - struct p80211item_uint32 basicrate5; - struct p80211item_uint32 basicrate6; - struct p80211item_uint32 basicrate7; - struct p80211item_uint32 basicrate8; - struct p80211item_uint32 supprate1; - struct p80211item_uint32 supprate2; - struct p80211item_uint32 supprate3; - struct p80211item_uint32 supprate4; - struct p80211item_uint32 supprate5; - struct p80211item_uint32 supprate6; - struct p80211item_uint32 supprate7; - struct p80211item_uint32 supprate8; + struct p80211item_uint32 basicrate[8]; + struct p80211item_uint32 supprate[8]; } __packed; struct p80211msg_dot11req_start { diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c index 1bd36dc2b7ff..8540c3336907 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.c +++ b/drivers/staging/wlan-ng/prism2mgmt.c @@ -388,6 +388,7 @@ int prism2mgmt_scan_results(struct wlandevice *wlandev, void *msgp) struct hfa384x_hscan_result_sub *item = NULL; int count; + int i; req = msgp; @@ -437,42 +438,17 @@ int prism2mgmt_scan_results(struct wlandevice *wlandev, void *msgp) if (item->supprates[count] == 0) break; -#define REQBASICRATE(N) \ - do { \ - if ((count >= (N)) && DOT11_RATE5_ISBASIC_GET( \ - item->supprates[(N) - 1])) { \ - req->basicrate ## N .data = item->supprates[(N) - 1]; \ - req->basicrate ## N .status = \ - P80211ENUM_msgitem_status_data_ok; \ - } \ - } while (0) - - REQBASICRATE(1); - REQBASICRATE(2); - REQBASICRATE(3); - REQBASICRATE(4); - REQBASICRATE(5); - REQBASICRATE(6); - REQBASICRATE(7); - REQBASICRATE(8); - -#define REQSUPPRATE(N) \ - do { \ - if (count >= (N)) { \ - req->supprate ## N .data = item->supprates[(N) - 1]; \ - req->supprate ## N .status = \ - P80211ENUM_msgitem_status_data_ok; \ - } \ - } while (0) - - REQSUPPRATE(1); - REQSUPPRATE(2); - REQSUPPRATE(3); - REQSUPPRATE(4); - REQSUPPRATE(5); - REQSUPPRATE(6); - REQSUPPRATE(7); - REQSUPPRATE(8); + for (i = 0; i < 8; i++) { + if (count > 1) { + if (DOT11_RATE5_ISBASIC_GET(item->supprates[i])) { + req->basicrate[i].data = item->supprates[i]; + req->basicrate[i].status = P80211ENUM_msgitem_status_data_ok; + } + + req->supprate[i].data = item->supprates[i]; + req->supprate[i].status = P80211ENUM_msgitem_status_data_ok; + } + } /* beacon period */ req->beaconperiod.status = P80211ENUM_msgitem_status_data_ok; -- 2.25.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/6] wlan-ng: clean up line ending
This patch cleans up all the "Lines should not end with a '('" warnings. Signed-off-by: Johannes Czekay Co-developed-by: Nicolai Fischer Signed-off-by: Nicolai Fischer --- drivers/staging/wlan-ng/cfg80211.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c index 759e475e303c..eda5b5a4e089 100644 --- a/drivers/staging/wlan-ng/cfg80211.c +++ b/drivers/staging/wlan-ng/cfg80211.c @@ -324,8 +324,7 @@ static int prism2_scan(struct wiphy *wiphy, (i < request->n_channels) && i < ARRAY_SIZE(prism2_channels); i++) msg1.channellist.data.data[i] = - ieee80211_frequency_to_channel( - request->channels[i]->center_freq); + ieee80211_frequency_to_channel(request->channels[i]->center_freq); msg1.channellist.data.len = request->n_channels; msg1.maxchanneltime.data = 250; @@ -478,8 +477,7 @@ static int prism2_connect(struct wiphy *wiphy, struct net_device *dev, goto exit; /* send key to driver */ - did = didmib_dot11smt_wepdefaultkeystable_key( - sme->key_idx + 1); + did = didmib_dot11smt_wepdefaultkeystable_key(sme->key_idx + 1); result = prism2_domibset_pstr32(wlandev, did, sme->key_len, (u8 *)sme->key); -- 2.25.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel