-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
ath79: ag71xx: apply interface mode to MII0/1_CTRL on ar71xx/ar913x #1271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| mii_if = AR71XX_MII1_CTRL_IF_RGMII; | ||
| break; | ||
| default: | ||
| BUG(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://elixir.bootlin.com/linux/v4.17/source/include/asm-generic/bug.h#L42
Don't use BUG() or BUG_ON() unless there's really no way out [...]
If the (sub)system can somehow continue operating, perhaps with reduced functionality, it's probably not BUG-worthy.
| @@ -1427,6 +1468,9 @@ static int ag71xx_probe(struct platform_device *pdev) | |||
| goto err_free; | |||
| } | |||
|
|
|||
| if (ag->mii_base) | |||
| ath79_mii_ctrl_set_if(ag, of_property_read_bool(np, "qca,is-mii1")); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you aware of any other differences between MII0 and MII1?
upstream drivers typically uses a different "compatible" property per actual IP block
I would like to avoid having a "qca,is-mac1" for example property later on, just because there's more differences in other registers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And why eth1 is marked as "qca,is-mii1"? On another device eth0 may be connected this way.
|
Would you please split the "ath79: ag71xx: fix MII0/1_CTRL settings on ar71xx/ar913x" into multiple atomic changes. One issue that gets fixed is that the speed settings are written to the interface related bits of the register. The other change adds the so far missing function that actually sets the interface mode related bits of the register. I don't really like the "qca,is-mii1" property. But it doesn't look like I'll have the time to check for a better way of doing it today. Just to let you know. |
|
What about using a separated dt node for MII_CNTL like the qca,ar9330-gmac in ar9330.dtsi? |
Assuming you mean different compatible, that might work. It is really hard to give a good advice without having the code/datasheets checked so far. |
|
I mean something like this in dts: diff --git a/target/linux/ath79/dts/ar7100.dtsi b/target/linux/ath79/dts/ar7100.dtsi
index 5b9a84197f..5ba887e43b 100644
--- a/target/linux/ath79/dts/ar7100.dtsi
+++ b/target/linux/ath79/dts/ar7100.dtsi
@@ -96,6 +96,16 @@
#reset-cells = <1>;
};
+ mii0: mii@18070000 {
+ compatible = "qca,ar7100-mii0";
+ reg = <0x18070000 0x4>;
+ };
+
+ mii1: mii@18070004 {
+ compatible = "qca,ar7100-mii1";
+ reg = <0x18070004 0x4>;
+ };
+
pcie0: pcie-controller@180c0000 {
compatible = "qca,ar7100-pci";
#address-cells = <3>;
@@ -172,8 +182,6 @@
ð0 {
compatible = "qca,ar7100-eth";
- reg = <0x19000000 0x200
- 0x18070000 0x4>;
pll-data = <0x00110000 0x00001099 0x00991099>;
pll-reg = <0x4 0x10 17>;
@@ -182,6 +190,7 @@
resets = <&rst 9>;
reset-names = "mac";
+ qca,mii-dev = <&mii0>;
};
&mdio1 {
@@ -190,8 +199,6 @@
ð1 {
compatible = "qca,ar7100-eth";
- reg = <0x1a000000 0x200
- 0x18070004 0x4>;
pll-data = <0x00110000 0x00001099 0x00991099>;
pll-reg = <0x4 0x14 19>;
@@ -201,4 +208,5 @@
resets = <&rst 13>;
reset-names = "mac";
+ qca,mii-dev = <&mii1>;
};and use of_iomap/of_iounmap in driver. |
|
looks way cleaner to me. Am i right that |
devicetree should describe the hardware if it's not a separate device (but just a separate register because the hardware designers thought it was a good idea to keep it separate) then I would only change the Ethernet controller's compatible string from "qca,ar7100-eth" to "qca,ar7100-eth0" and/or "qca,ar7100-eth1" I am not very familiar with the ath79 hardware |
They are defined in ath79.dtsi @xdarklight But...
...since this is the only thing this address space is used for, I don't know why there would be such a separated IP block used to configure only two parameters.
I might describe this block on ar7100 as a multiplexer (like pinmux of gpio) but I don't know whether it's suitable. |
the interface type bits seem like a pinmux controller if you choose to go with that we may end up with something like this: does the datasheet say anything about the missing information we need to solve these TODOs? |
|
Here is a leaked datasheet found on GitHub: https://github.com/Deoptim/atheros/raw/master/AR7100_nowatermark.pdf |
if it's the actual "interface speed" then I would say that the register belongs to the MAC
you can also get feedback from the devicetree maintainers which are reviewing the dt-bindings in the kernel by emailing devicetree@vger.kernel.org |
Ah... I don't have these things :(
I guess that's what PLL registers did. We have three raw values for PLL registers corresponding to 1G/100M/10M. I've updated the code and used qca,ar7100-eth0/1 as compatible string now. |
|
The patch fixing speed settings can be applied first if there are still problems with interface mode. Fixing speed settings will get devices with correct interface mode set by u-boot work. |
|
Something is wrong on ar913x on tp-link 1043v1 If I write anything to 0x18070000, then it resets to 0x00000000. Same with pll-reg 0xb8050010 Writing to 0xb8050014 works, but I am not sure which is the correct reg. |
|
Not really wrong. You need to bring the pll into reset to change the values. You remember the three magic register writes in one if the set pll functions. That is what they are supposed to do.
… Am 12.08.2018 um 14:19 schrieb Dmitry Tunin ***@***.***>:
Something is wrong on ar913x on tp-link 1043v1
If I write anything to 0x18070000, then it resets to 0x00000000.
Same with pll-reg 0xb8050010
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
But it worked the same way on dir-825. These are mii registers. |
|
Can't reproduce on ar9132 (TL-WR941N v2) |
|
And what are the correct values for a fixed rgmii link 1000?
вс, 12 авг. 2018 г. в 15:44, 蝈蝈 <notifications@github.com>:
… Can't reproduce on ar9132 (TL-WR941N v2)
***@***.***:/# devmem 0x18070000
0x00000013
***@***.***:/# devmem 0x18070000 32 0x0
***@***.***:/# devmem 0x18070000
0x00000000
***@***.***:/# devmem 0x18070000 32 0x13
***@***.***:/# devmem 0x18070000
0x00000013
***@***.***:/# devmem 0x18070004
0x00000000
***@***.***:/# devmem 0x18070004 32 0x10
***@***.***:/# devmem 0x18070004
0x00000010
***@***.***:/#
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1271 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AJYkt5JJwVr0-vxA_DYC-DU-w_whQCWwks5uQCMagaJpZM4V5LIY>
.
|
|
Now I have |
|
The same as AR7100, it's 0x22. (Code in ar71xx for MII_CNTL is in arch/mips/ath79/dev-eth.c) |
|
So It's 0x22 and 0x10? |
|
It seemed that openwrt doesn't use second GMAC on AR9132 for WR1043ND v1 so we don't need to set value at 0x18070004. (I don't know whether factory firmware used GMAC1) |
|
I am confused with which is used. I added debug by mkresin and get this
[ 49.068378] MKR: ath79_set_pllval()
[ 49.071888] MKR: 0xb8050010 init value: 0x00000000
[ 49.076702] MKR: 0xb8050014 init value: 0x13000a44
[ 49.081513] MKR: speed 1000
[ 49.084328] MKR: wrote 0x1a000000 to offset 0x00000010 and got return code 0
[ 49.091411] MKR: 0xb8050010 final value: 0x00000000
[ 49.096312] MKR: 0xb8050014 final value: 0x13000a44
[ 49.101414] MKR: 0xb8050010 final value: 0x00000000
[ 49.106314] MKR: 0xb8050014 final value: 0x13000a44
[ 49.111223] eth0: link up (1000Mbps/Full duplex)
It looks like we are writing to a wrong reg.
…
It seemed that openwrt doesn't use second GMAC on AR9132 for WR1043ND v1 so we don't need to set value at 0x18070004. (I don't know whether factory firmware used GMAC1)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
@mkresin But it seems that they do it a wrong way, because we get 0x0 in the register. |
|
I suggest reading dev-eth.c once. |
|
@981213 I already tried to change the pll-reg, but the switch didn't work. I'll try to build it again clean, maybe I broke something else. |
|
So I was correct. I broke something. After resetting the tree, the pll works OK. |
|
My commit is still wrong.... PLL shift is 20 instead of 17. |
|
But it worked with 17. |
|
@981213 So I built an image for 1043-v1. All works well. |
|
And it is really 17 in arch/mips/ath79/dev-eth.c #define AR71XX_ETH0_PLL_SHIFT 17 in ar71xx_regs.h |
|
That AR71XX means AR7130/AR7141/AR7161 static void ar91xx_set_speed_ge0(int speed)
{
u32 val = ath79_get_eth_pll(0, speed);
ath79_set_pll(AR913X_PLL_REG_ETH_CONFIG, AR913X_PLL_REG_ETH0_INT_CLOCK,
val, AR913X_ETH0_PLL_SHIFT);
ath79_mii_ctrl_set_speed(AR71XX_MII_REG_MII0_CTRL, speed);
}
static void ar91xx_set_speed_ge1(int speed)
{
u32 val = ath79_get_eth_pll(1, speed);
ath79_set_pll(AR913X_PLL_REG_ETH_CONFIG, AR913X_PLL_REG_ETH1_INT_CLOCK,
val, AR913X_ETH1_PLL_SHIFT);
ath79_mii_ctrl_set_speed(AR71XX_MII_REG_MII1_CTRL, speed);
} case ATH79_SOC_AR9132:
pdata->has_gbit = 1;
/* fall through */
case ATH79_SOC_AR9130:
if (id == 0)
pdata->set_speed = ar91xx_set_speed_ge0;
else
pdata->set_speed = ar91xx_set_speed_ge1;
pdata->is_ar91xx = 1;
break; |
|
Mine is AR9132 with gigabit. We need to set the reg per device then. |
|
Oh, it is fall through. Hm.. |
|
So it works with both 17, or 20 shift. |
|
Picked two more commits from the PR. Please rebase on master. |
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
|
Honestly I think my approach here is ugly :( |
|
@mkresin @xdarklight |
|
Yep, looks like the first two merged commits require also this third unmerged commit at least for the WNDR3700 series. It fixes wan (1000 Mbit link) on my WNDR3800. (I had tested just the wifi and LED things in the past two days with a standalone AP, and did not notice that wan on WNDR3x00 is now broken :-( |
|
@hnyman It was always broken. You probably built with this patch and everyone had an impression it's not really needed for your device. DIR-825 works without it, becuase u-boot sets the mode. |
In this way we'll have to introduce 4 compatible strings (ar7100-eth0/ar7100-eth1/ar9130-eth0/ar9130-eth1) for only one register difference, which I think may noy be worthy. |
|
@981213 Why not of the devices are really different? What is wrong to have different compatible strings for really different devices? It should be seen in DTS that they are different, not hidden in the driver. |
|
I'll implement the "compatible string" one next Monday if there are no more feedback from mail list. |
Check commit messages for description :-)