svn commit: r305436 - in stable/11/sys: arm/allwinner arm/allwinner/a13 arm/allwinner/clk arm/conf conf
Emmanuel Vadot
manu at FreeBSD.org
Mon Sep 5 20:17:21 UTC 2016
Author: manu
Date: Mon Sep 5 20:17:18 2016
New Revision: 305436
URL: https://svnweb.freebsd.org/changeset/base/305436
Log:
MFC r302472
Add support for Allwinner A13.
Reviewed by: jmcneill
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D6809
Added:
stable/11/sys/arm/allwinner/a13/
- copied from r302472, head/sys/arm/allwinner/a13/
Modified:
stable/11/sys/arm/allwinner/a10_codec.c
stable/11/sys/arm/allwinner/a10_ehci.c
stable/11/sys/arm/allwinner/a10_gpio.c
stable/11/sys/arm/allwinner/allwinner_machdep.c
stable/11/sys/arm/allwinner/aw_ccu.c
stable/11/sys/arm/allwinner/clk/aw_gate.c
stable/11/sys/arm/allwinner/clk/aw_pll.c
stable/11/sys/arm/allwinner/clk/aw_usbclk.c
stable/11/sys/arm/allwinner/std.a10
stable/11/sys/arm/conf/A10
stable/11/sys/conf/options.arm
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/arm/allwinner/a10_codec.c
==============================================================================
--- stable/11/sys/arm/allwinner/a10_codec.c Mon Sep 5 20:07:03 2016 (r305435)
+++ stable/11/sys/arm/allwinner/a10_codec.c Mon Sep 5 20:17:18 2016 (r305436)
@@ -720,13 +720,19 @@ CHANNEL_DECLARE(a10codec_chan);
* Device interface
*/
+static struct ofw_compat_data compat_data[] = {
+ {"allwinner,sun4i-a10-codec", 1},
+ {"allwinner,sun7i-a20-codec", 1},
+ {NULL, 0},
+};
+
static int
a10codec_probe(device_t dev)
{
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (!ofw_bus_is_compatible(dev, "allwinner,sun7i-a20-codec"))
+ if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
return (ENXIO);
device_set_desc(dev, "Allwinner Audio Codec");
Modified: stable/11/sys/arm/allwinner/a10_ehci.c
==============================================================================
--- stable/11/sys/arm/allwinner/a10_ehci.c Mon Sep 5 20:07:03 2016 (r305435)
+++ stable/11/sys/arm/allwinner/a10_ehci.c Mon Sep 5 20:17:18 2016 (r305436)
@@ -112,6 +112,7 @@ static const struct aw_ehci_conf a31_ehc
static struct ofw_compat_data compat_data[] = {
{ "allwinner,sun4i-a10-ehci", (uintptr_t)&a10_ehci_conf },
+ { "allwinner,sun5i-a13-ehci", (uintptr_t)&a10_ehci_conf },
{ "allwinner,sun6i-a31-ehci", (uintptr_t)&a31_ehci_conf },
{ "allwinner,sun7i-a20-ehci", (uintptr_t)&a10_ehci_conf },
{ "allwinner,sun8i-a83t-ehci", (uintptr_t)&a31_ehci_conf },
Modified: stable/11/sys/arm/allwinner/a10_gpio.c
==============================================================================
--- stable/11/sys/arm/allwinner/a10_gpio.c Mon Sep 5 20:07:03 2016 (r305435)
+++ stable/11/sys/arm/allwinner/a10_gpio.c Mon Sep 5 20:17:18 2016 (r305436)
@@ -80,6 +80,11 @@ __FBSDID("$FreeBSD$");
extern const struct allwinner_padconf a10_padconf;
#endif
+/* Defined in a13_padconf.c */
+#ifdef SOC_ALLWINNER_A13
+extern const struct allwinner_padconf a13_padconf;
+#endif
+
/* Defined in a20_padconf.c */
#ifdef SOC_ALLWINNER_A20
extern const struct allwinner_padconf a20_padconf;
@@ -115,6 +120,9 @@ static struct ofw_compat_data compat_dat
#ifdef SOC_ALLWINNER_A10
{"allwinner,sun4i-a10-pinctrl", (uintptr_t)&a10_padconf},
#endif
+#ifdef SOC_ALLWINNER_A13
+ {"allwinner,sun5i-a13-pinctrl", (uintptr_t)&a13_padconf},
+#endif
#ifdef SOC_ALLWINNER_A20
{"allwinner,sun7i-a20-pinctrl", (uintptr_t)&a20_padconf},
#endif
Modified: stable/11/sys/arm/allwinner/allwinner_machdep.c
==============================================================================
--- stable/11/sys/arm/allwinner/allwinner_machdep.c Mon Sep 5 20:07:03 2016 (r305435)
+++ stable/11/sys/arm/allwinner/allwinner_machdep.c Mon Sep 5 20:17:18 2016 (r305436)
@@ -68,6 +68,14 @@ a10_attach(platform_t plat)
}
static int
+a13_attach(platform_t plat)
+{
+ soc_type = ALLWINNERSOC_A13;
+ soc_family = ALLWINNERSOC_SUN5I;
+ return (0);
+}
+
+static int
a20_attach(platform_t plat)
{
soc_type = ALLWINNERSOC_A20;
@@ -169,6 +177,17 @@ static platform_method_t a10_methods[] =
FDT_PLATFORM_DEF(a10, "a10", 0, "allwinner,sun4i-a10", 200);
#endif
+#if defined(SOC_ALLWINNER_A13)
+static platform_method_t a13_methods[] = {
+ PLATFORMMETHOD(platform_attach, a13_attach),
+ PLATFORMMETHOD(platform_lastaddr, allwinner_lastaddr),
+ PLATFORMMETHOD(platform_devmap_init, allwinner_devmap_init),
+
+ PLATFORMMETHOD_END,
+};
+FDT_PLATFORM_DEF(a13, "a13", 0, "allwinner,sun5i-a13", 200);
+#endif
+
#if defined(SOC_ALLWINNER_A20)
static platform_method_t a20_methods[] = {
PLATFORMMETHOD(platform_attach, a20_attach),
Modified: stable/11/sys/arm/allwinner/aw_ccu.c
==============================================================================
--- stable/11/sys/arm/allwinner/aw_ccu.c Mon Sep 5 20:07:03 2016 (r305435)
+++ stable/11/sys/arm/allwinner/aw_ccu.c Mon Sep 5 20:17:18 2016 (r305436)
@@ -76,6 +76,7 @@ struct aw_ccu_softc {
static struct ofw_compat_data compat_data[] = {
{ "allwinner,sun4i-a10", CLOCK_CCU },
+ { "allwinner,sun5i-a13", CLOCK_CCU },
{ "allwinner,sun7i-a20", CLOCK_CCU },
{ "allwinner,sun6i-a31", CLOCK_CCU },
{ "allwinner,sun6i-a31s", CLOCK_CCU },
Modified: stable/11/sys/arm/allwinner/clk/aw_gate.c
==============================================================================
--- stable/11/sys/arm/allwinner/clk/aw_gate.c Mon Sep 5 20:07:03 2016 (r305435)
+++ stable/11/sys/arm/allwinner/clk/aw_gate.c Mon Sep 5 20:17:18 2016 (r305436)
@@ -60,6 +60,13 @@ static struct ofw_compat_data compat_dat
{ "allwinner,sun4i-a10-apb1-gates-clk",
(uintptr_t)"Allwinner APB1 Clock Gates" },
+ { "allwinner,sun5i-a13-ahb-gates-clk",
+ (uintptr_t)"Allwinner AHB Clock Gates" },
+ { "allwinner,sun5i-a13-apb0-gates-clk",
+ (uintptr_t)"Allwinner APB0 Clock Gates" },
+ { "allwinner,sun5i-a13-apb1-gates-clk",
+ (uintptr_t)"Allwinner APB1 Clock Gates" },
+
{ "allwinner,sun7i-a20-ahb-gates-clk",
(uintptr_t)"Allwinner AHB Clock Gates" },
{ "allwinner,sun7i-a20-apb0-gates-clk",
Modified: stable/11/sys/arm/allwinner/clk/aw_pll.c
==============================================================================
--- stable/11/sys/arm/allwinner/clk/aw_pll.c Mon Sep 5 20:07:03 2016 (r305435)
+++ stable/11/sys/arm/allwinner/clk/aw_pll.c Mon Sep 5 20:17:18 2016 (r305436)
@@ -49,6 +49,8 @@ __FBSDID("$FreeBSD$");
#include <dt-bindings/clock/sun4i-a10-pll2.h>
+#include <arm/allwinner/allwinner_machdep.h>
+
#include "clkdev_if.h"
#define AW_PLL_ENABLE (1 << 31)
@@ -101,6 +103,13 @@ __FBSDID("$FreeBSD$");
#define A10_PLL2_POST_DIV (0xf << 26)
+#define A13_PLL2_POST_DIV (0xf << 26)
+#define A13_PLL2_POST_DIV_SHIFT 26
+#define A13_PLL2_FACTOR_N (0x7f << 8)
+#define A13_PLL2_FACTOR_N_SHIFT 8
+#define A13_PLL2_PRE_DIV (0x1f << 0)
+#define A13_PLL2_PRE_DIV_SHIFT 0
+
#define A23_PLL1_FACTOR_N (0x1f << 8)
#define A23_PLL1_FACTOR_N_SHIFT 8
#define A23_PLL1_FACTOR_K (0x3 << 4)
@@ -159,6 +168,7 @@ enum aw_pll_type {
AWPLL_A10_PLL3,
AWPLL_A10_PLL5,
AWPLL_A10_PLL6,
+ AWPLL_A13_PLL2,
AWPLL_A23_PLL1,
AWPLL_A31_PLL1,
AWPLL_A31_PLL6,
@@ -462,6 +472,81 @@ a10_pll6_set_freq(struct aw_pll_sc *sc,
}
static int
+a13_pll2_recalc(struct aw_pll_sc *sc, uint64_t *freq)
+{
+ uint32_t val, post_div, n, pre_div;
+
+ DEVICE_LOCK(sc);
+ PLL_READ(sc, &val);
+ DEVICE_UNLOCK(sc);
+
+ post_div = ((val & A13_PLL2_POST_DIV) >> A13_PLL2_POST_DIV_SHIFT) + 1;
+ if (post_div == 0)
+ post_div = 1;
+ n = (val & A13_PLL2_FACTOR_N) >> A13_PLL2_FACTOR_N_SHIFT;
+ if (n == 0)
+ n = 1;
+ pre_div = ((val & A13_PLL2_PRE_DIV) >> A13_PLL2_PRE_DIV_SHIFT) + 1;
+ if (pre_div == 0)
+ pre_div = 1;
+
+ switch (sc->id) {
+ case SUN4I_A10_PLL2_1X:
+ *freq = (*freq * 2 * n) / pre_div / post_div / 2;
+ break;
+ case SUN4I_A10_PLL2_2X:
+ *freq = (*freq * 2 * n) / pre_div / 4;
+ break;
+ case SUN4I_A10_PLL2_4X:
+ *freq = (*freq * 2 * n) / pre_div / 2;
+ break;
+ case SUN4I_A10_PLL2_8X:
+ *freq = (*freq * 2 * n) / pre_div;
+ break;
+ default:
+ return (EINVAL);
+ }
+
+ return (0);
+}
+
+static int
+a13_pll2_set_freq(struct aw_pll_sc *sc, uint64_t fin, uint64_t *fout,
+ int flags)
+{
+ uint32_t val, post_div, n, pre_div;
+
+ if (sc->id != SUN4I_A10_PLL2_1X)
+ return (ENXIO);
+
+ /*
+ * Audio Codec needs PLL2-1X to be either 24576000 or 22579200.
+ *
+ * PLL2-1X output frequency is (48MHz * n) / pre_div / post_div / 2.
+ * To get as close as possible to the desired rate, we use a
+ * pre-divider of 21 and a post-divider of 4. With these values,
+ * a multiplier of 86 or 79 gets us close to the target rates.
+ */
+ if (*fout != 24576000 && *fout != 22579200)
+ return (EINVAL);
+
+ pre_div = 21;
+ post_div = 4;
+ n = (*fout * pre_div * post_div * 2) / (2 * fin);
+
+ DEVICE_LOCK(sc);
+ PLL_READ(sc, &val);
+ val &= ~(A13_PLL2_POST_DIV | A13_PLL2_FACTOR_N | A13_PLL2_PRE_DIV);
+ val |= ((post_div - 1) << A13_PLL2_POST_DIV_SHIFT);
+ val |= (n << A13_PLL2_FACTOR_N_SHIFT);
+ val |= ((pre_div - 1) << A13_PLL2_PRE_DIV_SHIFT);
+ PLL_WRITE(sc, val);
+ DEVICE_UNLOCK(sc);
+
+ return (0);
+}
+
+static int
a23_pll1_recalc(struct aw_pll_sc *sc, uint64_t *freq)
{
uint32_t val, m, n, k, p;
@@ -591,6 +676,7 @@ static struct aw_pll_funcs aw_pll_func[]
PLL(AWPLL_A10_PLL3, a10_pll3_recalc, a10_pll3_set_freq, a10_pll3_init),
PLL(AWPLL_A10_PLL5, a10_pll5_recalc, NULL, NULL),
PLL(AWPLL_A10_PLL6, a10_pll6_recalc, a10_pll6_set_freq, a10_pll6_init),
+ PLL(AWPLL_A13_PLL2, a13_pll2_recalc, a13_pll2_set_freq, NULL),
PLL(AWPLL_A23_PLL1, a23_pll1_recalc, NULL, NULL),
PLL(AWPLL_A31_PLL1, a31_pll1_recalc, NULL, NULL),
PLL(AWPLL_A31_PLL6, a31_pll6_recalc, NULL, a31_pll6_init),
@@ -603,6 +689,7 @@ static struct ofw_compat_data compat_dat
{ "allwinner,sun4i-a10-pll3-clk", AWPLL_A10_PLL3 },
{ "allwinner,sun4i-a10-pll5-clk", AWPLL_A10_PLL5 },
{ "allwinner,sun4i-a10-pll6-clk", AWPLL_A10_PLL6 },
+ { "allwinner,sun5i-a13-pll2-clk", AWPLL_A13_PLL2 },
{ "allwinner,sun6i-a31-pll1-clk", AWPLL_A31_PLL1 },
{ "allwinner,sun6i-a31-pll6-clk", AWPLL_A31_PLL6 },
{ "allwinner,sun8i-a23-pll1-clk", AWPLL_A23_PLL1 },
Modified: stable/11/sys/arm/allwinner/clk/aw_usbclk.c
==============================================================================
--- stable/11/sys/arm/allwinner/clk/aw_usbclk.c Mon Sep 5 20:07:03 2016 (r305435)
+++ stable/11/sys/arm/allwinner/clk/aw_usbclk.c Mon Sep 5 20:17:18 2016 (r305436)
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
enum aw_usbclk_type {
AW_A10_USBCLK = 1,
+ AW_A13_USBCLK,
AW_A31_USBCLK,
AW_A83T_USBCLK,
AW_H3_USBCLK,
@@ -68,6 +69,7 @@ enum aw_usbclk_type {
static struct ofw_compat_data compat_data[] = {
{ "allwinner,sun4i-a10-usb-clk", AW_A10_USBCLK },
+ { "allwinner,sun5i-a13-usb-clk", AW_A13_USBCLK },
{ "allwinner,sun6i-a31-usb-clk", AW_A31_USBCLK },
{ "allwinner,sun8i-a83t-usb-clk", AW_A83T_USBCLK },
{ "allwinner,sun8i-h3-usb-clk", AW_H3_USBCLK },
Modified: stable/11/sys/arm/allwinner/std.a10
==============================================================================
--- stable/11/sys/arm/allwinner/std.a10 Mon Sep 5 20:07:03 2016 (r305435)
+++ stable/11/sys/arm/allwinner/std.a10 Mon Sep 5 20:17:18 2016 (r305436)
@@ -10,3 +10,4 @@ options KERNVIRTADDR=0xc0200000
files "../allwinner/files.allwinner"
files "../allwinner/files.a10"
+files "../allwinner/a13/files.a13"
Modified: stable/11/sys/arm/conf/A10
==============================================================================
--- stable/11/sys/arm/conf/A10 Mon Sep 5 20:07:03 2016 (r305435)
+++ stable/11/sys/arm/conf/A10 Mon Sep 5 20:17:18 2016 (r305436)
@@ -26,6 +26,7 @@ include "../allwinner/std.a10"
options INTRNG
options SOC_ALLWINNER_A10
+options SOC_ALLWINNER_A13
options HZ=100
options SCHED_4BSD # 4BSD scheduler
@@ -68,6 +69,8 @@ device iic
device twsi
device axp209 # AXP209 Power Management Unit
+device pcf8563 # RTC
+
# GPIO
device gpio
device gpioled
@@ -96,6 +99,9 @@ device emac
# USB ethernet support, requires miibus
device miibus
+# Sound support
+device sound
+
# Pinmux
device fdt_pinctrl
Modified: stable/11/sys/conf/options.arm
==============================================================================
--- stable/11/sys/conf/options.arm Mon Sep 5 20:07:03 2016 (r305435)
+++ stable/11/sys/conf/options.arm Mon Sep 5 20:17:18 2016 (r305436)
@@ -41,6 +41,7 @@ SOCDEV_VA opt_global.h
PV_STATS opt_pmap.h
QEMU_WORKAROUNDS opt_global.h
SOC_ALLWINNER_A10 opt_global.h
+SOC_ALLWINNER_A13 opt_global.h
SOC_ALLWINNER_A20 opt_global.h
SOC_ALLWINNER_A31 opt_global.h
SOC_ALLWINNER_A31S opt_global.h
More information about the svn-src-stable-11
mailing list