• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisiónfc97ff2695d6d7fbea7d5fda7b080f405d6ee744 (tree)
Tiempo2022-07-19 23:52:15
AutorTom Rini <trini@kons...>
CommiterTom Rini

Log Message

Merge https://source.denx.de/u-boot/custodians/u-boot-sunxi

To quote Andre:

One prominent feature is the restructering of the clock driver, which
allows to end up with one actual driver for all variants, although we
still only compile in support for one SoC.
Also contained are some initial SPI fixes, which should fix some
problems, and enable SPI flash support for the F1C100s SoC. Those
patches revealed more problems, I will queue fixes later on, but for
now it should at least still work.
Apart from some smaller fixes (for instance for NAND operation), there
is also preparation for the upcoming Allwinner D1 support, in form of
the USB PHY driver. There are more driver support patches to come.

The gitlab CI completed successfully, including the build test for all
160 sunxi boards. I also boot tested on a few boards, but didn't have
time for more elaborate tests this time.

Cambiar Resumen

Diferencia incremental

--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -679,15 +679,6 @@ config MMC_SUNXI_SLOT_EXTRA
679679 slot or emmc on mmc1 - mmc3. Setting this to 1, 2 or 3 will enable
680680 support for this.
681681
682-config INITIAL_USB_SCAN_DELAY
683- int "delay initial usb scan by x ms to allow builtin devices to init"
684- default 0
685- ---help---
686- Some boards have on board usb devices which need longer than the
687- USB spec's 1 second to connect from board powerup. Set this config
688- option to a non 0 value to add an extra delay before the first usb
689- bus scan.
690-
691682 config USB0_VBUS_PIN
692683 string "Vbus enable pin for usb0 (otg)"
693684 default ""
@@ -850,8 +841,9 @@ config VIDEO_LCD_DCLK_PHASE
850841 int "LCD panel display clock phase"
851842 depends on VIDEO_SUNXI || DM_VIDEO
852843 default 1
844+ range 0 3
853845 ---help---
854- Select LCD panel display clock phase shift, range 0-3.
846+ Select LCD panel display clock phase shift
855847
856848 config VIDEO_LCD_POWER
857849 string "LCD panel power enable pin"
--- a/configs/licheepi_nano_defconfig
+++ b/configs/licheepi_nano_defconfig
@@ -13,3 +13,6 @@ CONFIG_SPL_SPI_SUNXI=y
1313 CONFIG_SPL_STACK=0x8000
1414 CONFIG_SYS_PBSIZE=1024
1515 # CONFIG_SYSRESET is not set
16+CONFIG_SPI_FLASH_WINBOND=y
17+CONFIG_SPI_FLASH_XTX=y
18+CONFIG_SPI=y
--- a/configs/orangepi_zero_defconfig
+++ b/configs/orangepi_zero_defconfig
@@ -10,6 +10,7 @@ CONFIG_SPL_SPI_SUNXI=y
1010 CONFIG_CONSOLE_MUX=y
1111 CONFIG_SPL_STACK=0x8000
1212 CONFIG_SYS_PBSIZE=1024
13+CONFIG_SPI_FLASH_MACRONIX=y
1314 CONFIG_SPI_FLASH_WINBOND=y
1415 CONFIG_SUN8I_EMAC=y
1516 CONFIG_SPI=y
--- a/drivers/clk/sunxi/clk_a10.c
+++ b/drivers/clk/sunxi/clk_a10.c
@@ -64,30 +64,9 @@ static struct ccu_reset a10_resets[] = {
6464 [RST_USB_PHY2] = RESET(0x0cc, BIT(2)),
6565 };
6666
67-static const struct ccu_desc a10_ccu_desc = {
67+const struct ccu_desc a10_ccu_desc = {
6868 .gates = a10_gates,
6969 .resets = a10_resets,
70-};
71-
72-static int a10_clk_bind(struct udevice *dev)
73-{
74- return sunxi_reset_bind(dev, ARRAY_SIZE(a10_resets));
75-}
76-
77-static const struct udevice_id a10_ccu_ids[] = {
78- { .compatible = "allwinner,sun4i-a10-ccu",
79- .data = (ulong)&a10_ccu_desc },
80- { .compatible = "allwinner,sun7i-a20-ccu",
81- .data = (ulong)&a10_ccu_desc },
82- { }
83-};
84-
85-U_BOOT_DRIVER(clk_sun4i_a10) = {
86- .name = "sun4i_a10_ccu",
87- .id = UCLASS_CLK,
88- .of_match = a10_ccu_ids,
89- .priv_auto = sizeof(struct ccu_priv),
90- .ops = &sunxi_clk_ops,
91- .probe = sunxi_clk_probe,
92- .bind = a10_clk_bind,
70+ .num_gates = ARRAY_SIZE(a10_gates),
71+ .num_resets = ARRAY_SIZE(a10_resets),
9372 };
--- a/drivers/clk/sunxi/clk_a10s.c
+++ b/drivers/clk/sunxi/clk_a10s.c
@@ -49,30 +49,9 @@ static struct ccu_reset a10s_resets[] = {
4949 [RST_USB_PHY1] = RESET(0x0cc, BIT(1)),
5050 };
5151
52-static const struct ccu_desc a10s_ccu_desc = {
52+const struct ccu_desc a10s_ccu_desc = {
5353 .gates = a10s_gates,
5454 .resets = a10s_resets,
55-};
56-
57-static int a10s_clk_bind(struct udevice *dev)
58-{
59- return sunxi_reset_bind(dev, ARRAY_SIZE(a10s_resets));
60-}
61-
62-static const struct udevice_id a10s_ccu_ids[] = {
63- { .compatible = "allwinner,sun5i-a10s-ccu",
64- .data = (ulong)&a10s_ccu_desc },
65- { .compatible = "allwinner,sun5i-a13-ccu",
66- .data = (ulong)&a10s_ccu_desc },
67- { }
68-};
69-
70-U_BOOT_DRIVER(clk_sun5i_a10s) = {
71- .name = "sun5i_a10s_ccu",
72- .id = UCLASS_CLK,
73- .of_match = a10s_ccu_ids,
74- .priv_auto = sizeof(struct ccu_priv),
75- .ops = &sunxi_clk_ops,
76- .probe = sunxi_clk_probe,
77- .bind = a10s_clk_bind,
55+ .num_gates = ARRAY_SIZE(a10s_gates),
56+ .num_resets = ARRAY_SIZE(a10s_resets),
7857 };
--- a/drivers/clk/sunxi/clk_a23.c
+++ b/drivers/clk/sunxi/clk_a23.c
@@ -68,30 +68,9 @@ static struct ccu_reset a23_resets[] = {
6868 [RST_BUS_UART4] = RESET(0x2d8, BIT(20)),
6969 };
7070
71-static const struct ccu_desc a23_ccu_desc = {
71+const struct ccu_desc a23_ccu_desc = {
7272 .gates = a23_gates,
7373 .resets = a23_resets,
74-};
75-
76-static int a23_clk_bind(struct udevice *dev)
77-{
78- return sunxi_reset_bind(dev, ARRAY_SIZE(a23_resets));
79-}
80-
81-static const struct udevice_id a23_clk_ids[] = {
82- { .compatible = "allwinner,sun8i-a23-ccu",
83- .data = (ulong)&a23_ccu_desc },
84- { .compatible = "allwinner,sun8i-a33-ccu",
85- .data = (ulong)&a23_ccu_desc },
86- { }
87-};
88-
89-U_BOOT_DRIVER(clk_sun8i_a23) = {
90- .name = "sun8i_a23_ccu",
91- .id = UCLASS_CLK,
92- .of_match = a23_clk_ids,
93- .priv_auto = sizeof(struct ccu_priv),
94- .ops = &sunxi_clk_ops,
95- .probe = sunxi_clk_probe,
96- .bind = a23_clk_bind,
74+ .num_gates = ARRAY_SIZE(a23_gates),
75+ .num_resets = ARRAY_SIZE(a23_resets),
9776 };
--- a/drivers/clk/sunxi/clk_a31.c
+++ b/drivers/clk/sunxi/clk_a31.c
@@ -89,28 +89,9 @@ static struct ccu_reset a31_resets[] = {
8989 [RST_APB2_UART5] = RESET(0x2d8, BIT(21)),
9090 };
9191
92-static const struct ccu_desc a31_ccu_desc = {
92+const struct ccu_desc a31_ccu_desc = {
9393 .gates = a31_gates,
9494 .resets = a31_resets,
95-};
96-
97-static int a31_clk_bind(struct udevice *dev)
98-{
99- return sunxi_reset_bind(dev, ARRAY_SIZE(a31_resets));
100-}
101-
102-static const struct udevice_id a31_clk_ids[] = {
103- { .compatible = "allwinner,sun6i-a31-ccu",
104- .data = (ulong)&a31_ccu_desc },
105- { }
106-};
107-
108-U_BOOT_DRIVER(clk_sun6i_a31) = {
109- .name = "sun6i_a31_ccu",
110- .id = UCLASS_CLK,
111- .of_match = a31_clk_ids,
112- .priv_auto = sizeof(struct ccu_priv),
113- .ops = &sunxi_clk_ops,
114- .probe = sunxi_clk_probe,
115- .bind = a31_clk_bind,
95+ .num_gates = ARRAY_SIZE(a31_gates),
96+ .num_resets = ARRAY_SIZE(a31_resets),
11697 };
--- a/drivers/clk/sunxi/clk_a31_r.c
+++ b/drivers/clk/sunxi/clk_a31_r.c
@@ -28,32 +28,9 @@ static struct ccu_reset a31_r_resets[] = {
2828 [RST_APB0_I2C] = RESET(0x0b0, BIT(6)),
2929 };
3030
31-static const struct ccu_desc a31_r_ccu_desc = {
31+const struct ccu_desc a31_r_ccu_desc = {
3232 .gates = a31_r_gates,
3333 .resets = a31_r_resets,
34-};
35-
36-static int a31_r_clk_bind(struct udevice *dev)
37-{
38- return sunxi_reset_bind(dev, ARRAY_SIZE(a31_r_resets));
39-}
40-
41-static const struct udevice_id a31_r_clk_ids[] = {
42- { .compatible = "allwinner,sun8i-a83t-r-ccu",
43- .data = (ulong)&a31_r_ccu_desc },
44- { .compatible = "allwinner,sun8i-h3-r-ccu",
45- .data = (ulong)&a31_r_ccu_desc },
46- { .compatible = "allwinner,sun50i-a64-r-ccu",
47- .data = (ulong)&a31_r_ccu_desc },
48- { }
49-};
50-
51-U_BOOT_DRIVER(clk_sun6i_a31_r) = {
52- .name = "sun6i_a31_r_ccu",
53- .id = UCLASS_CLK,
54- .of_match = a31_r_clk_ids,
55- .priv_auto = sizeof(struct ccu_priv),
56- .ops = &sunxi_clk_ops,
57- .probe = sunxi_clk_probe,
58- .bind = a31_r_clk_bind,
34+ .num_gates = ARRAY_SIZE(a31_r_gates),
35+ .num_resets = ARRAY_SIZE(a31_r_resets),
5936 };
--- a/drivers/clk/sunxi/clk_a64.c
+++ b/drivers/clk/sunxi/clk_a64.c
@@ -77,28 +77,9 @@ static const struct ccu_reset a64_resets[] = {
7777 [RST_BUS_UART4] = RESET(0x2d8, BIT(20)),
7878 };
7979
80-static const struct ccu_desc a64_ccu_desc = {
80+const struct ccu_desc a64_ccu_desc = {
8181 .gates = a64_gates,
8282 .resets = a64_resets,
83-};
84-
85-static int a64_clk_bind(struct udevice *dev)
86-{
87- return sunxi_reset_bind(dev, ARRAY_SIZE(a64_resets));
88-}
89-
90-static const struct udevice_id a64_ccu_ids[] = {
91- { .compatible = "allwinner,sun50i-a64-ccu",
92- .data = (ulong)&a64_ccu_desc },
93- { }
94-};
95-
96-U_BOOT_DRIVER(clk_sun50i_a64) = {
97- .name = "sun50i_a64_ccu",
98- .id = UCLASS_CLK,
99- .of_match = a64_ccu_ids,
100- .priv_auto = sizeof(struct ccu_priv),
101- .ops = &sunxi_clk_ops,
102- .probe = sunxi_clk_probe,
103- .bind = a64_clk_bind,
83+ .num_gates = ARRAY_SIZE(a64_gates),
84+ .num_resets = ARRAY_SIZE(a64_resets),
10485 };
--- a/drivers/clk/sunxi/clk_a80.c
+++ b/drivers/clk/sunxi/clk_a80.c
@@ -74,40 +74,16 @@ static const struct ccu_reset a80_mmc_resets[] = {
7474 [3] = GATE(0xc, BIT(18)),
7575 };
7676
77-static const struct ccu_desc a80_ccu_desc = {
77+const struct ccu_desc a80_ccu_desc = {
7878 .gates = a80_gates,
7979 .resets = a80_resets,
80+ .num_gates = ARRAY_SIZE(a80_gates),
81+ .num_resets = ARRAY_SIZE(a80_resets),
8082 };
8183
82-static const struct ccu_desc a80_mmc_clk_desc = {
84+const struct ccu_desc a80_mmc_clk_desc = {
8385 .gates = a80_mmc_gates,
8486 .resets = a80_mmc_resets,
85-};
86-
87-static int a80_clk_bind(struct udevice *dev)
88-{
89- ulong count = ARRAY_SIZE(a80_resets);
90-
91- if (device_is_compatible(dev, "allwinner,sun9i-a80-mmc-config-clk"))
92- count = ARRAY_SIZE(a80_mmc_resets);
93-
94- return sunxi_reset_bind(dev, count);
95-}
96-
97-static const struct udevice_id a80_ccu_ids[] = {
98- { .compatible = "allwinner,sun9i-a80-ccu",
99- .data = (ulong)&a80_ccu_desc },
100- { .compatible = "allwinner,sun9i-a80-mmc-config-clk",
101- .data = (ulong)&a80_mmc_clk_desc },
102- { }
103-};
104-
105-U_BOOT_DRIVER(clk_sun9i_a80) = {
106- .name = "sun9i_a80_ccu",
107- .id = UCLASS_CLK,
108- .of_match = a80_ccu_ids,
109- .priv_auto = sizeof(struct ccu_priv),
110- .ops = &sunxi_clk_ops,
111- .probe = sunxi_clk_probe,
112- .bind = a80_clk_bind,
87+ .num_gates = ARRAY_SIZE(a80_mmc_gates),
88+ .num_resets = ARRAY_SIZE(a80_mmc_resets),
11389 };
--- a/drivers/clk/sunxi/clk_a83t.c
+++ b/drivers/clk/sunxi/clk_a83t.c
@@ -72,28 +72,9 @@ static struct ccu_reset a83t_resets[] = {
7272 [RST_BUS_UART4] = RESET(0x2d8, BIT(20)),
7373 };
7474
75-static const struct ccu_desc a83t_ccu_desc = {
75+const struct ccu_desc a83t_ccu_desc = {
7676 .gates = a83t_gates,
7777 .resets = a83t_resets,
78-};
79-
80-static int a83t_clk_bind(struct udevice *dev)
81-{
82- return sunxi_reset_bind(dev, ARRAY_SIZE(a83t_resets));
83-}
84-
85-static const struct udevice_id a83t_clk_ids[] = {
86- { .compatible = "allwinner,sun8i-a83t-ccu",
87- .data = (ulong)&a83t_ccu_desc },
88- { }
89-};
90-
91-U_BOOT_DRIVER(clk_sun8i_a83t) = {
92- .name = "sun8i_a83t_ccu",
93- .id = UCLASS_CLK,
94- .of_match = a83t_clk_ids,
95- .priv_auto = sizeof(struct ccu_priv),
96- .ops = &sunxi_clk_ops,
97- .probe = sunxi_clk_probe,
98- .bind = a83t_clk_bind,
78+ .num_gates = ARRAY_SIZE(a83t_gates),
79+ .num_resets = ARRAY_SIZE(a83t_resets),
9980 };
--- a/drivers/clk/sunxi/clk_f1c100s.c
+++ b/drivers/clk/sunxi/clk_f1c100s.c
@@ -47,28 +47,9 @@ static struct ccu_reset f1c100s_resets[] = {
4747 [RST_BUS_UART2] = RESET(0x2d0, BIT(22)),
4848 };
4949
50-static const struct ccu_desc f1c100s_ccu_desc = {
50+const struct ccu_desc f1c100s_ccu_desc = {
5151 .gates = f1c100s_gates,
5252 .resets = f1c100s_resets,
53-};
54-
55-static int f1c100s_clk_bind(struct udevice *dev)
56-{
57- return sunxi_reset_bind(dev, ARRAY_SIZE(f1c100s_resets));
58-}
59-
60-static const struct udevice_id f1c100s_clk_ids[] = {
61- { .compatible = "allwinner,suniv-f1c100s-ccu",
62- .data = (ulong)&f1c100s_ccu_desc },
63- { }
64-};
65-
66-U_BOOT_DRIVER(clk_suniv_f1c100s) = {
67- .name = "suniv_f1c100s_ccu",
68- .id = UCLASS_CLK,
69- .of_match = f1c100s_clk_ids,
70- .priv_auto = sizeof(struct ccu_priv),
71- .ops = &sunxi_clk_ops,
72- .probe = sunxi_clk_probe,
73- .bind = f1c100s_clk_bind,
53+ .num_gates = ARRAY_SIZE(f1c100s_gates),
54+ .num_resets = ARRAY_SIZE(f1c100s_resets),
7455 };
--- a/drivers/clk/sunxi/clk_h3.c
+++ b/drivers/clk/sunxi/clk_h3.c
@@ -90,30 +90,9 @@ static struct ccu_reset h3_resets[] = {
9090 [RST_BUS_UART3] = RESET(0x2d8, BIT(19)),
9191 };
9292
93-static const struct ccu_desc h3_ccu_desc = {
93+const struct ccu_desc h3_ccu_desc = {
9494 .gates = h3_gates,
9595 .resets = h3_resets,
96-};
97-
98-static int h3_clk_bind(struct udevice *dev)
99-{
100- return sunxi_reset_bind(dev, ARRAY_SIZE(h3_resets));
101-}
102-
103-static const struct udevice_id h3_ccu_ids[] = {
104- { .compatible = "allwinner,sun8i-h3-ccu",
105- .data = (ulong)&h3_ccu_desc },
106- { .compatible = "allwinner,sun50i-h5-ccu",
107- .data = (ulong)&h3_ccu_desc },
108- { }
109-};
110-
111-U_BOOT_DRIVER(clk_sun8i_h3) = {
112- .name = "sun8i_h3_ccu",
113- .id = UCLASS_CLK,
114- .of_match = h3_ccu_ids,
115- .priv_auto = sizeof(struct ccu_priv),
116- .ops = &sunxi_clk_ops,
117- .probe = sunxi_clk_probe,
118- .bind = h3_clk_bind,
96+ .num_gates = ARRAY_SIZE(h3_gates),
97+ .num_resets = ARRAY_SIZE(h3_resets),
11998 };
--- a/drivers/clk/sunxi/clk_h6.c
+++ b/drivers/clk/sunxi/clk_h6.c
@@ -91,28 +91,9 @@ static struct ccu_reset h6_resets[] = {
9191 [RST_BUS_OTG] = RESET(0xa8c, BIT(24)),
9292 };
9393
94-static const struct ccu_desc h6_ccu_desc = {
94+const struct ccu_desc h6_ccu_desc = {
9595 .gates = h6_gates,
9696 .resets = h6_resets,
97-};
98-
99-static int h6_clk_bind(struct udevice *dev)
100-{
101- return sunxi_reset_bind(dev, ARRAY_SIZE(h6_resets));
102-}
103-
104-static const struct udevice_id h6_ccu_ids[] = {
105- { .compatible = "allwinner,sun50i-h6-ccu",
106- .data = (ulong)&h6_ccu_desc },
107- { }
108-};
109-
110-U_BOOT_DRIVER(clk_sun50i_h6) = {
111- .name = "sun50i_h6_ccu",
112- .id = UCLASS_CLK,
113- .of_match = h6_ccu_ids,
114- .priv_auto = sizeof(struct ccu_priv),
115- .ops = &sunxi_clk_ops,
116- .probe = sunxi_clk_probe,
117- .bind = h6_clk_bind,
97+ .num_gates = ARRAY_SIZE(h6_gates),
98+ .num_resets = ARRAY_SIZE(h6_resets),
11899 };
--- a/drivers/clk/sunxi/clk_h616.c
+++ b/drivers/clk/sunxi/clk_h616.c
@@ -109,28 +109,9 @@ static struct ccu_reset h616_resets[] = {
109109 [RST_BUS_OTG] = RESET(0xa8c, BIT(24)),
110110 };
111111
112-static const struct ccu_desc h616_ccu_desc = {
112+const struct ccu_desc h616_ccu_desc = {
113113 .gates = h616_gates,
114114 .resets = h616_resets,
115-};
116-
117-static int h616_clk_bind(struct udevice *dev)
118-{
119- return sunxi_reset_bind(dev, ARRAY_SIZE(h616_resets));
120-}
121-
122-static const struct udevice_id h616_ccu_ids[] = {
123- { .compatible = "allwinner,sun50i-h616-ccu",
124- .data = (ulong)&h616_ccu_desc },
125- { }
126-};
127-
128-U_BOOT_DRIVER(clk_sun50i_h616) = {
129- .name = "sun50i_h616_ccu",
130- .id = UCLASS_CLK,
131- .of_match = h616_ccu_ids,
132- .priv_auto = sizeof(struct ccu_priv),
133- .ops = &sunxi_clk_ops,
134- .probe = sunxi_clk_probe,
135- .bind = h616_clk_bind,
115+ .num_gates = ARRAY_SIZE(h616_gates),
116+ .num_resets = ARRAY_SIZE(h616_resets),
136117 };
--- a/drivers/clk/sunxi/clk_h6_r.c
+++ b/drivers/clk/sunxi/clk_h6_r.c
@@ -34,30 +34,9 @@ static struct ccu_reset h6_r_resets[] = {
3434 [RST_R_APB1_W1] = RESET(0x1ec, BIT(16)),
3535 };
3636
37-static const struct ccu_desc h6_r_ccu_desc = {
37+const struct ccu_desc h6_r_ccu_desc = {
3838 .gates = h6_r_gates,
3939 .resets = h6_r_resets,
40-};
41-
42-static int h6_r_clk_bind(struct udevice *dev)
43-{
44- return sunxi_reset_bind(dev, ARRAY_SIZE(h6_r_resets));
45-}
46-
47-static const struct udevice_id h6_r_clk_ids[] = {
48- { .compatible = "allwinner,sun50i-h6-r-ccu",
49- .data = (ulong)&h6_r_ccu_desc },
50- { .compatible = "allwinner,sun50i-h616-r-ccu",
51- .data = (ulong)&h6_r_ccu_desc },
52- { }
53-};
54-
55-U_BOOT_DRIVER(clk_sun50i_h6_r) = {
56- .name = "sun50i_h6_r_ccu",
57- .id = UCLASS_CLK,
58- .of_match = h6_r_clk_ids,
59- .priv_auto = sizeof(struct ccu_priv),
60- .ops = &sunxi_clk_ops,
61- .probe = sunxi_clk_probe,
62- .bind = h6_r_clk_bind,
40+ .num_gates = ARRAY_SIZE(h6_r_gates),
41+ .num_resets = ARRAY_SIZE(h6_r_resets),
6342 };
--- a/drivers/clk/sunxi/clk_r40.c
+++ b/drivers/clk/sunxi/clk_r40.c
@@ -99,28 +99,9 @@ static struct ccu_reset r40_resets[] = {
9999 [RST_BUS_UART7] = RESET(0x2d8, BIT(23)),
100100 };
101101
102-static const struct ccu_desc r40_ccu_desc = {
102+const struct ccu_desc r40_ccu_desc = {
103103 .gates = r40_gates,
104104 .resets = r40_resets,
105-};
106-
107-static int r40_clk_bind(struct udevice *dev)
108-{
109- return sunxi_reset_bind(dev, ARRAY_SIZE(r40_resets));
110-}
111-
112-static const struct udevice_id r40_clk_ids[] = {
113- { .compatible = "allwinner,sun8i-r40-ccu",
114- .data = (ulong)&r40_ccu_desc },
115- { }
116-};
117-
118-U_BOOT_DRIVER(clk_sun8i_r40) = {
119- .name = "sun8i_r40_ccu",
120- .id = UCLASS_CLK,
121- .of_match = r40_clk_ids,
122- .priv_auto = sizeof(struct ccu_priv),
123- .ops = &sunxi_clk_ops,
124- .probe = sunxi_clk_probe,
125- .bind = r40_clk_bind,
105+ .num_gates = ARRAY_SIZE(r40_gates),
106+ .num_resets = ARRAY_SIZE(r40_resets),
126107 };
--- a/drivers/clk/sunxi/clk_sunxi.c
+++ b/drivers/clk/sunxi/clk_sunxi.c
@@ -12,25 +12,31 @@
1212 #include <reset.h>
1313 #include <asm/io.h>
1414 #include <clk/sunxi.h>
15+#include <dm/device-internal.h>
1516 #include <linux/bitops.h>
1617 #include <linux/log2.h>
1718
18-static const struct ccu_clk_gate *priv_to_gate(struct ccu_priv *priv,
19+extern U_BOOT_DRIVER(sunxi_reset);
20+
21+static const struct ccu_clk_gate *plat_to_gate(struct ccu_plat *plat,
1922 unsigned long id)
2023 {
21- return &priv->desc->gates[id];
24+ if (id >= plat->desc->num_gates)
25+ return NULL;
26+
27+ return &plat->desc->gates[id];
2228 }
2329
2430 static int sunxi_set_gate(struct clk *clk, bool on)
2531 {
26- struct ccu_priv *priv = dev_get_priv(clk->dev);
27- const struct ccu_clk_gate *gate = priv_to_gate(priv, clk->id);
32+ struct ccu_plat *plat = dev_get_plat(clk->dev);
33+ const struct ccu_clk_gate *gate = plat_to_gate(plat, clk->id);
2834 u32 reg;
2935
30- if ((gate->flags & CCU_CLK_F_DUMMY_GATE))
36+ if (gate && (gate->flags & CCU_CLK_F_DUMMY_GATE))
3137 return 0;
3238
33- if (!(gate->flags & CCU_CLK_F_IS_VALID)) {
39+ if (!gate || !(gate->flags & CCU_CLK_F_IS_VALID)) {
3440 printf("%s: (CLK#%ld) unhandled\n", __func__, clk->id);
3541 return 0;
3642 }
@@ -38,13 +44,13 @@ static int sunxi_set_gate(struct clk *clk, bool on)
3844 debug("%s: (CLK#%ld) off#0x%x, BIT(%d)\n", __func__,
3945 clk->id, gate->off, ilog2(gate->bit));
4046
41- reg = readl(priv->base + gate->off);
47+ reg = readl(plat->base + gate->off);
4248 if (on)
4349 reg |= gate->bit;
4450 else
4551 reg &= ~gate->bit;
4652
47- writel(reg, priv->base + gate->off);
53+ writel(reg, plat->base + gate->off);
4854
4955 return 0;
5056 }
@@ -64,21 +70,19 @@ struct clk_ops sunxi_clk_ops = {
6470 .disable = sunxi_clk_disable,
6571 };
6672
67-int sunxi_clk_probe(struct udevice *dev)
73+static int sunxi_clk_bind(struct udevice *dev)
74+{
75+ /* Reuse the platform data for the reset driver. */
76+ return device_bind(dev, DM_DRIVER_REF(sunxi_reset), "reset",
77+ dev_get_plat(dev), dev_ofnode(dev), NULL);
78+}
79+
80+static int sunxi_clk_probe(struct udevice *dev)
6881 {
69- struct ccu_priv *priv = dev_get_priv(dev);
7082 struct clk_bulk clk_bulk;
7183 struct reset_ctl_bulk rst_bulk;
7284 int ret;
7385
74- priv->base = dev_read_addr_ptr(dev);
75- if (!priv->base)
76- return -ENOMEM;
77-
78- priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
79- if (!priv->desc)
80- return -EINVAL;
81-
8286 ret = clk_get_bulk(dev, &clk_bulk);
8387 if (!ret)
8488 clk_enable_bulk(&clk_bulk);
@@ -89,3 +93,138 @@ int sunxi_clk_probe(struct udevice *dev)
8993
9094 return 0;
9195 }
96+
97+static int sunxi_clk_of_to_plat(struct udevice *dev)
98+{
99+ struct ccu_plat *plat = dev_get_plat(dev);
100+
101+ plat->base = dev_read_addr_ptr(dev);
102+ if (!plat->base)
103+ return -ENOMEM;
104+
105+ plat->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
106+ if (!plat->desc)
107+ return -EINVAL;
108+
109+ return 0;
110+}
111+
112+extern const struct ccu_desc a10_ccu_desc;
113+extern const struct ccu_desc a10s_ccu_desc;
114+extern const struct ccu_desc a23_ccu_desc;
115+extern const struct ccu_desc a31_ccu_desc;
116+extern const struct ccu_desc a31_r_ccu_desc;
117+extern const struct ccu_desc a64_ccu_desc;
118+extern const struct ccu_desc a80_ccu_desc;
119+extern const struct ccu_desc a80_mmc_clk_desc;
120+extern const struct ccu_desc a83t_ccu_desc;
121+extern const struct ccu_desc f1c100s_ccu_desc;
122+extern const struct ccu_desc h3_ccu_desc;
123+extern const struct ccu_desc h6_ccu_desc;
124+extern const struct ccu_desc h616_ccu_desc;
125+extern const struct ccu_desc h6_r_ccu_desc;
126+extern const struct ccu_desc r40_ccu_desc;
127+extern const struct ccu_desc v3s_ccu_desc;
128+
129+static const struct udevice_id sunxi_clk_ids[] = {
130+#ifdef CONFIG_CLK_SUN4I_A10
131+ { .compatible = "allwinner,sun4i-a10-ccu",
132+ .data = (ulong)&a10_ccu_desc },
133+#endif
134+#ifdef CONFIG_CLK_SUN5I_A10S
135+ { .compatible = "allwinner,sun5i-a10s-ccu",
136+ .data = (ulong)&a10s_ccu_desc },
137+ { .compatible = "allwinner,sun5i-a13-ccu",
138+ .data = (ulong)&a10s_ccu_desc },
139+#endif
140+#ifdef CONFIG_CLK_SUN6I_A31
141+ { .compatible = "allwinner,sun6i-a31-ccu",
142+ .data = (ulong)&a31_ccu_desc },
143+#endif
144+#ifdef CONFIG_CLK_SUN4I_A10
145+ { .compatible = "allwinner,sun7i-a20-ccu",
146+ .data = (ulong)&a10_ccu_desc },
147+#endif
148+#ifdef CONFIG_CLK_SUN8I_A23
149+ { .compatible = "allwinner,sun8i-a23-ccu",
150+ .data = (ulong)&a23_ccu_desc },
151+ { .compatible = "allwinner,sun8i-a33-ccu",
152+ .data = (ulong)&a23_ccu_desc },
153+#endif
154+#ifdef CONFIG_CLK_SUN8I_A83T
155+ { .compatible = "allwinner,sun8i-a83t-ccu",
156+ .data = (ulong)&a83t_ccu_desc },
157+#endif
158+#ifdef CONFIG_CLK_SUN6I_A31_R
159+ { .compatible = "allwinner,sun8i-a83t-r-ccu",
160+ .data = (ulong)&a31_r_ccu_desc },
161+#endif
162+#ifdef CONFIG_CLK_SUN8I_H3
163+ { .compatible = "allwinner,sun8i-h3-ccu",
164+ .data = (ulong)&h3_ccu_desc },
165+#endif
166+#ifdef CONFIG_CLK_SUN6I_A31_R
167+ { .compatible = "allwinner,sun8i-h3-r-ccu",
168+ .data = (ulong)&a31_r_ccu_desc },
169+#endif
170+#ifdef CONFIG_CLK_SUN8I_R40
171+ { .compatible = "allwinner,sun8i-r40-ccu",
172+ .data = (ulong)&r40_ccu_desc },
173+#endif
174+#ifdef CONFIG_CLK_SUN8I_V3S
175+ { .compatible = "allwinner,sun8i-v3-ccu",
176+ .data = (ulong)&v3s_ccu_desc },
177+ { .compatible = "allwinner,sun8i-v3s-ccu",
178+ .data = (ulong)&v3s_ccu_desc },
179+#endif
180+#ifdef CONFIG_CLK_SUN9I_A80
181+ { .compatible = "allwinner,sun9i-a80-ccu",
182+ .data = (ulong)&a80_ccu_desc },
183+ { .compatible = "allwinner,sun9i-a80-mmc-config-clk",
184+ .data = (ulong)&a80_mmc_clk_desc },
185+#endif
186+#ifdef CONFIG_CLK_SUN50I_A64
187+ { .compatible = "allwinner,sun50i-a64-ccu",
188+ .data = (ulong)&a64_ccu_desc },
189+#endif
190+#ifdef CONFIG_CLK_SUN6I_A31_R
191+ { .compatible = "allwinner,sun50i-a64-r-ccu",
192+ .data = (ulong)&a31_r_ccu_desc },
193+#endif
194+#ifdef CONFIG_CLK_SUN8I_H3
195+ { .compatible = "allwinner,sun50i-h5-ccu",
196+ .data = (ulong)&h3_ccu_desc },
197+#endif
198+#ifdef CONFIG_CLK_SUN50I_H6
199+ { .compatible = "allwinner,sun50i-h6-ccu",
200+ .data = (ulong)&h6_ccu_desc },
201+#endif
202+#ifdef CONFIG_CLK_SUN50I_H6_R
203+ { .compatible = "allwinner,sun50i-h6-r-ccu",
204+ .data = (ulong)&h6_r_ccu_desc },
205+#endif
206+#ifdef CONFIG_CLK_SUN50I_H616
207+ { .compatible = "allwinner,sun50i-h616-ccu",
208+ .data = (ulong)&h616_ccu_desc },
209+#endif
210+#ifdef CONFIG_CLK_SUN50I_H6_R
211+ { .compatible = "allwinner,sun50i-h616-r-ccu",
212+ .data = (ulong)&h6_r_ccu_desc },
213+#endif
214+#ifdef CONFIG_CLK_SUNIV_F1C100S
215+ { .compatible = "allwinner,suniv-f1c100s-ccu",
216+ .data = (ulong)&f1c100s_ccu_desc },
217+#endif
218+ { }
219+};
220+
221+U_BOOT_DRIVER(sunxi_clk) = {
222+ .name = "sunxi_clk",
223+ .id = UCLASS_CLK,
224+ .of_match = sunxi_clk_ids,
225+ .bind = sunxi_clk_bind,
226+ .probe = sunxi_clk_probe,
227+ .of_to_plat = sunxi_clk_of_to_plat,
228+ .plat_auto = sizeof(struct ccu_plat),
229+ .ops = &sunxi_clk_ops,
230+};
--- a/drivers/clk/sunxi/clk_v3s.c
+++ b/drivers/clk/sunxi/clk_v3s.c
@@ -49,30 +49,9 @@ static struct ccu_reset v3s_resets[] = {
4949 [RST_BUS_UART2] = RESET(0x2d8, BIT(18)),
5050 };
5151
52-static const struct ccu_desc v3s_ccu_desc = {
52+const struct ccu_desc v3s_ccu_desc = {
5353 .gates = v3s_gates,
5454 .resets = v3s_resets,
55-};
56-
57-static int v3s_clk_bind(struct udevice *dev)
58-{
59- return sunxi_reset_bind(dev, ARRAY_SIZE(v3s_resets));
60-}
61-
62-static const struct udevice_id v3s_clk_ids[] = {
63- { .compatible = "allwinner,sun8i-v3s-ccu",
64- .data = (ulong)&v3s_ccu_desc },
65- { .compatible = "allwinner,sun8i-v3-ccu",
66- .data = (ulong)&v3s_ccu_desc },
67- { }
68-};
69-
70-U_BOOT_DRIVER(clk_sun8i_v3s) = {
71- .name = "sun8i_v3s_ccu",
72- .id = UCLASS_CLK,
73- .of_match = v3s_clk_ids,
74- .priv_auto = sizeof(struct ccu_priv),
75- .ops = &sunxi_clk_ops,
76- .probe = sunxi_clk_probe,
77- .bind = v3s_clk_bind,
55+ .num_gates = ARRAY_SIZE(v3s_gates),
56+ .num_resets = ARRAY_SIZE(v3s_resets),
7857 };
--- a/drivers/mtd/nand/raw/sunxi_nand_spl.c
+++ b/drivers/mtd/nand/raw/sunxi_nand_spl.c
@@ -208,7 +208,7 @@ static void nand_apply_config(const struct nfc_config *conf)
208208
209209 val = readl(SUNXI_NFC_BASE + NFC_CTL);
210210 val &= ~NFC_CTL_PAGE_SIZE_MASK;
211- writel(val | NFC_CTL_RAM_METHOD | NFC_CTL_PAGE_SIZE(conf->page_size),
211+ writel(val | NFC_CTL_PAGE_SIZE(conf->page_size),
212212 SUNXI_NFC_BASE + NFC_CTL);
213213 writel(conf->ecc_size, SUNXI_NFC_BASE + NFC_CNT);
214214 writel(conf->page_size, SUNXI_NFC_BASE + NFC_SPARE_AREA);
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -16,7 +16,6 @@
1616 #include <asm/global_data.h>
1717 #include <asm/gpio.h>
1818 #include <asm/io.h>
19-#include <asm/arch/clock.h>
2019 #include <common.h>
2120 #include <clk.h>
2221 #include <dm.h>
@@ -857,7 +856,7 @@ static int sun8i_emac_eth_of_to_plat(struct udevice *dev)
857856 priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1);
858857
859858 pdata->phy_interface = dev_read_phy_mode(dev);
860- printf("phy interface%d\n", pdata->phy_interface);
859+ debug("phy interface %d\n", pdata->phy_interface);
861860 if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
862861 return -EINVAL;
863862
--- a/drivers/phy/allwinner/Kconfig
+++ b/drivers/phy/allwinner/Kconfig
@@ -13,6 +13,16 @@ config PHY_SUN4I_USB
1313 This driver controls the entire USB PHY block, both the USB OTG
1414 parts, as well as the 2 regular USB 2 host PHYs.
1515
16+config INITIAL_USB_SCAN_DELAY
17+ int "Delay initial USB scan by x ms to allow builtin devices to init"
18+ depends on PHY_SUN4I_USB
19+ default 0
20+ help
21+ Some boards have on board usb devices which need longer than
22+ the USB spec's 1 second to connect from board powerup. Set
23+ this option to a nonzero value to add an extra delay before
24+ the first USB bus scan.
25+
1626 config PHY_SUN50I_USB3
1727 bool "Allwinner sun50i USB3 PHY driver"
1828 depends on ARCH_SUNXI
--- a/drivers/phy/allwinner/phy-sun4i-usb.c
+++ b/drivers/phy/allwinner/phy-sun4i-usb.c
@@ -20,8 +20,6 @@
2020 #include <reset.h>
2121 #include <asm/gpio.h>
2222 #include <asm/io.h>
23-#include <asm/arch/clock.h>
24-#include <asm/arch/cpu.h>
2523 #include <dm/device_compat.h>
2624 #include <linux/bitops.h>
2725 #include <linux/delay.h>
@@ -34,7 +32,8 @@
3432 #define REG_PHYTUNE 0x0c
3533 #define REG_PHYCTL_A33 0x10
3634 #define REG_PHY_OTGCTL 0x20
37-#define REG_PMU_UNK1 0x10
35+
36+#define REG_HCI_PHY_CTL 0x10
3837
3938 /* Common Control Bits for Both PHYs */
4039 #define PHY_PLL_BW 0x03
@@ -65,6 +64,7 @@
6564 /* A83T specific control bits for PHY0 */
6665 #define PHY_CTL_VBUSVLDEXT BIT(5)
6766 #define PHY_CTL_SIDDQ BIT(3)
67+#define PHY_CTL_H3_SIDDQ BIT(1)
6868
6969 /* A83T specific control bits for PHY2 HSIC */
7070 #define SUNXI_EHCI_HS_FORCE BIT(20)
@@ -89,9 +89,9 @@ struct sun4i_usb_phy_cfg {
8989 int num_phys;
9090 enum sun4i_usb_phy_type type;
9191 u32 disc_thresh;
92+ u32 hci_phy_ctl_clear;
9293 u8 phyctl_offset;
9394 bool dedicated_clocks;
94- bool enable_pmu_unk1;
9595 bool phy0_dual_route;
9696 int missing_phys;
9797 };
@@ -277,6 +277,12 @@ static int sun4i_usb_phy_init(struct phy *phy)
277277 return ret;
278278 }
279279
280+ if (usb_phy->pmu && data->cfg->hci_phy_ctl_clear) {
281+ val = readl(usb_phy->pmu + REG_HCI_PHY_CTL);
282+ val &= ~data->cfg->hci_phy_ctl_clear;
283+ writel(val, usb_phy->pmu + REG_HCI_PHY_CTL);
284+ }
285+
280286 if (data->cfg->type == sun8i_a83t_phy ||
281287 data->cfg->type == sun50i_h6_phy) {
282288 if (phy->id == 0) {
@@ -286,11 +292,6 @@ static int sun4i_usb_phy_init(struct phy *phy)
286292 writel(val, data->base + data->cfg->phyctl_offset);
287293 }
288294 } else {
289- if (usb_phy->pmu && data->cfg->enable_pmu_unk1) {
290- val = readl(usb_phy->pmu + REG_PMU_UNK1);
291- writel(val & ~2, usb_phy->pmu + REG_PMU_UNK1);
292- }
293-
294295 if (usb_phy->id == 0)
295296 sun4i_usb_phy_write(phy, PHY_RES45_CAL_EN,
296297 PHY_RES45_CAL_DATA,
@@ -530,7 +531,6 @@ static const struct sun4i_usb_phy_cfg sun4i_a10_cfg = {
530531 .disc_thresh = 3,
531532 .phyctl_offset = REG_PHYCTL_A10,
532533 .dedicated_clocks = false,
533- .enable_pmu_unk1 = false,
534534 };
535535
536536 static const struct sun4i_usb_phy_cfg sun5i_a13_cfg = {
@@ -539,7 +539,6 @@ static const struct sun4i_usb_phy_cfg sun5i_a13_cfg = {
539539 .disc_thresh = 2,
540540 .phyctl_offset = REG_PHYCTL_A10,
541541 .dedicated_clocks = false,
542- .enable_pmu_unk1 = false,
543542 };
544543
545544 static const struct sun4i_usb_phy_cfg sun6i_a31_cfg = {
@@ -548,7 +547,6 @@ static const struct sun4i_usb_phy_cfg sun6i_a31_cfg = {
548547 .disc_thresh = 3,
549548 .phyctl_offset = REG_PHYCTL_A10,
550549 .dedicated_clocks = true,
551- .enable_pmu_unk1 = false,
552550 };
553551
554552 static const struct sun4i_usb_phy_cfg sun7i_a20_cfg = {
@@ -557,7 +555,6 @@ static const struct sun4i_usb_phy_cfg sun7i_a20_cfg = {
557555 .disc_thresh = 2,
558556 .phyctl_offset = REG_PHYCTL_A10,
559557 .dedicated_clocks = false,
560- .enable_pmu_unk1 = false,
561558 };
562559
563560 static const struct sun4i_usb_phy_cfg sun8i_a23_cfg = {
@@ -566,7 +563,6 @@ static const struct sun4i_usb_phy_cfg sun8i_a23_cfg = {
566563 .disc_thresh = 3,
567564 .phyctl_offset = REG_PHYCTL_A10,
568565 .dedicated_clocks = true,
569- .enable_pmu_unk1 = false,
570566 };
571567
572568 static const struct sun4i_usb_phy_cfg sun8i_a33_cfg = {
@@ -575,7 +571,6 @@ static const struct sun4i_usb_phy_cfg sun8i_a33_cfg = {
575571 .disc_thresh = 3,
576572 .phyctl_offset = REG_PHYCTL_A33,
577573 .dedicated_clocks = true,
578- .enable_pmu_unk1 = false,
579574 };
580575
581576 static const struct sun4i_usb_phy_cfg sun8i_a83t_cfg = {
@@ -591,7 +586,7 @@ static const struct sun4i_usb_phy_cfg sun8i_h3_cfg = {
591586 .disc_thresh = 3,
592587 .phyctl_offset = REG_PHYCTL_A33,
593588 .dedicated_clocks = true,
594- .enable_pmu_unk1 = true,
589+ .hci_phy_ctl_clear = PHY_CTL_H3_SIDDQ,
595590 .phy0_dual_route = true,
596591 };
597592
@@ -601,7 +596,7 @@ static const struct sun4i_usb_phy_cfg sun8i_r40_cfg = {
601596 .disc_thresh = 3,
602597 .phyctl_offset = REG_PHYCTL_A33,
603598 .dedicated_clocks = true,
604- .enable_pmu_unk1 = true,
599+ .hci_phy_ctl_clear = PHY_CTL_H3_SIDDQ,
605600 .phy0_dual_route = true,
606601 };
607602
@@ -611,7 +606,16 @@ static const struct sun4i_usb_phy_cfg sun8i_v3s_cfg = {
611606 .disc_thresh = 3,
612607 .phyctl_offset = REG_PHYCTL_A33,
613608 .dedicated_clocks = true,
614- .enable_pmu_unk1 = true,
609+ .hci_phy_ctl_clear = PHY_CTL_H3_SIDDQ,
610+ .phy0_dual_route = true,
611+};
612+
613+static const struct sun4i_usb_phy_cfg sun20i_d1_cfg = {
614+ .num_phys = 2,
615+ .type = sun50i_h6_phy,
616+ .phyctl_offset = REG_PHYCTL_A33,
617+ .dedicated_clocks = true,
618+ .hci_phy_ctl_clear = PHY_CTL_SIDDQ,
615619 .phy0_dual_route = true,
616620 };
617621
@@ -621,7 +625,7 @@ static const struct sun4i_usb_phy_cfg sun50i_a64_cfg = {
621625 .disc_thresh = 3,
622626 .phyctl_offset = REG_PHYCTL_A33,
623627 .dedicated_clocks = true,
624- .enable_pmu_unk1 = true,
628+ .hci_phy_ctl_clear = PHY_CTL_H3_SIDDQ,
625629 .phy0_dual_route = true,
626630 };
627631
@@ -631,7 +635,6 @@ static const struct sun4i_usb_phy_cfg sun50i_h6_cfg = {
631635 .disc_thresh = 3,
632636 .phyctl_offset = REG_PHYCTL_A33,
633637 .dedicated_clocks = true,
634- .enable_pmu_unk1 = true,
635638 .phy0_dual_route = true,
636639 .missing_phys = BIT(1) | BIT(2),
637640 };
@@ -647,6 +650,7 @@ static const struct udevice_id sun4i_usb_phy_ids[] = {
647650 { .compatible = "allwinner,sun8i-h3-usb-phy", .data = (ulong)&sun8i_h3_cfg },
648651 { .compatible = "allwinner,sun8i-r40-usb-phy", .data = (ulong)&sun8i_r40_cfg },
649652 { .compatible = "allwinner,sun8i-v3s-usb-phy", .data = (ulong)&sun8i_v3s_cfg },
653+ { .compatible = "allwinner,sun20i-d1-usb-phy", .data = (ulong)&sun20i_d1_cfg },
650654 { .compatible = "allwinner,sun50i-a64-usb-phy", .data = (ulong)&sun50i_a64_cfg},
651655 { .compatible = "allwinner,sun50i-h6-usb-phy", .data = (ulong)&sun50i_h6_cfg},
652656 { }
--- a/drivers/reset/reset-sunxi.c
+++ b/drivers/reset/reset-sunxi.c
@@ -12,30 +12,22 @@
1212 #include <reset-uclass.h>
1313 #include <asm/io.h>
1414 #include <clk/sunxi.h>
15-#include <dm/device-internal.h>
16-#include <dm/lists.h>
1715 #include <linux/bitops.h>
1816 #include <linux/log2.h>
1917
20-struct sunxi_reset_priv {
21- void *base;
22- ulong count;
23- const struct ccu_desc *desc;
24-};
25-
26-static const struct ccu_reset *priv_to_reset(struct sunxi_reset_priv *priv,
18+static const struct ccu_reset *plat_to_reset(struct ccu_plat *plat,
2719 unsigned long id)
2820 {
29- return &priv->desc->resets[id];
21+ return &plat->desc->resets[id];
3022 }
3123
3224 static int sunxi_reset_request(struct reset_ctl *reset_ctl)
3325 {
34- struct sunxi_reset_priv *priv = dev_get_priv(reset_ctl->dev);
26+ struct ccu_plat *plat = dev_get_plat(reset_ctl->dev);
3527
3628 debug("%s: (RST#%ld)\n", __func__, reset_ctl->id);
3729
38- if (reset_ctl->id >= priv->count)
30+ if (reset_ctl->id >= plat->desc->num_resets)
3931 return -EINVAL;
4032
4133 return 0;
@@ -43,8 +35,8 @@ static int sunxi_reset_request(struct reset_ctl *reset_ctl)
4335
4436 static int sunxi_set_reset(struct reset_ctl *reset_ctl, bool on)
4537 {
46- struct sunxi_reset_priv *priv = dev_get_priv(reset_ctl->dev);
47- const struct ccu_reset *reset = priv_to_reset(priv, reset_ctl->id);
38+ struct ccu_plat *plat = dev_get_plat(reset_ctl->dev);
39+ const struct ccu_reset *reset = plat_to_reset(plat, reset_ctl->id);
4840 u32 reg;
4941
5042 if (!(reset->flags & CCU_RST_F_IS_VALID)) {
@@ -55,13 +47,13 @@ static int sunxi_set_reset(struct reset_ctl *reset_ctl, bool on)
5547 debug("%s: (RST#%ld) off#0x%x, BIT(%d)\n", __func__,
5648 reset_ctl->id, reset->off, ilog2(reset->bit));
5749
58- reg = readl(priv->base + reset->off);
50+ reg = readl(plat->base + reset->off);
5951 if (on)
6052 reg |= reset->bit;
6153 else
6254 reg &= ~reset->bit;
6355
64- writel(reg, priv->base + reset->off);
56+ writel(reg, plat->base + reset->off);
6557
6658 return 0;
6759 }
@@ -82,39 +74,8 @@ struct reset_ops sunxi_reset_ops = {
8274 .rst_deassert = sunxi_reset_deassert,
8375 };
8476
85-static int sunxi_reset_probe(struct udevice *dev)
86-{
87- struct sunxi_reset_priv *priv = dev_get_priv(dev);
88-
89- priv->base = dev_read_addr_ptr(dev);
90-
91- return 0;
92-}
93-
94-int sunxi_reset_bind(struct udevice *dev, ulong count)
95-{
96- struct udevice *rst_dev;
97- struct sunxi_reset_priv *priv;
98- int ret;
99-
100- ret = device_bind_driver_to_node(dev, "sunxi_reset", "reset",
101- dev_ofnode(dev), &rst_dev);
102- if (ret) {
103- debug("failed to bind sunxi_reset driver (ret=%d)\n", ret);
104- return ret;
105- }
106- priv = malloc(sizeof(struct sunxi_reset_priv));
107- priv->count = count;
108- priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
109- dev_set_priv(rst_dev, priv);
110-
111- return 0;
112-}
113-
11477 U_BOOT_DRIVER(sunxi_reset) = {
11578 .name = "sunxi_reset",
11679 .id = UCLASS_RESET,
11780 .ops = &sunxi_reset_ops,
118- .probe = sunxi_reset_probe,
119- .priv_auto = sizeof(struct sunxi_reset_priv),
12081 };
--- a/drivers/spi/spi-sunxi.c
+++ b/drivers/spi/spi-sunxi.c
@@ -72,10 +72,18 @@ DECLARE_GLOBAL_DATA_PTR;
7272 #define SUN4I_XMIT_CNT(cnt) ((cnt) & SUN4I_MAX_XFER_SIZE)
7373 #define SUN4I_FIFO_STA_RF_CNT_BITS 0
7474
75-#define SUN4I_SPI_MAX_RATE 24000000
75+#ifdef CONFIG_MACH_SUNIV
76+/* the AHB clock, which we programmed to be 1/3 of PLL_PERIPH@600MHz */
77+#define SUNXI_INPUT_CLOCK 200000000 /* 200 MHz */
78+#define SUN4I_SPI_MAX_RATE (SUNXI_INPUT_CLOCK / 2)
79+#else
80+/* the SPI mod clock, defaulting to be 1/1 of the HOSC@24MHz */
81+#define SUNXI_INPUT_CLOCK 24000000 /* 24 MHz */
82+#define SUN4I_SPI_MAX_RATE SUNXI_INPUT_CLOCK
83+#endif
7684 #define SUN4I_SPI_MIN_RATE 3000
7785 #define SUN4I_SPI_DEFAULT_RATE 1000000
78-#define SUN4I_SPI_TIMEOUT_US 1000000
86+#define SUN4I_SPI_TIMEOUT_MS 1000
7987
8088 #define SPI_REG(priv, reg) ((priv)->base + \
8189 (priv)->variant->regs[reg])
@@ -221,6 +229,60 @@ err_ahb:
221229 return ret;
222230 }
223231
232+static void sun4i_spi_set_speed_mode(struct udevice *dev)
233+{
234+ struct sun4i_spi_priv *priv = dev_get_priv(dev);
235+ unsigned int div;
236+ u32 reg;
237+
238+ /*
239+ * Setup clock divider.
240+ *
241+ * We have two choices there. Either we can use the clock
242+ * divide rate 1, which is calculated thanks to this formula:
243+ * SPI_CLK = MOD_CLK / (2 ^ (cdr + 1))
244+ * Or we can use CDR2, which is calculated with the formula:
245+ * SPI_CLK = MOD_CLK / (2 * (cdr + 1))
246+ * Whether we use the former or the latter is set through the
247+ * DRS bit.
248+ *
249+ * First try CDR2, and if we can't reach the expected
250+ * frequency, fall back to CDR1.
251+ */
252+
253+ div = DIV_ROUND_UP(SUNXI_INPUT_CLOCK, priv->freq);
254+ reg = readl(SPI_REG(priv, SPI_CCR));
255+
256+ if ((div / 2) <= (SUN4I_CLK_CTL_CDR2_MASK + 1)) {
257+ div /= 2;
258+ if (div > 0)
259+ div--;
260+
261+ reg &= ~(SUN4I_CLK_CTL_CDR2_MASK | SUN4I_CLK_CTL_DRS);
262+ reg |= SUN4I_CLK_CTL_CDR2(div) | SUN4I_CLK_CTL_DRS;
263+ } else {
264+ div = fls(div - 1);
265+ /* The F1C100s encodes the divider as 2^(n+1) */
266+ if (IS_ENABLED(CONFIG_MACH_SUNIV))
267+ div--;
268+ reg &= ~((SUN4I_CLK_CTL_CDR1_MASK << 8) | SUN4I_CLK_CTL_DRS);
269+ reg |= SUN4I_CLK_CTL_CDR1(div);
270+ }
271+
272+ writel(reg, SPI_REG(priv, SPI_CCR));
273+
274+ reg = readl(SPI_REG(priv, SPI_TCR));
275+ reg &= ~(SPI_BIT(priv, SPI_TCR_CPOL) | SPI_BIT(priv, SPI_TCR_CPHA));
276+
277+ if (priv->mode & SPI_CPOL)
278+ reg |= SPI_BIT(priv, SPI_TCR_CPOL);
279+
280+ if (priv->mode & SPI_CPHA)
281+ reg |= SPI_BIT(priv, SPI_TCR_CPHA);
282+
283+ writel(reg, SPI_REG(priv, SPI_TCR));
284+}
285+
224286 static int sun4i_spi_claim_bus(struct udevice *dev)
225287 {
226288 struct sun4i_spi_priv *priv = dev_get_priv(dev->parent);
@@ -240,6 +302,8 @@ static int sun4i_spi_claim_bus(struct udevice *dev)
240302 setbits_le32(SPI_REG(priv, SPI_TCR), SPI_BIT(priv, SPI_TCR_CS_MANUAL) |
241303 SPI_BIT(priv, SPI_TCR_CS_ACTIVE_LOW));
242304
305+ sun4i_spi_set_speed_mode(dev->parent);
306+
243307 return 0;
244308 }
245309
@@ -262,7 +326,6 @@ static int sun4i_spi_xfer(struct udevice *dev, unsigned int bitlen,
262326 struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev);
263327
264328 u32 len = bitlen / 8;
265- u32 rx_fifocnt;
266329 u8 nbytes;
267330 int ret;
268331
@@ -300,13 +363,10 @@ static int sun4i_spi_xfer(struct udevice *dev, unsigned int bitlen,
300363 setbits_le32(SPI_REG(priv, SPI_TCR),
301364 SPI_BIT(priv, SPI_TCR_XCH));
302365
303- /* Wait till RX FIFO to be empty */
304- ret = readl_poll_timeout(SPI_REG(priv, SPI_FSR),
305- rx_fifocnt,
306- (((rx_fifocnt &
307- SPI_BIT(priv, SPI_FSR_RF_CNT_MASK)) >>
308- SUN4I_FIFO_STA_RF_CNT_BITS) >= nbytes),
309- SUN4I_SPI_TIMEOUT_US);
366+ /* Wait for the transfer to be done */
367+ ret = wait_for_bit_le32((const void *)SPI_REG(priv, SPI_TCR),
368+ SPI_BIT(priv, SPI_TCR_XCH),
369+ false, SUN4I_SPI_TIMEOUT_MS, false);
310370 if (ret < 0) {
311371 printf("ERROR: sun4i_spi: Timeout transferring data\n");
312372 sun4i_spi_set_cs(bus, slave_plat->cs, false);
@@ -329,46 +389,14 @@ static int sun4i_spi_set_speed(struct udevice *dev, uint speed)
329389 {
330390 struct sun4i_spi_plat *plat = dev_get_plat(dev);
331391 struct sun4i_spi_priv *priv = dev_get_priv(dev);
332- unsigned int div;
333- u32 reg;
334392
335393 if (speed > plat->max_hz)
336394 speed = plat->max_hz;
337395
338396 if (speed < SUN4I_SPI_MIN_RATE)
339397 speed = SUN4I_SPI_MIN_RATE;
340- /*
341- * Setup clock divider.
342- *
343- * We have two choices there. Either we can use the clock
344- * divide rate 1, which is calculated thanks to this formula:
345- * SPI_CLK = MOD_CLK / (2 ^ (cdr + 1))
346- * Or we can use CDR2, which is calculated with the formula:
347- * SPI_CLK = MOD_CLK / (2 * (cdr + 1))
348- * Whether we use the former or the latter is set through the
349- * DRS bit.
350- *
351- * First try CDR2, and if we can't reach the expected
352- * frequency, fall back to CDR1.
353- */
354-
355- div = SUN4I_SPI_MAX_RATE / (2 * speed);
356- reg = readl(SPI_REG(priv, SPI_CCR));
357-
358- if (div <= (SUN4I_CLK_CTL_CDR2_MASK + 1)) {
359- if (div > 0)
360- div--;
361-
362- reg &= ~(SUN4I_CLK_CTL_CDR2_MASK | SUN4I_CLK_CTL_DRS);
363- reg |= SUN4I_CLK_CTL_CDR2(div) | SUN4I_CLK_CTL_DRS;
364- } else {
365- div = __ilog2(SUN4I_SPI_MAX_RATE) - __ilog2(speed);
366- reg &= ~((SUN4I_CLK_CTL_CDR1_MASK << 8) | SUN4I_CLK_CTL_DRS);
367- reg |= SUN4I_CLK_CTL_CDR1(div);
368- }
369398
370399 priv->freq = speed;
371- writel(reg, SPI_REG(priv, SPI_CCR));
372400
373401 return 0;
374402 }
@@ -376,19 +404,8 @@ static int sun4i_spi_set_speed(struct udevice *dev, uint speed)
376404 static int sun4i_spi_set_mode(struct udevice *dev, uint mode)
377405 {
378406 struct sun4i_spi_priv *priv = dev_get_priv(dev);
379- u32 reg;
380-
381- reg = readl(SPI_REG(priv, SPI_TCR));
382- reg &= ~(SPI_BIT(priv, SPI_TCR_CPOL) | SPI_BIT(priv, SPI_TCR_CPHA));
383-
384- if (mode & SPI_CPOL)
385- reg |= SPI_BIT(priv, SPI_TCR_CPOL);
386-
387- if (mode & SPI_CPHA)
388- reg |= SPI_BIT(priv, SPI_TCR_CPHA);
389407
390408 priv->mode = mode;
391- writel(reg, SPI_REG(priv, SPI_TCR));
392409
393410 return 0;
394411 }
--- a/include/clk/sunxi.h
+++ b/include/clk/sunxi.h
@@ -70,34 +70,21 @@ struct ccu_reset {
7070 struct ccu_desc {
7171 const struct ccu_clk_gate *gates;
7272 const struct ccu_reset *resets;
73+ u8 num_gates;
74+ u8 num_resets;
7375 };
7476
7577 /**
76- * struct ccu_priv - sunxi clock control unit
78+ * struct ccu_plat - sunxi clock control unit platform data
7779 *
7880 * @base: base address
7981 * @desc: ccu descriptor
8082 */
81-struct ccu_priv {
83+struct ccu_plat {
8284 void *base;
8385 const struct ccu_desc *desc;
8486 };
8587
86-/**
87- * sunxi_clk_probe - common sunxi clock probe
88- * @dev: clock device
89- */
90-int sunxi_clk_probe(struct udevice *dev);
91-
9288 extern struct clk_ops sunxi_clk_ops;
9389
94-/**
95- * sunxi_reset_bind() - reset binding
96- *
97- * @dev: reset device
98- * @count: reset count
99- * Return: 0 success, or error value
100- */
101-int sunxi_reset_bind(struct udevice *dev, ulong count);
102-
10390 #endif /* _CLK_SUNXI_H */
--- a/include/configs/sun4i.h
+++ b/include/configs/sun4i.h
@@ -2,18 +2,12 @@
22 /*
33 * (C) Copyright 2012-2013 Henrik Nordstrom <henrik@henriknordstrom.net>
44 *
5- * Configuration settings for the Allwinner A10 (sun4i) CPU
5+ * Placeholder wrapper to allow addressing Allwinner A10 (sun4i) CPU
6+ * based devices separately. Please do not add anything in here.
67 */
78 #ifndef __CONFIG_H
89 #define __CONFIG_H
910
10-/*
11- * A10 specific configuration
12- */
13-
14-/*
15- * Include common sunxi configuration where most the settings are
16- */
1711 #include <configs/sunxi-common.h>
1812
1913 #endif /* __CONFIG_H */
--- a/include/configs/sun50i.h
+++ b/include/configs/sun50i.h
@@ -1,26 +1,11 @@
11 /* SPDX-License-Identifier: GPL-2.0+ */
22 /*
3- * Configuration settings for the Allwinner A64 (sun50i) CPU
3+ * Placeholder wrapper to allow addressing Allwinner A64 (and later) sun50i
4+ * CPU based devices separately. Please do not add anything in here.
45 */
5-
66 #ifndef __CONFIG_H
77 #define __CONFIG_H
88
9-/*
10- * A64 specific configuration
11- */
12-
13-#ifndef CONFIG_SUN50I_GEN_H6
14-#define GICD_BASE 0x1c81000
15-#define GICC_BASE 0x1c82000
16-#else
17-#define GICD_BASE 0x3021000
18-#define GICC_BASE 0x3022000
19-#endif
20-
21-/*
22- * Include common sunxi configuration where most the settings are
23- */
249 #include <configs/sunxi-common.h>
2510
2611 #endif /* __CONFIG_H */
--- a/include/configs/sun5i.h
+++ b/include/configs/sun5i.h
@@ -2,18 +2,12 @@
22 /*
33 * (C) Copyright 2012-2013 Henrik Nordstrom <henrik@henriknordstrom.net>
44 *
5- * Configuration settings for the Allwinner A13 (sun5i) CPU
5+ * Placeholder wrapper to allow addressing Allwinner A13 (sun5i) CPU
6+ * based devices separately. Please do not add anything in here.
67 */
78 #ifndef __CONFIG_H
89 #define __CONFIG_H
910
10-/*
11- * High Level Configuration Options
12- */
13-
14-/*
15- * Include common sunxi configuration where most the settings are
16- */
1711 #include <configs/sunxi-common.h>
1812
1913 #endif /* __CONFIG_H */
--- a/include/configs/sun6i.h
+++ b/include/configs/sun6i.h
@@ -4,15 +4,12 @@
44 * (C) Copyright 2013 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
55 * (C) Copyright 2013 Maxime Ripard <maxime.ripard@free-electrons.com>
66 *
7- * Configuration settings for the Allwinner A31 (sun6i) CPU
7+ * Placeholder wrapper to allow addressing Allwinner A31 (sun6i) CPU
8+ * based devices separately. Please do not add anything in here.
89 */
9-
1010 #ifndef __CONFIG_H
1111 #define __CONFIG_H
1212
13-/*
14- * Include common sunxi configuration where most the settings are
15- */
1613 #include <configs/sunxi-common.h>
1714
1815 #endif /* __CONFIG_H */
--- a/include/configs/sun7i.h
+++ b/include/configs/sun7i.h
@@ -3,14 +3,12 @@
33 * (C) Copyright 2012-2013 Henrik Nordstrom <henrik@henriknordstrom.net>
44 * (C) Copyright 2013 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
55 *
6- * Configuration settings for the Allwinner A20 (sun7i) CPU
6+ * Placeholder wrapper to allow addressing Allwinner A20 (sun7i) CPU
7+ * based devices separately. Please do not add anything in here.
78 */
89 #ifndef __CONFIG_H
910 #define __CONFIG_H
1011
11-/*
12- * Include common sunxi configuration where most the settings are
13- */
1412 #include <configs/sunxi-common.h>
1513
1614 #endif /* __CONFIG_H */
--- a/include/configs/sun8i.h
+++ b/include/configs/sun8i.h
@@ -2,21 +2,12 @@
22 /*
33 * (C) Copyright 2014 Chen-Yu Tsai <wens@csie.org>
44 *
5- * Configuration settings for the Allwinner A23 (sun8i) CPU
5+ * Placeholder wrapper to allow addressing Allwinner A23 (and later) sun8i
6+ * CPU based devices separately. Please do not add anything in here.
67 */
7-
88 #ifndef __CONFIG_H
99 #define __CONFIG_H
1010
11-/*
12- * A23 specific configuration
13- */
14-
15-#include <asm/arch/cpu.h>
16-
17-/*
18- * Include common sunxi configuration where most the settings are
19- */
2011 #include <configs/sunxi-common.h>
2112
2213 #endif /* __CONFIG_H */
--- a/include/configs/sun9i.h
+++ b/include/configs/sun9i.h
@@ -2,19 +2,12 @@
22 /*
33 * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
44 *
5- * Configuration settings for the Allwinner A80 (sun9i) CPU
5+ * Placeholder wrapper to allow addressing Allwinner A80 (sun9i) CPU
6+ * based devices separately. Please do not add anything in here.
67 */
7-
88 #ifndef __CONFIG_H
99 #define __CONFIG_H
1010
11-/*
12- * A80 specific configuration
13- */
14-
15-/*
16- * Include common sunxi configuration where most the settings are
17- */
1811 #include <configs/sunxi-common.h>
1912
2013 #endif /* __CONFIG_H */
--- a/include/configs/suniv.h
+++ b/include/configs/suniv.h
@@ -1,14 +1,11 @@
11 /* SPDX-License-Identifier: GPL-2.0+ */
22 /*
3- * Configuration settings for new Allwinner F-series (suniv) CPU
3+ * Placeholder wrapper to allow addressing Allwinner F-series (suniv) CPU
4+ * based devices separately. Please do not add anything in here.
45 */
5-
66 #ifndef __CONFIG_H
77 #define __CONFIG_H
88
9-/*
10- * Include common sunxi configuration where most the settings are
11- */
129 #include <configs/sunxi-common.h>
1310
1411 #endif /* __CONFIG_H */