CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Wed Sep 28 10:23:37 UTC 2022 Modified Files: src/sys/arch/arm/amlogic: mesongx_wdt.c Log Message: Match Meson GXBB watchdog. >From Vincent DEFERT on port-arm: http://mail-index.netbsd.org/port-arm/2022/09/21/msg007860.html To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/amlogic/mesongx_wdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/mesongx_wdt.c diff -u src/sys/arch/arm/amlogic/mesongx_wdt.c:1.2 src/sys/arch/arm/amlogic/mesongx_wdt.c:1.3 --- src/sys/arch/arm/amlogic/mesongx_wdt.c:1.2 Wed Jan 27 03:10:18 2021 +++ src/sys/arch/arm/amlogic/mesongx_wdt.c Wed Sep 28 10:23:37 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: mesongx_wdt.c,v 1.2 2021/01/27 03:10:18 thorpej Exp $ */ +/* $NetBSD: mesongx_wdt.c,v 1.3 2022/09/28 10:23:37 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mesongx_wdt.c,v 1.2 2021/01/27 03:10:18 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mesongx_wdt.c,v 1.3 2022/09/28 10:23:37 jmcneill Exp $"); #include #include @@ -56,6 +56,7 @@ __KERNEL_RCSID(0, "$NetBSD: mesongx_wdt. static const struct device_compatible_entry compat_data[] = { { .compat = "amlogic,meson-gx-wdt" }, + { .compat = "amlogic,meson-gxbb-wdt" }, DEVICE_COMPAT_EOL };
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Wed Sep 28 10:23:37 UTC 2022 Modified Files: src/sys/arch/arm/amlogic: mesongx_wdt.c Log Message: Match Meson GXBB watchdog. >From Vincent DEFERT on port-arm: http://mail-index.netbsd.org/port-arm/2022/09/21/msg007860.html To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/amlogic/mesongx_wdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: brook Date: Thu Jun 23 03:36:00 UTC 2022 Modified Files: src/sys/arch/arm/amlogic: meson8b_pinctrl.c Log Message: Add a mising gpio pin description. This file enumerates the gpio pins in two different ways: as enum values and as an array of data. The enum values are used as keys into the array. One of the enums, GPIODV_9, is missing from the table. As a result, lookup fails to find a matching entry and returns an invalid entry, which causes the kernel to panic. This patch adds the missing data to the array. However, the underlying problem is not fixed. Somewhere in the kernel is lookup logic that does not check the validity of the results to ensure that a match indeed occurred. There are no doubt other potential panics to be triggered by the same lookup code applied to other tables (or future versions of this one). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/amlogic/meson8b_pinctrl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson8b_pinctrl.c diff -u src/sys/arch/arm/amlogic/meson8b_pinctrl.c:1.2 src/sys/arch/arm/amlogic/meson8b_pinctrl.c:1.3 --- src/sys/arch/arm/amlogic/meson8b_pinctrl.c:1.2 Wed Aug 14 09:50:20 2019 +++ src/sys/arch/arm/amlogic/meson8b_pinctrl.c Thu Jun 23 03:36:00 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: meson8b_pinctrl.c,v 1.2 2019/08/14 09:50:20 jmcneill Exp $ */ +/* $NetBSD: meson8b_pinctrl.c,v 1.3 2022/06/23 03:36:00 brook Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: meson8b_pinctrl.c,v 1.2 2019/08/14 09:50:20 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson8b_pinctrl.c,v 1.3 2022/06/23 03:36:00 brook Exp $"); #include @@ -226,6 +226,7 @@ static const struct meson_pinctrl_gpio m CBUS_GPIO(GPIOY_14, 3, 14, 3, 14), /* GPIODV */ + CBUS_GPIO(GPIODV_9, 6, 9, 0, 9), CBUS_GPIO(GPIODV_24, 6, 24, 0, 24), CBUS_GPIO(GPIODV_25, 6, 25, 0, 25), CBUS_GPIO(GPIODV_26, 6, 26, 0, 26),
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: brook Date: Thu Jun 23 03:36:00 UTC 2022 Modified Files: src/sys/arch/arm/amlogic: meson8b_pinctrl.c Log Message: Add a mising gpio pin description. This file enumerates the gpio pins in two different ways: as enum values and as an array of data. The enum values are used as keys into the array. One of the enums, GPIODV_9, is missing from the table. As a result, lookup fails to find a matching entry and returns an invalid entry, which causes the kernel to panic. This patch adds the missing data to the array. However, the underlying problem is not fixed. Somewhere in the kernel is lookup logic that does not check the validity of the results to ensure that a match indeed occurred. There are no doubt other potential panics to be triggered by the same lookup code applied to other tables (or future versions of this one). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/amlogic/meson8b_pinctrl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: riastradh Date: Sat Mar 19 11:36:43 UTC 2022 Modified Files: src/sys/arch/arm/amlogic: meson_rng.c Log Message: meson_rng(4): No need for lock -- delete it. We only ever read a single register at a time; no exclusive access or serialization needed. XXX This driver should have some kind of hardware-specific health test -- is there documentation anywhere for what this RNG actually is? To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/amlogic/meson_rng.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_rng.c diff -u src/sys/arch/arm/amlogic/meson_rng.c:1.4 src/sys/arch/arm/amlogic/meson_rng.c:1.5 --- src/sys/arch/arm/amlogic/meson_rng.c:1.4 Wed Jan 27 03:10:18 2021 +++ src/sys/arch/arm/amlogic/meson_rng.c Sat Mar 19 11:36:43 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_rng.c,v 1.4 2021/01/27 03:10:18 thorpej Exp $ */ +/* $NetBSD: meson_rng.c,v 1.5 2022/03/19 11:36:43 riastradh Exp $ */ /*- * Copyright (c) 2015-2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: meson_rng.c,v 1.4 2021/01/27 03:10:18 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_rng.c,v 1.5 2022/03/19 11:36:43 riastradh Exp $"); #include #include @@ -49,7 +49,6 @@ struct meson_rng_softc { bus_space_tag_t sc_bst; bus_space_handle_t sc_bsh; - kmutex_t sc_lock; krndsource_t sc_rndsource; }; @@ -91,8 +90,6 @@ meson_rng_attach(device_t parent, device return; } - mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_VM); - /* Core clock is optional */ clk = fdtbus_clock_get(phandle, "core"); if (clk != NULL && clk_enable(clk) != 0) { @@ -114,7 +111,6 @@ meson_rng_get(size_t bytes_wanted, void struct meson_rng_softc * const sc = priv; uint32_t data; - mutex_spin_enter(>sc_lock); while (bytes_wanted) { data = bus_space_read_4(sc->sc_bst, sc->sc_bsh, 0); rnd_add_data_sync(>sc_rndsource, , sizeof(data), @@ -122,5 +118,4 @@ meson_rng_get(size_t bytes_wanted, void bytes_wanted -= MIN(bytes_wanted, sizeof(data)); } explicit_memset(, 0, sizeof(data)); - mutex_spin_exit(>sc_lock); }
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: riastradh Date: Sat Mar 19 11:36:43 UTC 2022 Modified Files: src/sys/arch/arm/amlogic: meson_rng.c Log Message: meson_rng(4): No need for lock -- delete it. We only ever read a single register at a time; no exclusive access or serialization needed. XXX This driver should have some kind of hardware-specific health test -- is there documentation anywhere for what this RNG actually is? To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/amlogic/meson_rng.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jdc Date: Fri Nov 19 07:04:27 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: meson_dwmac.c Log Message: PR port-evbarm/50416 Redo the previous change. The "snps,..." properties are on the ethernet node and the "reset-..." properties are on the phy node. Handle this by creating a separate reset routine for each case. Idea from Jared. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/amlogic/meson_dwmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_dwmac.c diff -u src/sys/arch/arm/amlogic/meson_dwmac.c:1.13 src/sys/arch/arm/amlogic/meson_dwmac.c:1.14 --- src/sys/arch/arm/amlogic/meson_dwmac.c:1.13 Wed Nov 17 11:57:27 2021 +++ src/sys/arch/arm/amlogic/meson_dwmac.c Fri Nov 19 07:04:27 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_dwmac.c,v 1.13 2021/11/17 11:57:27 jdc Exp $ */ +/* $NetBSD: meson_dwmac.c,v 1.14 2021/11/19 07:04:27 jdc Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.13 2021/11/17 11:57:27 jdc Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.14 2021/11/19 07:04:27 jdc Exp $"); #include #include @@ -66,72 +66,69 @@ static const struct device_compatible_en }; static int -meson_dwmac_reset(const int phandle) +meson_dwmac_reset_eth(const int phandle) { struct fdtbus_gpio_pin *pin_reset; const u_int *reset_delay_us; - const u_int *reset_assert_us, *reset_deassert_us, *reset_gpios; bool reset_active_low; int len, val; - /* - * Depending on the DTS, we need to check either the "snps,...", - * or the "reset-..." properties for the MAC reset information. - */ - pin_reset = fdtbus_gpio_acquire(phandle, "snps,reset-gpio", GPIO_PIN_OUTPUT); - if (pin_reset != NULL) { + if (pin_reset == NULL) + return ENXIO; - reset_delay_us = fdtbus_get_prop(phandle, - "snps,reset-delays-us", ); - if (reset_delay_us == NULL || len != 12) - return ENXIO; + reset_delay_us = fdtbus_get_prop(phandle, "snps,reset-delays-us", ); + if (reset_delay_us == NULL || len != 12) + return ENXIO; - reset_active_low = of_hasprop(phandle, "snps,reset-active-low"); + reset_active_low = of_hasprop(phandle, "snps,reset-active-low"); - val = reset_active_low ? 1 : 0; + val = reset_active_low ? 1 : 0; - fdtbus_gpio_write(pin_reset, val); - delay(be32toh(reset_delay_us[0])); - fdtbus_gpio_write(pin_reset, !val); - delay(be32toh(reset_delay_us[1])); - fdtbus_gpio_write(pin_reset, val); - delay(be32toh(reset_delay_us[2])); + fdtbus_gpio_write(pin_reset, val); + delay(be32toh(reset_delay_us[0])); + fdtbus_gpio_write(pin_reset, !val); + delay(be32toh(reset_delay_us[1])); + fdtbus_gpio_write(pin_reset, val); + delay(be32toh(reset_delay_us[2])); - return 0; - } + return 0; +} + +static int +meson_dwmac_reset_phy(const int phandle) +{ + struct fdtbus_gpio_pin *pin_reset; + const u_int *reset_assert_us, *reset_deassert_us, *reset_gpios; + bool reset_active_low; + int len, val; pin_reset = fdtbus_gpio_acquire(phandle, "reset-gpios", GPIO_PIN_OUTPUT); - if (pin_reset != NULL) { - reset_assert_us = fdtbus_get_prop(phandle, - "reset-assert-us", ); - if (reset_assert_us == NULL || len != 4) - return ENXIO; - reset_deassert_us = fdtbus_get_prop(phandle, - "reset-deassert-us", ); - if (reset_deassert_us == NULL || len != 4) - return ENXIO; - reset_gpios = fdtbus_get_prop(phandle, - "reset-gpios", ); - if (reset_gpios == NULL || len != 12) - return ENXIO; - - reset_active_low = be32toh(reset_gpios[2]); - - val = reset_active_low ? 1 : 0; - - - fdtbus_gpio_write(pin_reset, val); - delay(be32toh(reset_assert_us[0])); - fdtbus_gpio_write(pin_reset, !val); - delay(be32toh(reset_deassert_us[0])); + if (pin_reset == NULL) + return ENXIO; - return 0; - } + reset_assert_us = fdtbus_get_prop(phandle, "reset-assert-us", ); + if (reset_assert_us == NULL || len != 4) + return ENXIO; + reset_deassert_us = fdtbus_get_prop(phandle, "reset-deassert-us", ); + if (reset_deassert_us == NULL || len != 4) + return ENXIO; + reset_gpios = fdtbus_get_prop(phandle, "reset-gpios", ); + if (reset_gpios == NULL || len != 12) + return ENXIO; + + reset_active_low = be32toh(reset_gpios[2]); + + val = reset_active_low ? 1 : 0; + + fdtbus_gpio_write(pin_reset, val); + delay(be32toh(reset_assert_us[0])); + fdtbus_gpio_write(pin_reset, !val); + delay(be32toh(reset_deassert_us[0])); - return ENXIO; + return 0; } static void @@ -276,8 +273,19 @@ meson_dwmac_attach(device_t parent, devi } aprint_normal_dev(self, "interrupting on %s\n", intrstr); - if (meson_dwmac_reset(phandle_phy) != 0) - aprint_error_dev(self, "PHY reset failed\n"); + /* + * Depending on the DTS, we need to check either the "snps,...", + * properties on the ethernet node, or the "reset-..." + *
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jdc Date: Fri Nov 19 07:04:27 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: meson_dwmac.c Log Message: PR port-evbarm/50416 Redo the previous change. The "snps,..." properties are on the ethernet node and the "reset-..." properties are on the phy node. Handle this by creating a separate reset routine for each case. Idea from Jared. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/amlogic/meson_dwmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jdc Date: Wed Nov 17 11:57:27 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: meson_dwmac.c Log Message: PR port-evbarm/50416 Also check the "reset_gpios", "reset-assert-us", and "reset-deassert-us" properties for ethernet MAC reset information. Makes the built-in ethernet work on Odroid C1 and Odroid C2 (with mesongxbb_pinctrl.c >= r1.3). Based on a hint from Jared. C2 tested by Martin. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/amlogic/meson_dwmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jdc Date: Wed Nov 17 11:57:27 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: meson_dwmac.c Log Message: PR port-evbarm/50416 Also check the "reset_gpios", "reset-assert-us", and "reset-deassert-us" properties for ethernet MAC reset information. Makes the built-in ethernet work on Odroid C1 and Odroid C2 (with mesongxbb_pinctrl.c >= r1.3). Based on a hint from Jared. C2 tested by Martin. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/amlogic/meson_dwmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_dwmac.c diff -u src/sys/arch/arm/amlogic/meson_dwmac.c:1.12 src/sys/arch/arm/amlogic/meson_dwmac.c:1.13 --- src/sys/arch/arm/amlogic/meson_dwmac.c:1.12 Sun Nov 7 19:21:32 2021 +++ src/sys/arch/arm/amlogic/meson_dwmac.c Wed Nov 17 11:57:27 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_dwmac.c,v 1.12 2021/11/07 19:21:32 jmcneill Exp $ */ +/* $NetBSD: meson_dwmac.c,v 1.13 2021/11/17 11:57:27 jdc Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.12 2021/11/07 19:21:32 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.13 2021/11/17 11:57:27 jdc Exp $"); #include #include @@ -70,29 +70,68 @@ meson_dwmac_reset(const int phandle) { struct fdtbus_gpio_pin *pin_reset; const u_int *reset_delay_us; + const u_int *reset_assert_us, *reset_deassert_us, *reset_gpios; bool reset_active_low; int len, val; - pin_reset = fdtbus_gpio_acquire(phandle, "snps,reset-gpio", GPIO_PIN_OUTPUT); - if (pin_reset == NULL) + /* + * Depending on the DTS, we need to check either the "snps,...", + * or the "reset-..." properties for the MAC reset information. + */ + + pin_reset = fdtbus_gpio_acquire(phandle, "snps,reset-gpio", + GPIO_PIN_OUTPUT); + if (pin_reset != NULL) { + + reset_delay_us = fdtbus_get_prop(phandle, + "snps,reset-delays-us", ); + if (reset_delay_us == NULL || len != 12) + return ENXIO; + + reset_active_low = of_hasprop(phandle, "snps,reset-active-low"); + + val = reset_active_low ? 1 : 0; + + fdtbus_gpio_write(pin_reset, val); + delay(be32toh(reset_delay_us[0])); + fdtbus_gpio_write(pin_reset, !val); + delay(be32toh(reset_delay_us[1])); + fdtbus_gpio_write(pin_reset, val); + delay(be32toh(reset_delay_us[2])); + return 0; + } + + pin_reset = fdtbus_gpio_acquire(phandle, "reset-gpios", + GPIO_PIN_OUTPUT); + if (pin_reset != NULL) { + reset_assert_us = fdtbus_get_prop(phandle, + "reset-assert-us", ); + if (reset_assert_us == NULL || len != 4) + return ENXIO; + reset_deassert_us = fdtbus_get_prop(phandle, + "reset-deassert-us", ); + if (reset_deassert_us == NULL || len != 4) + return ENXIO; + reset_gpios = fdtbus_get_prop(phandle, + "reset-gpios", ); + if (reset_gpios == NULL || len != 12) + return ENXIO; + + reset_active_low = be32toh(reset_gpios[2]); + + val = reset_active_low ? 1 : 0; + + + fdtbus_gpio_write(pin_reset, val); + delay(be32toh(reset_assert_us[0])); + fdtbus_gpio_write(pin_reset, !val); + delay(be32toh(reset_deassert_us[0])); - reset_delay_us = fdtbus_get_prop(phandle, "snps,reset-delays-us", ); - if (reset_delay_us == NULL || len != 12) - return ENXIO; - - reset_active_low = of_hasprop(phandle, "snps,reset-active-low"); - - val = reset_active_low ? 1 : 0; - - fdtbus_gpio_write(pin_reset, val); - delay(be32toh(reset_delay_us[0])); - fdtbus_gpio_write(pin_reset, !val); - delay(be32toh(reset_delay_us[1])); - fdtbus_gpio_write(pin_reset, val); - delay(be32toh(reset_delay_us[2])); + return 0; + } - return 0; + return ENXIO; } static void
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Wed Nov 17 11:31:12 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: mesongxbb_pinctrl.c Log Message: Add missing GPIOZ direction / input / output register defs. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/amlogic/mesongxbb_pinctrl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/mesongxbb_pinctrl.c diff -u src/sys/arch/arm/amlogic/mesongxbb_pinctrl.c:1.2 src/sys/arch/arm/amlogic/mesongxbb_pinctrl.c:1.3 --- src/sys/arch/arm/amlogic/mesongxbb_pinctrl.c:1.2 Tue Feb 26 21:55:28 2019 +++ src/sys/arch/arm/amlogic/mesongxbb_pinctrl.c Wed Nov 17 11:31:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mesongxbb_pinctrl.c,v 1.2 2019/02/26 21:55:28 jmcneill Exp $ */ +/* $NetBSD: mesongxbb_pinctrl.c,v 1.3 2021/11/17 11:31:12 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mesongxbb_pinctrl.c,v 1.2 2019/02/26 21:55:28 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mesongxbb_pinctrl.c,v 1.3 2021/11/17 11:31:12 jmcneill Exp $"); #include @@ -309,7 +309,25 @@ static const struct meson_pinctrl_gpio m CBUS_GPIO(CARD_5, 2, 25), CBUS_GPIO(CARD_6, 2, 26), - /* CARD */ + /* GPIOZ */ + CBUS_GPIO(GPIOZ_0, 3, 0), + CBUS_GPIO(GPIOZ_1, 3, 1), + CBUS_GPIO(GPIOZ_2, 3, 2), + CBUS_GPIO(GPIOZ_3, 3, 3), + CBUS_GPIO(GPIOZ_4, 3, 4), + CBUS_GPIO(GPIOZ_5, 3, 5), + CBUS_GPIO(GPIOZ_6, 3, 6), + CBUS_GPIO(GPIOZ_7, 3, 7), + CBUS_GPIO(GPIOZ_8, 3, 8), + CBUS_GPIO(GPIOZ_9, 3, 9), + CBUS_GPIO(GPIOZ_10, 3, 10), + CBUS_GPIO(GPIOZ_11, 3, 11), + CBUS_GPIO(GPIOZ_12, 3, 12), + CBUS_GPIO(GPIOZ_13, 3, 13), + CBUS_GPIO(GPIOZ_14, 3, 14), + CBUS_GPIO(GPIOZ_15, 3, 15), + + /* CLK */ CBUS_GPIO(GPIOCLK_0, 3, 28), CBUS_GPIO(GPIOCLK_1, 3, 29), CBUS_GPIO(GPIOCLK_2, 3, 30),
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Wed Nov 17 11:31:12 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: mesongxbb_pinctrl.c Log Message: Add missing GPIOZ direction / input / output register defs. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/amlogic/mesongxbb_pinctrl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: ryo Date: Fri Feb 12 21:39:55 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: meson_uart.c Log Message: UART_RFIFO_REG should be masked before passing to cn_check_magic(). there is any data in other than the lower 8 bits. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/amlogic/meson_uart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: ryo Date: Fri Feb 12 21:39:55 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: meson_uart.c Log Message: UART_RFIFO_REG should be masked before passing to cn_check_magic(). there is any data in other than the lower 8 bits. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/amlogic/meson_uart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_uart.c diff -u src/sys/arch/arm/amlogic/meson_uart.c:1.5 src/sys/arch/arm/amlogic/meson_uart.c:1.6 --- src/sys/arch/arm/amlogic/meson_uart.c:1.5 Wed Jan 27 03:10:18 2021 +++ src/sys/arch/arm/amlogic/meson_uart.c Fri Feb 12 21:39:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_uart.c,v 1.5 2021/01/27 03:10:18 thorpej Exp $ */ +/* $NetBSD: meson_uart.c,v 1.6 2021/02/12 21:39:55 ryo Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: meson_uart.c,v 1.5 2021/01/27 03:10:18 thorpej Exp $"); +__KERNEL_RCSID(1, "$NetBSD: meson_uart.c,v 1.6 2021/02/12 21:39:55 ryo Exp $"); #define cn_trap() \ do {\ @@ -260,7 +260,7 @@ meson_uart_cngetc(dev_t dev) return -1; } - c = bus_space_read_4(bst, bsh, UART_RFIFO_REG); + c = bus_space_read_4(bst, bsh, UART_RFIFO_REG) & 0xff; #if defined(DDB) extern int db_active; if (!db_active) @@ -272,7 +272,7 @@ meson_uart_cngetc(dev_t dev) splx(s); - return c & 0xff; + return c; } static void
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: joerg Date: Thu Feb 4 22:55:36 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: mesong12_clkc.c Log Message: Fix C error in G12_CLK_vid_pll To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/amlogic/mesong12_clkc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/mesong12_clkc.c diff -u src/sys/arch/arm/amlogic/mesong12_clkc.c:1.5 src/sys/arch/arm/amlogic/mesong12_clkc.c:1.6 --- src/sys/arch/arm/amlogic/mesong12_clkc.c:1.5 Wed Jan 27 03:10:18 2021 +++ src/sys/arch/arm/amlogic/mesong12_clkc.c Thu Feb 4 22:55:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mesong12_clkc.c,v 1.5 2021/01/27 03:10:18 thorpej Exp $ */ +/* $NetBSD: mesong12_clkc.c,v 1.6 2021/02/04 22:55:36 joerg Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mesong12_clkc.c,v 1.5 2021/01/27 03:10:18 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mesong12_clkc.c,v 1.6 2021/02/04 22:55:36 joerg Exp $"); #include #include @@ -939,7 +939,7 @@ struct mesong12_clkc_config { __BIT(18), /* sel */ \ 0) #define G12_CLK_vid_pll \ - MESON_CLK_GATE(MESONG12_CLOCK_VID_PLL_DIV, "vid_pll", \ + MESON_CLK_GATE(MESONG12_CLOCK_VID_PLL, "vid_pll", \ "vid_pll_sel", /* parent */ \ HHI_VID_PLL_CLK_DIV, /* reg */ \ 19)/* bit */
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: joerg Date: Thu Feb 4 22:55:36 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: mesong12_clkc.c Log Message: Fix C error in G12_CLK_vid_pll To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/amlogic/mesong12_clkc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Mon Feb 1 01:52:05 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: files.meson Log Message: defflag SOC_MESONG12 To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/amlogic/files.meson Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/files.meson diff -u src/sys/arch/arm/amlogic/files.meson:1.11 src/sys/arch/arm/amlogic/files.meson:1.12 --- src/sys/arch/arm/amlogic/files.meson:1.11 Fri Jan 1 07:21:58 2021 +++ src/sys/arch/arm/amlogic/files.meson Mon Feb 1 01:52:04 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files.meson,v 1.11 2021/01/01 07:21:58 ryo Exp $ +# $NetBSD: files.meson,v 1.12 2021/02/01 01:52:04 jmcneill Exp $ # # Configuration info for Amlogic Meson family SoCs # @@ -158,6 +158,7 @@ file arch/arm/amlogic/meson_thermal.c me # SOC parameters defflag opt_soc.h SOC_MESON defflag opt_soc.h SOC_MESON8B: SOC_MESON +defflag opt_soc.h SOC_MESONG12: SOC_MESON defflag opt_soc.h SOC_MESONGX: SOC_MESON defflag opt_soc.h SOC_MESONGXBB: SOC_MESONGX defflag opt_soc.h SOC_MESONGXL: SOC_MESONGX
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Mon Feb 1 01:52:05 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: files.meson Log Message: defflag SOC_MESONG12 To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/amlogic/files.meson Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Thu Jan 28 11:45:31 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: port-arm/55957: Odroid C2 can not access eMMC card A few changes to clock setup: - Disable clock while changing dividers - Set / clear DDR flag before changing clock - Adjust TX/RX/core phases To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/mesongx_mmc.c diff -u src/sys/arch/arm/amlogic/mesongx_mmc.c:1.13 src/sys/arch/arm/amlogic/mesongx_mmc.c:1.14 --- src/sys/arch/arm/amlogic/mesongx_mmc.c:1.13 Wed Jan 27 03:10:18 2021 +++ src/sys/arch/arm/amlogic/mesongx_mmc.c Thu Jan 28 11:45:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mesongx_mmc.c,v 1.13 2021/01/27 03:10:18 thorpej Exp $ */ +/* $NetBSD: mesongx_mmc.c,v 1.14 2021/01/28 11:45:31 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.13 2021/01/27 03:10:18 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.14 2021/01/28 11:45:31 jmcneill Exp $"); #include #include @@ -496,6 +496,17 @@ mesongx_mmc_set_clock(struct mesongx_mmc if (best_diff == INT_MAX) return ERANGE; + val = MMC_READ(sc, SD_EMMC_CFG); + val |= CFG_STOP_CLK; + MMC_WRITE(sc, SD_EMMC_CFG, val); + + val = MMC_READ(sc, SD_EMMC_CFG); + if (ddr) + val |= CFG_DDR; + else + val &= ~CFG_DDR; + MMC_WRITE(sc, SD_EMMC_CFG, val); + val = MMC_READ(sc, SD_EMMC_CLOCK); if (sc->sc_hwtype == MESONGX_MMC_V3) val |= CLOCK_CFG_V3_ALWAYS_ON; @@ -504,15 +515,19 @@ mesongx_mmc_set_clock(struct mesongx_mmc val &= ~CLOCK_CFG_RX_PHASE; val |= __SHIFTIN(0, CLOCK_CFG_RX_PHASE); val &= ~CLOCK_CFG_TX_PHASE; - val |= __SHIFTIN(2, CLOCK_CFG_TX_PHASE); + val |= __SHIFTIN(0, CLOCK_CFG_TX_PHASE); val &= ~CLOCK_CFG_CO_PHASE; - val |= __SHIFTIN(3, CLOCK_CFG_CO_PHASE); + val |= __SHIFTIN(2, CLOCK_CFG_CO_PHASE); val &= ~CLOCK_CFG_SRC; val |= __SHIFTIN(best_sel, CLOCK_CFG_SRC); val &= ~CLOCK_CFG_DIV; val |= __SHIFTIN(best_div, CLOCK_CFG_DIV); MMC_WRITE(sc, SD_EMMC_CLOCK, val); + val = MMC_READ(sc, SD_EMMC_CFG); + val &= ~CFG_STOP_CLK; + MMC_WRITE(sc, SD_EMMC_CFG, val); + return 0; } @@ -733,21 +748,8 @@ static int mesongx_mmc_bus_clock(sdmmc_chipset_handle_t sch, int freq, bool ddr) { struct mesongx_mmc_softc * const sc = sch; - uint32_t val; - int error; - - error = mesongx_mmc_set_clock(sc, freq, ddr); - if (error != 0) - return error; - - val = MMC_READ(sc, SD_EMMC_CFG); - if (ddr) - val |= CFG_DDR; - else - val &= ~CFG_DDR; - MMC_WRITE(sc, SD_EMMC_CFG, val); - return 0; + return mesongx_mmc_set_clock(sc, freq, ddr); } static int
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Thu Jan 28 11:45:31 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: port-arm/55957: Odroid C2 can not access eMMC card A few changes to clock setup: - Disable clock while changing dividers - Set / clear DDR flag before changing clock - Adjust TX/RX/core phases To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: thorpej Date: Wed Jan 27 01:49:36 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: meson_pinctrl.c meson_pwm.c meson_thermal.c meson_usbctrl.c meson_usbphy.c mesong12_clkc.c mesongx_mmc.c mesongxbb_clkc.c Log Message: Use DEVICE_COMPAT_EOL. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/amlogic/meson_pinctrl.c cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/amlogic/meson_pwm.c \ src/sys/arch/arm/amlogic/meson_usbctrl.c \ src/sys/arch/arm/amlogic/mesong12_clkc.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/amlogic/meson_thermal.c \ src/sys/arch/arm/amlogic/meson_usbphy.c \ src/sys/arch/arm/amlogic/mesongxbb_clkc.c cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_pinctrl.c diff -u src/sys/arch/arm/amlogic/meson_pinctrl.c:1.9 src/sys/arch/arm/amlogic/meson_pinctrl.c:1.10 --- src/sys/arch/arm/amlogic/meson_pinctrl.c:1.9 Mon Jan 25 14:20:37 2021 +++ src/sys/arch/arm/amlogic/meson_pinctrl.c Wed Jan 27 01:49:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_pinctrl.c,v 1.9 2021/01/25 14:20:37 thorpej Exp $ */ +/* $NetBSD: meson_pinctrl.c,v 1.10 2021/01/27 01:49:36 thorpej Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -29,7 +29,7 @@ #include "opt_soc.h" #include -__KERNEL_RCSID(0, "$NetBSD: meson_pinctrl.c,v 1.9 2021/01/25 14:20:37 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_pinctrl.c,v 1.10 2021/01/27 01:49:36 thorpej Exp $"); #include #include @@ -96,7 +96,7 @@ static const struct device_compatible_en { .compat = "amlogic,meson-g12a-periphs-pinctrl", .data = _periphs_pinctrl_config }, #endif - { } + DEVICE_COMPAT_EOL }; #define MUX_READ(sc, reg)\ Index: src/sys/arch/arm/amlogic/meson_pwm.c diff -u src/sys/arch/arm/amlogic/meson_pwm.c:1.3 src/sys/arch/arm/amlogic/meson_pwm.c:1.4 --- src/sys/arch/arm/amlogic/meson_pwm.c:1.3 Mon Jan 25 14:20:37 2021 +++ src/sys/arch/arm/amlogic/meson_pwm.c Wed Jan 27 01:49:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_pwm.c,v 1.3 2021/01/25 14:20:37 thorpej Exp $ */ +/* $NetBSD: meson_pwm.c,v 1.4 2021/01/27 01:49:36 thorpej Exp $ */ /* * Copyright (c) 2021 Ryo Shimizu @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: meson_pwm.c,v 1.3 2021/01/25 14:20:37 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_pwm.c,v 1.4 2021/01/27 01:49:36 thorpej Exp $"); #include #include @@ -69,7 +69,7 @@ static const struct device_compatible_en { .compat = "amlogic,meson-g12a-ao-pwm-ab" }, { .compat = "amlogic,meson-g12a-ao-pwm-cd" }, { .compat = "amlogic,meson-g12a-ee-pwm" }, - { } + DEVICE_COMPAT_EOL }; #define MESON_PWM_NCHAN 2 Index: src/sys/arch/arm/amlogic/meson_usbctrl.c diff -u src/sys/arch/arm/amlogic/meson_usbctrl.c:1.3 src/sys/arch/arm/amlogic/meson_usbctrl.c:1.4 --- src/sys/arch/arm/amlogic/meson_usbctrl.c:1.3 Mon Jan 25 14:20:37 2021 +++ src/sys/arch/arm/amlogic/meson_usbctrl.c Wed Jan 27 01:49:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_usbctrl.c,v 1.3 2021/01/25 14:20:37 thorpej Exp $ */ +/* $NetBSD: meson_usbctrl.c,v 1.4 2021/01/27 01:49:36 thorpej Exp $ */ /* * Copyright (c) 2021 Ryo Shimizu @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: meson_usbctrl.c,v 1.3 2021/01/25 14:20:37 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_usbctrl.c,v 1.4 2021/01/27 01:49:36 thorpej Exp $"); #include #include @@ -112,7 +112,7 @@ struct meson_usbctrl_config mesong12_con static const struct device_compatible_entry compat_data[] = { { .compat = "amlogic,meson-g12a-usb-ctrl", .data = _conf }, - { } + DEVICE_COMPAT_EOL }; struct meson_usbctrl_softc { Index: src/sys/arch/arm/amlogic/mesong12_clkc.c diff -u src/sys/arch/arm/amlogic/mesong12_clkc.c:1.3 src/sys/arch/arm/amlogic/mesong12_clkc.c:1.4 --- src/sys/arch/arm/amlogic/mesong12_clkc.c:1.3 Mon Jan 25 14:20:37 2021 +++ src/sys/arch/arm/amlogic/mesong12_clkc.c Wed Jan 27 01:49:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mesong12_clkc.c,v 1.3 2021/01/25 14:20:37 thorpej Exp $ */ +/* $NetBSD: mesong12_clkc.c,v 1.4 2021/01/27 01:49:36 thorpej Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mesong12_clkc.c,v 1.3 2021/01/25 14:20:37 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mesong12_clkc.c,v 1.4 2021/01/27 01:49:36 thorpej Exp $"); #include #include @@ -1492,7 +1492,7 @@ static const struct mesong12_clkc_config static const struct device_compatible_entry compat_data[] = { { .compat = "amlogic,g12a-clkc", .data = _config }, { .compat = "amlogic,g12b-clkc", .data = _config }, - { } + DEVICE_COMPAT_EOL }; CFATTACH_DECL_NEW(mesong12_clkc, sizeof(struct meson_clk_softc), Index: src/sys/arch/arm/amlogic/meson_thermal.c diff -u
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: thorpej Date: Wed Jan 27 01:49:36 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: meson_pinctrl.c meson_pwm.c meson_thermal.c meson_usbctrl.c meson_usbphy.c mesong12_clkc.c mesongx_mmc.c mesongxbb_clkc.c Log Message: Use DEVICE_COMPAT_EOL. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/amlogic/meson_pinctrl.c cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/amlogic/meson_pwm.c \ src/sys/arch/arm/amlogic/meson_usbctrl.c \ src/sys/arch/arm/amlogic/mesong12_clkc.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/amlogic/meson_thermal.c \ src/sys/arch/arm/amlogic/meson_usbphy.c \ src/sys/arch/arm/amlogic/mesongxbb_clkc.c cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: macallan Date: Fri Jan 8 00:13:21 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: meson_thermal.c Log Message: shut up a clang warning about snprintf() called with a variable as format string NFCI To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson_thermal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_thermal.c diff -u src/sys/arch/arm/amlogic/meson_thermal.c:1.1 src/sys/arch/arm/amlogic/meson_thermal.c:1.2 --- src/sys/arch/arm/amlogic/meson_thermal.c:1.1 Fri Jan 1 07:21:58 2021 +++ src/sys/arch/arm/amlogic/meson_thermal.c Fri Jan 8 00:13:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_thermal.c,v 1.1 2021/01/01 07:21:58 ryo Exp $ */ +/* $NetBSD: meson_thermal.c,v 1.2 2021/01/08 00:13:20 macallan Exp $ */ /* * Copyright (c) 2021 Ryo Shimizu @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: meson_thermal.c,v 1.1 2021/01/01 07:21:58 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_thermal.c,v 1.2 2021/01/08 00:13:20 macallan Exp $"); #include #include @@ -226,7 +226,8 @@ meson_thermal_attach(device_t parent, de sc->sc_sme->sme_refresh = meson_thermal_refresh; sc->sc_sensor_temp.units = ENVSYS_STEMP; sc->sc_sensor_temp.state = ENVSYS_SINVALID; - snprintf(sc->sc_sensor_temp.desc, ENVSYS_DESCLEN, sc->sc_conf->name); + snprintf(sc->sc_sensor_temp.desc, ENVSYS_DESCLEN, + "%s", sc->sc_conf->name); sysmon_envsys_sensor_attach(sc->sc_sme, >sc_sensor_temp); sysmon_envsys_register(sc->sc_sme);
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: macallan Date: Fri Jan 8 00:13:21 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: meson_thermal.c Log Message: shut up a clang warning about snprintf() called with a variable as format string NFCI To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson_thermal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Fri Jan 1 11:58:21 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: Use symbolic names for hwtype values. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/mesongx_mmc.c diff -u src/sys/arch/arm/amlogic/mesongx_mmc.c:1.7 src/sys/arch/arm/amlogic/mesongx_mmc.c:1.8 --- src/sys/arch/arm/amlogic/mesongx_mmc.c:1.7 Fri Jan 1 11:51:47 2021 +++ src/sys/arch/arm/amlogic/mesongx_mmc.c Fri Jan 1 11:58:21 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mesongx_mmc.c,v 1.7 2021/01/01 11:51:47 jmcneill Exp $ */ +/* $NetBSD: mesongx_mmc.c,v 1.8 2021/01/01 11:58:21 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.7 2021/01/01 11:51:47 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.8 2021/01/01 11:58:21 jmcneill Exp $"); #include #include @@ -262,10 +262,15 @@ CFATTACH_DECL_NEW(mesongx_mmc, sizeof(st #define MMC_READ(sc, reg) \ bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg)) +enum { + MESONGX_MMC_V2 = 2, + MESONGX_MMC_V3 = 3, +}; + static const struct of_compat_data compat_data[] = { - { "amlogic,meson-gx-mmc", 2 }, - { "amlogic,meson-gxbb-mmc", 2 }, - { "amlogic,meson-axg-mmc", 3 }, + { "amlogic,meson-gx-mmc", MESONGX_MMC_V2 }, + { "amlogic,meson-gxbb-mmc", MESONGX_MMC_V2 }, + { "amlogic,meson-axg-mmc", MESONGX_MMC_V3 }, { NULL } }; @@ -492,7 +497,7 @@ mesongx_mmc_set_clock(struct mesongx_mmc return ERANGE; val = MMC_READ(sc, SD_EMMC_CLOCK); - if (sc->sc_hwtype == 3) + if (sc->sc_hwtype == MESONGX_MMC_V3) val |= CLOCK_CFG_V3_ALWAYS_ON; else val |= CLOCK_CFG_V2_ALWAYS_ON;
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Fri Jan 1 11:58:21 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: Use symbolic names for hwtype values. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Fri Jan 1 11:51:47 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: #define To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/mesongx_mmc.c diff -u src/sys/arch/arm/amlogic/mesongx_mmc.c:1.6 src/sys/arch/arm/amlogic/mesongx_mmc.c:1.7 --- src/sys/arch/arm/amlogic/mesongx_mmc.c:1.6 Fri Jan 1 07:17:36 2021 +++ src/sys/arch/arm/amlogic/mesongx_mmc.c Fri Jan 1 11:51:47 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mesongx_mmc.c,v 1.6 2021/01/01 07:17:36 ryo Exp $ */ +/* $NetBSD: mesongx_mmc.c,v 1.7 2021/01/01 11:51:47 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.6 2021/01/01 07:17:36 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.7 2021/01/01 11:51:47 jmcneill Exp $"); #include #include @@ -70,7 +70,7 @@ __KERNEL_RCSID(0, "$NetBSD: mesongx_mmc. #define CALOUT_CALI_SETUP __BITS(15,8) #define CALOUT_CALI_VLD __BIT(7) #define CALOUT_CALI_IDX __BITS(5,0) -#define SD_EMMC_V3_ADJUST 0x0c +#define SD_EMMC_V3_ADJUST 0x0c #define SD_EMMC_START 0x40 #define START_DESC_ADDR __BITS(31,2) #define START_DESC_BUSY __BIT(1)
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Fri Jan 1 11:51:47 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: #define To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: ryo Date: Fri Jan 1 07:18:23 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: meson_dwmac.c Log Message: fix to work with various clock frequencies, and add support "amlogic,meson-axg-dwmac" To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/amlogic/meson_dwmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_dwmac.c diff -u src/sys/arch/arm/amlogic/meson_dwmac.c:1.8 src/sys/arch/arm/amlogic/meson_dwmac.c:1.9 --- src/sys/arch/arm/amlogic/meson_dwmac.c:1.8 Thu Feb 6 00:32:07 2020 +++ src/sys/arch/arm/amlogic/meson_dwmac.c Fri Jan 1 07:18:23 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_dwmac.c,v 1.8 2020/02/06 00:32:07 rjs Exp $ */ +/* $NetBSD: meson_dwmac.c,v 1.9 2021/01/01 07:18:23 ryo Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.8 2020/02/06 00:32:07 rjs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.9 2021/01/01 07:18:23 ryo Exp $"); #include #include @@ -61,6 +61,7 @@ static const char * compatible[] = { "amlogic,meson8b-dwmac", "amlogic,meson-gx-dwmac", "amlogic,meson-gxbb-dwmac", + "amlogic,meson-axg-dwmac", NULL }; @@ -101,7 +102,8 @@ meson_dwmac_set_mode_rgmii(int phandle, u_int tx_delay; uint32_t val; - const u_int div = clk_get_rate(clkin) / 25000; +#define DIV_ROUND_OFF(x, y) (((x) + (y) / 2) / (y)) + const u_int div = DIV_ROUND_OFF(clk_get_rate(clkin), 25000); if (of_getprop_uint32(phandle, "amlogic,tx-delay-ns", _delay) != 0) tx_delay = 2; @@ -153,6 +155,8 @@ meson_dwmac_attach(device_t parent, devi struct dwc_gmac_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; const int phandle = faa->faa_phandle; + int miiclk, phandle_phy, phy = MII_PHY_ANY; + u_int miiclk_rate; bus_space_handle_t prgeth_bsh; struct fdtbus_reset *rst_gmac; struct clk *clk_gmac, *clk_in[2]; @@ -196,6 +200,12 @@ meson_dwmac_attach(device_t parent, devi aprint_error(": missing 'phy-mode' property\n"); return; } + phandle_phy = fdtbus_get_phandle(phandle, "phy-handle"); + if (phandle_phy > 0) { + of_getprop_uint32(phandle_phy, "reg", ); + } else { + phandle_phy = phandle; + } if (strcmp(phy_mode, "rgmii") == 0) { meson_dwmac_set_mode_rgmii(phandle, sc->sc_bst, prgeth_bsh, clk_in[0]); @@ -226,10 +236,24 @@ meson_dwmac_attach(device_t parent, devi } aprint_normal_dev(self, "interrupting on %s\n", intrstr); - if (meson_dwmac_reset(phandle) != 0) + if (meson_dwmac_reset(phandle_phy) != 0) aprint_error_dev(self, "PHY reset failed\n"); - dwc_gmac_attach(sc, MII_PHY_ANY, GMAC_MII_CLK_100_150M_DIV62); + miiclk_rate = clk_get_rate(clk_gmac); + if (miiclk_rate > 250 * 1000 * 1000) + miiclk = GMAC_MII_CLK_250_300M_DIV124; + else if (miiclk_rate > 150 * 1000 * 1000) + miiclk = GMAC_MII_CLK_150_250M_DIV102; + else if (miiclk_rate > 100 * 1000 * 1000) + miiclk = GMAC_MII_CLK_100_150M_DIV62; + else if (miiclk_rate > 60 * 1000 * 1000) + miiclk = GMAC_MII_CLK_60_100M_DIV42; + else if (miiclk_rate > 35 * 1000 * 1000) + miiclk = GMAC_MII_CLK_35_60M_DIV26; + else + miiclk = GMAC_MII_CLK_25_35M_DIV16; + + dwc_gmac_attach(sc, phy, miiclk); } CFATTACH_DECL_NEW(meson_dwmac, sizeof(struct dwc_gmac_softc),
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: ryo Date: Fri Jan 1 07:18:23 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: meson_dwmac.c Log Message: fix to work with various clock frequencies, and add support "amlogic,meson-axg-dwmac" To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/amlogic/meson_dwmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: ryo Date: Fri Jan 1 07:17:37 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: adapts to some register differences to add support "amlogic,meson-axg-mmc" To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/mesongx_mmc.c diff -u src/sys/arch/arm/amlogic/mesongx_mmc.c:1.5 src/sys/arch/arm/amlogic/mesongx_mmc.c:1.6 --- src/sys/arch/arm/amlogic/mesongx_mmc.c:1.5 Sun Apr 21 13:08:48 2019 +++ src/sys/arch/arm/amlogic/mesongx_mmc.c Fri Jan 1 07:17:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: mesongx_mmc.c,v 1.5 2019/04/21 13:08:48 jmcneill Exp $ */ +/* $NetBSD: mesongx_mmc.c,v 1.6 2021/01/01 07:17:36 ryo Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.5 2019/04/21 13:08:48 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.6 2021/01/01 07:17:36 ryo Exp $"); #include #include @@ -45,10 +45,14 @@ __KERNEL_RCSID(0, "$NetBSD: mesongx_mmc. #include #define SD_EMMC_CLOCK 0x00 -#define CLOCK_CFG_IRQ_SDIO_SLEEP __BIT(25) -#define CLOCK_CFG_ALWAYS_ON __BIT(24) -#define CLOCK_CFG_RX_DELAY __BITS(23,20) -#define CLOCK_CFG_TX_DELAY __BITS(19,16) +#define CLOCK_CFG_V2_IRQ_SDIO_SLEEP __BIT(25) +#define CLOCK_CFG_V2_ALWAYS_ON __BIT(24) +#define CLOCK_CFG_V2_RX_DELAY __BITS(23,20) +#define CLOCK_CFG_V2_TX_DELAY __BITS(19,16) +#define CLOCK_CFG_V3_IRQ_SDIO_SLEEP __BIT(29) +#define CLOCK_CFG_V3_ALWAYS_ON __BIT(28) +#define CLOCK_CFG_V3_RX_DELAY __BITS(27,22) +#define CLOCK_CFG_V3_TX_DELAY __BITS(21,16) #define CLOCK_CFG_SRAM_PD __BITS(15,14) #define CLOCK_CFG_RX_PHASE __BITS(13,12) #define CLOCK_CFG_TX_PHASE __BITS(11,10) @@ -56,7 +60,7 @@ __KERNEL_RCSID(0, "$NetBSD: mesongx_mmc. #define CLOCK_CFG_SRC__BITS(7,6) #define CLOCK_CFG_DIV__BITS(5,0) #define SD_EMMC_DELAY 0x04 -#define SD_EMMC_ADJUST 0x08 +#define SD_EMMC_ADJUST 0x08 /* V2 */ #define ADJUST_ADJ_DELAY __BITS(21,16) #define ADJUST_CALI_RISE __BIT(14) #define ADJUST_ADJ_ENABLE __BIT(13) @@ -66,6 +70,7 @@ __KERNEL_RCSID(0, "$NetBSD: mesongx_mmc. #define CALOUT_CALI_SETUP __BITS(15,8) #define CALOUT_CALI_VLD __BIT(7) #define CALOUT_CALI_IDX __BITS(5,0) +#define SD_EMMC_V3_ADJUST 0x0c #define SD_EMMC_START 0x40 #define START_DESC_ADDR __BITS(31,2) #define START_DESC_BUSY __BIT(1) @@ -214,6 +219,7 @@ struct mesongx_mmc_softc { device_t sc_sdmmc_dev; uint32_t sc_host_ocr; + int sc_hwtype; struct sdmmc_command *sc_cmd; @@ -257,8 +263,9 @@ CFATTACH_DECL_NEW(mesongx_mmc, sizeof(st bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg)) static const struct of_compat_data compat_data[] = { - { "amlogic,meson-gx-mmc", 1 }, - { "amlogic,meson-gxbb-mmc", 1 }, + { "amlogic,meson-gx-mmc", 2 }, + { "amlogic,meson-gxbb-mmc", 2 }, + { "amlogic,meson-axg-mmc", 3 }, { NULL } }; @@ -280,6 +287,8 @@ mesongx_mmc_attach(device_t parent, devi bus_addr_t addr; bus_size_t size; + sc->sc_hwtype = (int)of_search_compatible(phandle, compat_data)->data; + if (fdtbus_get_reg(phandle, 0, , ) != 0) { aprint_error(": couldn't get registers\n"); return; @@ -483,7 +492,10 @@ mesongx_mmc_set_clock(struct mesongx_mmc return ERANGE; val = MMC_READ(sc, SD_EMMC_CLOCK); - val |= CLOCK_CFG_ALWAYS_ON; + if (sc->sc_hwtype == 3) + val |= CLOCK_CFG_V3_ALWAYS_ON; + else + val |= CLOCK_CFG_V2_ALWAYS_ON; val &= ~CLOCK_CFG_RX_PHASE; val |= __SHIFTIN(0, CLOCK_CFG_RX_PHASE); val &= ~CLOCK_CFG_TX_PHASE;
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: ryo Date: Fri Jan 1 07:17:37 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: adapts to some register differences to add support "amlogic,meson-axg-mmc" To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: ryo Date: Fri Jan 1 07:15:18 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: meson_resets.c Log Message: add "amlogic,meson-axg-reset" to compatible To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/amlogic/meson_resets.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_resets.c diff -u src/sys/arch/arm/amlogic/meson_resets.c:1.2 src/sys/arch/arm/amlogic/meson_resets.c:1.3 --- src/sys/arch/arm/amlogic/meson_resets.c:1.2 Mon Feb 25 19:30:17 2019 +++ src/sys/arch/arm/amlogic/meson_resets.c Fri Jan 1 07:15:18 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_resets.c,v 1.2 2019/02/25 19:30:17 jmcneill Exp $ */ +/* $NetBSD: meson_resets.c,v 1.3 2021/01/01 07:15:18 ryo Exp $ */ /*- * Copyright (c) 2017-2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: meson_resets.c,v 1.2 2019/02/25 19:30:17 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_resets.c,v 1.3 2021/01/01 07:15:18 ryo Exp $"); #include #include @@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: meson_resets static const char * compatible[] = { "amlogic,meson8b-reset", + "amlogic,meson-axg-reset", "amlogic,meson-gxbb-reset", NULL };
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: ryo Date: Fri Jan 1 07:15:18 UTC 2021 Modified Files: src/sys/arch/arm/amlogic: meson_resets.c Log Message: add "amlogic,meson-axg-reset" to compatible To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/amlogic/meson_resets.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: rjs Date: Thu Feb 6 00:32:07 UTC 2020 Modified Files: src/sys/arch/arm/amlogic: meson_dwmac.c Log Message: Match new dtb. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/amlogic/meson_dwmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: rjs Date: Thu Feb 6 00:32:07 UTC 2020 Modified Files: src/sys/arch/arm/amlogic: meson_dwmac.c Log Message: Match new dtb. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/amlogic/meson_dwmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_dwmac.c diff -u src/sys/arch/arm/amlogic/meson_dwmac.c:1.7 src/sys/arch/arm/amlogic/meson_dwmac.c:1.8 --- src/sys/arch/arm/amlogic/meson_dwmac.c:1.7 Sun Jul 21 08:24:32 2019 +++ src/sys/arch/arm/amlogic/meson_dwmac.c Thu Feb 6 00:32:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_dwmac.c,v 1.7 2019/07/21 08:24:32 mrg Exp $ */ +/* $NetBSD: meson_dwmac.c,v 1.8 2020/02/06 00:32:07 rjs Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.7 2019/07/21 08:24:32 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.8 2020/02/06 00:32:07 rjs Exp $"); #include #include @@ -60,6 +60,7 @@ __KERNEL_RCSID(0, "$NetBSD: meson_dwmac. static const char * compatible[] = { "amlogic,meson8b-dwmac", "amlogic,meson-gx-dwmac", + "amlogic,meson-gxbb-dwmac", NULL };
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Fri Aug 16 10:36:06 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson8b_clkc.c Log Message: Use correct register for mpll2_div clock To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/amlogic/meson8b_clkc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson8b_clkc.c diff -u src/sys/arch/arm/amlogic/meson8b_clkc.c:1.4 src/sys/arch/arm/amlogic/meson8b_clkc.c:1.5 --- src/sys/arch/arm/amlogic/meson8b_clkc.c:1.4 Tue Aug 13 09:56:08 2019 +++ src/sys/arch/arm/amlogic/meson8b_clkc.c Fri Aug 16 10:36:06 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson8b_clkc.c,v 1.4 2019/08/13 09:56:08 skrll Exp $ */ +/* $NetBSD: meson8b_clkc.c,v 1.5 2019/08/16 10:36:06 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: meson8b_clkc.c,v 1.4 2019/08/13 09:56:08 skrll Exp $"); +__KERNEL_RCSID(1, "$NetBSD: meson8b_clkc.c,v 1.5 2019/08/16 10:36:06 jmcneill Exp $"); #include #include @@ -268,9 +268,9 @@ static struct meson_clk_clk meson8b_clkc MESON_CLK_PLL_REG_INVALID,/* ssen */ 0), MESON_CLK_MPLL(MESON8B_CLOCK_MPLL2_DIV, "mpll2_div", "mpll_prediv", - MESON_CLK_PLL_REG(HHI_MPLL_CNTL8, __BITS(13,0)), /* sdm */ - MESON_CLK_PLL_REG(HHI_MPLL_CNTL8, __BIT(15)), /* sdm_enable */ - MESON_CLK_PLL_REG(HHI_MPLL_CNTL8, __BITS(24,16)), /* n2 */ + MESON_CLK_PLL_REG(HHI_MPLL_CNTL9, __BITS(13,0)), /* sdm */ + MESON_CLK_PLL_REG(HHI_MPLL_CNTL9, __BIT(15)), /* sdm_enable */ + MESON_CLK_PLL_REG(HHI_MPLL_CNTL9, __BITS(24,16)), /* n2 */ MESON_CLK_PLL_REG_INVALID,/* ssen */ 0),
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Fri Aug 16 10:36:06 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson8b_clkc.c Log Message: Use correct register for mpll2_div clock To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/amlogic/meson8b_clkc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Wed Aug 14 09:50:20 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson8b_pinctrl.c Log Message: Add eth_rxd3 and eth_rxd2 pinctrl groups To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson8b_pinctrl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson8b_pinctrl.c diff -u src/sys/arch/arm/amlogic/meson8b_pinctrl.c:1.1 src/sys/arch/arm/amlogic/meson8b_pinctrl.c:1.2 --- src/sys/arch/arm/amlogic/meson8b_pinctrl.c:1.1 Sat Jan 19 20:56:03 2019 +++ src/sys/arch/arm/amlogic/meson8b_pinctrl.c Wed Aug 14 09:50:20 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson8b_pinctrl.c,v 1.1 2019/01/19 20:56:03 jmcneill Exp $ */ +/* $NetBSD: meson8b_pinctrl.c,v 1.2 2019/08/14 09:50:20 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: meson8b_pinctrl.c,v 1.1 2019/01/19 20:56:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson8b_pinctrl.c,v 1.2 2019/08/14 09:50:20 jmcneill Exp $"); #include @@ -481,6 +481,8 @@ static const struct meson_pinctrl_group { "eth_ref_clk", REG6, 8, { DIF_3_N }, 1 }, { "eth_mdc", REG6, 9, { DIF_4_P }, 1 }, { "eth_mdio_en", REG6, 10, { DIF_4_N }, 1 }, + { "eth_rxd3", REG7, 22, { DIF_2_P }, 1 }, + { "eth_rxd2", REG7, 23, { DIF_2_N }, 1 }, }; static const struct meson_pinctrl_group meson8b_aobus_groups[] = {
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: skrll Date: Tue Aug 13 09:52:57 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: Trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_platform.c diff -u src/sys/arch/arm/amlogic/meson_platform.c:1.11 src/sys/arch/arm/amlogic/meson_platform.c:1.12 --- src/sys/arch/arm/amlogic/meson_platform.c:1.11 Sun Apr 21 15:57:33 2019 +++ src/sys/arch/arm/amlogic/meson_platform.c Tue Aug 13 09:52:57 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_platform.c,v 1.11 2019/04/21 15:57:33 jmcneill Exp $ */ +/* $NetBSD: meson_platform.c,v 1.12 2019/08/13 09:52:57 skrll Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -33,7 +33,7 @@ #include "arml2cc.h" #include -__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.11 2019/04/21 15:57:33 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.12 2019/08/13 09:52:57 skrll Exp $"); #include #include @@ -256,7 +256,7 @@ meson8b_platform_device_register(device_ strcat(boot_args, rootarg); } } - + meson_platform_device_register(self, aux); } #endif
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: skrll Date: Tue Aug 13 09:52:57 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: Trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: ryo Date: Tue May 28 05:08:47 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_uart.c Log Message: - since ttyinput (t_linesw->l_rint) should not be called from interrupt context, it has been modified to use softint like other serial drivers. - add spinlock for interrupt. ok jmcneill@. thanks To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/amlogic/meson_uart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Apr 21 15:57:33 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: Fix SOC_MESON8B build To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_platform.c diff -u src/sys/arch/arm/amlogic/meson_platform.c:1.10 src/sys/arch/arm/amlogic/meson_platform.c:1.11 --- src/sys/arch/arm/amlogic/meson_platform.c:1.10 Sun Apr 21 13:49:47 2019 +++ src/sys/arch/arm/amlogic/meson_platform.c Sun Apr 21 15:57:33 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_platform.c,v 1.10 2019/04/21 13:49:47 jmcneill Exp $ */ +/* $NetBSD: meson_platform.c,v 1.11 2019/04/21 15:57:33 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -33,7 +33,7 @@ #include "arml2cc.h" #include -__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.10 2019/04/21 13:49:47 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.11 2019/04/21 15:57:33 jmcneill Exp $"); #include #include @@ -442,11 +442,11 @@ meson8b_mpstart(void) } static const struct arm_platform meson8b_platform = { - .ap_devmap = meson8b_platform_devmap, + .ap_devmap = meson_platform_devmap, .ap_bootstrap = meson8b_platform_bootstrap, .ap_init_attach_args = meson_platform_init_attach_args, .ap_device_register = meson8b_platform_device_register, - .ap_reset = meson_platform_reset, + .ap_reset = meson8b_platform_reset, .ap_delay = a9tmr_delay, .ap_uart_freq = meson_platform_uart_freq, .ap_mpstart = meson8b_mpstart,
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Apr 21 15:57:33 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: Fix SOC_MESON8B build To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Apr 21 14:13:55 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_rng.c Log Message: Add support for Meson GXBB and GXL To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson_rng.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Apr 21 14:13:55 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_rng.c Log Message: Add support for Meson GXBB and GXL To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson_rng.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_rng.c diff -u src/sys/arch/arm/amlogic/meson_rng.c:1.1 src/sys/arch/arm/amlogic/meson_rng.c:1.2 --- src/sys/arch/arm/amlogic/meson_rng.c:1.1 Sat Jan 19 20:56:03 2019 +++ src/sys/arch/arm/amlogic/meson_rng.c Sun Apr 21 14:13:55 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_rng.c,v 1.1 2019/01/19 20:56:03 jmcneill Exp $ */ +/* $NetBSD: meson_rng.c,v 1.2 2019/04/21 14:13:55 jmcneill Exp $ */ /*- * Copyright (c) 2015-2019 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: meson_rng.c,v 1.1 2019/01/19 20:56:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_rng.c,v 1.2 2019/04/21 14:13:55 jmcneill Exp $"); #include #include @@ -55,7 +55,7 @@ struct meson_rng_softc { }; static const char * const compatible[] = { - "amlogic,meson8b-rng", + "amlogic,meson-rng", NULL }; @@ -94,12 +94,9 @@ meson_rng_attach(device_t parent, device mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_VM); + /* Core clock is optional */ clk = fdtbus_clock_get(phandle, "core"); - if (clk == NULL) { - aprint_error(": couldn't get core clock\n"); - return; - } - if (clk_enable(clk) != 0) { + if (clk != NULL && clk_enable(clk) != 0) { aprint_error(": couldn't enable core clock\n"); return; } @@ -118,15 +115,15 @@ static void meson_rng_get(size_t bytes_wanted, void *priv) { struct meson_rng_softc * const sc = priv; - uint32_t data[2]; + uint32_t data; mutex_spin_enter(>sc_lock); while (bytes_wanted) { - bus_space_read_region_4(sc->sc_bst, sc->sc_bsh, 0, data, 2); - rnd_add_data_sync(>sc_rndsource, data, sizeof(data), + data = bus_space_read_4(sc->sc_bst, sc->sc_bsh, 0); + rnd_add_data_sync(>sc_rndsource, , sizeof(data), sizeof(data) * NBBY); bytes_wanted -= MIN(bytes_wanted, sizeof(data)); } - explicit_memset(data, 0, sizeof(data)); + explicit_memset(, 0, sizeof(data)); mutex_spin_exit(>sc_lock); }
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Apr 21 13:49:47 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: Don't rely on the existing state of the GX watchdog control register when resetting. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_platform.c diff -u src/sys/arch/arm/amlogic/meson_platform.c:1.9 src/sys/arch/arm/amlogic/meson_platform.c:1.10 --- src/sys/arch/arm/amlogic/meson_platform.c:1.9 Sun Apr 21 12:36:39 2019 +++ src/sys/arch/arm/amlogic/meson_platform.c Sun Apr 21 13:49:47 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_platform.c,v 1.9 2019/04/21 12:36:39 jmcneill Exp $ */ +/* $NetBSD: meson_platform.c,v 1.10 2019/04/21 13:49:47 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -33,7 +33,7 @@ #include "arml2cc.h" #include -__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.9 2019/04/21 12:36:39 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.10 2019/04/21 13:49:47 jmcneill Exp $"); #include #include @@ -81,7 +81,9 @@ __KERNEL_RCSID(0, "$NetBSD: meson_platfo #define MESONGX_WATCHDOG_BASE 0xc11098d0 #define MESONGX_WATCHDOG_SIZE 0x10 #define MESONGX_WATCHDOG_CNTL 0x00 -#define MESONGX_WATCHDOG_CNTL_WDOG_EN __BIT(18) +#define MESONGX_WATCHDOG_CNTL_CLK_EN __BIT(24) +#define MESONGX_WATCHDOG_CNTL_SYS_RESET_N_EN __BIT(21) +#define MESONGX_WATCHDOG_CNTL_WDOG_EN __BIT(18) #define MESONGX_WATCHDOG_CNTL1 0x04 #define MESONGX_WATCHDOG_TCNT 0x08 #define MESONGX_WATCHDOG_TCNT_COUNT __BITS(15,0) @@ -463,8 +465,9 @@ mesongx_platform_reset(void) bus_space_map(bst, MESONGX_WATCHDOG_BASE, MESONGX_WATCHDOG_SIZE, 0, ); - val = bus_space_read_4(bst, bsh, MESONGX_WATCHDOG_CNTL); - val |= MESONGX_WATCHDOG_CNTL_WDOG_EN; + val = MESONGX_WATCHDOG_CNTL_SYS_RESET_N_EN | + MESONGX_WATCHDOG_CNTL_WDOG_EN | + MESONGX_WATCHDOG_CNTL_CLK_EN; bus_space_write_4(bst, bsh, MESONGX_WATCHDOG_CNTL, val); bus_space_write_4(bst, bsh, MESONGX_WATCHDOG_TCNT, 1);
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Apr 21 13:49:47 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: Don't rely on the existing state of the GX watchdog control register when resetting. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Apr 21 13:08:48 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: Fix module clock rate in DDR52 mode and support mmc-ddr-3_3v DT property To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Apr 21 13:08:48 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: Fix module clock rate in DDR52 mode and support mmc-ddr-3_3v DT property To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/mesongx_mmc.c diff -u src/sys/arch/arm/amlogic/mesongx_mmc.c:1.4 src/sys/arch/arm/amlogic/mesongx_mmc.c:1.5 --- src/sys/arch/arm/amlogic/mesongx_mmc.c:1.4 Sat Mar 16 12:52:47 2019 +++ src/sys/arch/arm/amlogic/mesongx_mmc.c Sun Apr 21 13:08:48 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: mesongx_mmc.c,v 1.4 2019/03/16 12:52:47 jmcneill Exp $ */ +/* $NetBSD: mesongx_mmc.c,v 1.5 2019/04/21 13:08:48 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.4 2019/03/16 12:52:47 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.5 2019/04/21 13:08:48 jmcneill Exp $"); #include #include @@ -463,7 +463,7 @@ mesongx_mmc_set_clock(struct mesongx_mmc best_sel = 0; best_div = 0; - const u_int target_rate = (freq * 1000) >> ddr; + const u_int target_rate = (freq * 1000) << ddr; for (sel = 0; sel <= 1; sel++) { const u_int parent_rate = clk_get_rate(sc->sc_clk_clkin[sel]); for (div = 1; div <= 63; div++) { @@ -541,6 +541,10 @@ mesongx_mmc_attach_i(device_t self) if (of_getprop_bool(sc->sc_phandle, "cap-mmc-highspeed")) saa.saa_caps |= SMC_CAPS_MMC_HIGHSPEED; + if (of_getprop_bool(sc->sc_phandle, "mmc-ddr-3_3v")) { + saa.saa_caps |= SMC_CAPS_MMC_DDR52; + } + if (of_getprop_bool(sc->sc_phandle, "mmc-ddr-1_8v")) { saa.saa_caps |= SMC_CAPS_MMC_DDR52; sc->sc_host_ocr |= MMC_OCR_1_65V_1_95V;
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Apr 21 12:36:39 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: Provide a separate ap_reset for Meson GX family SoCs To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_platform.c diff -u src/sys/arch/arm/amlogic/meson_platform.c:1.8 src/sys/arch/arm/amlogic/meson_platform.c:1.9 --- src/sys/arch/arm/amlogic/meson_platform.c:1.8 Fri Apr 19 19:07:56 2019 +++ src/sys/arch/arm/amlogic/meson_platform.c Sun Apr 21 12:36:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_platform.c,v 1.8 2019/04/19 19:07:56 jmcneill Exp $ */ +/* $NetBSD: meson_platform.c,v 1.9 2019/04/21 12:36:39 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -33,7 +33,7 @@ #include "arml2cc.h" #include -__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.8 2019/04/19 19:07:56 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.9 2019/04/21 12:36:39 jmcneill Exp $"); #include #include @@ -69,14 +69,23 @@ __KERNEL_RCSID(0, "$NetBSD: meson_platfo #define MESON_CBUS_OFFSET 0x0110 -#define MESON_WATCHDOG_BASE 0xc1109900 -#define MESON_WATCHDOG_SIZE 0x8 -#define MESON_WATCHDOG_TC 0x00 -#define WATCHDOG_TC_CPUS __BITS(27,24) -#define WATCHDOG_TC_ENABLE __BIT(19) -#define WATCHDOG_TC_TCNT __BITS(15,0) -#define MESON_WATCHDOG_RESET 0x04 -#define WATCHDOG_RESET_COUNT __BITS(15,0) +#define MESON8B_WATCHDOG_BASE 0xc1109900 +#define MESON8B_WATCHDOG_SIZE 0x8 +#define MESON8B_WATCHDOG_TC 0x00 +#define MESON8B_WATCHDOG_TC_CPUS __BITS(27,24) +#define MESON8B_WATCHDOG_TC_ENABLE __BIT(19) +#define MESON8B_WATCHDOG_TC_TCNT __BITS(15,0) +#define MESON8B_WATCHDOG_RESET 0x04 +#define MESON8B_WATCHDOG_RESET_COUNT __BITS(15,0) + +#define MESONGX_WATCHDOG_BASE 0xc11098d0 +#define MESONGX_WATCHDOG_SIZE 0x10 +#define MESONGX_WATCHDOG_CNTL 0x00 +#define MESONGX_WATCHDOG_CNTL_WDOG_EN __BIT(18) +#define MESONGX_WATCHDOG_CNTL1 0x04 +#define MESONGX_WATCHDOG_TCNT 0x08 +#define MESONGX_WATCHDOG_TCNT_COUNT __BITS(15,0) +#define MESONGX_WATCHDOG_RESET 0x0c #define MESON8B_ARM_VBASE (MESON_CORE_APB3_VBASE + MESON_CORE_APB3_SIZE) #define MESON8B_ARM_PBASE 0xc420 @@ -295,26 +304,24 @@ meson8b_platform_bootstrap(void) meson_platform_bootstrap(); } -#endif static void -meson_platform_reset(void) +meson8b_platform_reset(void) { bus_space_tag_t bst = _bs_tag; bus_space_handle_t bsh; - bus_space_map(bst, MESON_WATCHDOG_BASE, MESON_WATCHDOG_SIZE, 0, ); + bus_space_map(bst, MESON8B_WATCHDOG_BASE, MESON8B_WATCHDOG_SIZE, 0, ); - bus_space_write_4(bst, bsh, MESON_WATCHDOG_TC, - WATCHDOG_TC_CPUS | WATCHDOG_TC_ENABLE | __SHIFTIN(0xfff, WATCHDOG_TC_TCNT)); - bus_space_write_4(bst, bsh, MESON_WATCHDOG_RESET, 0); + bus_space_write_4(bst, bsh, MESON8B_WATCHDOG_TC, + MESON8B_WATCHDOG_TC_CPUS | MESON8B_WATCHDOG_TC_ENABLE | __SHIFTIN(0xfff, MESON8B_WATCHDOG_TC_TCNT)); + bus_space_write_4(bst, bsh, MESON8B_WATCHDOG_RESET, 0); for (;;) { __asm("wfi"); } } -#if defined(SOC_MESON8B) static void meson8b_mpinit_delay(u_int n) { @@ -433,7 +440,7 @@ meson8b_mpstart(void) } static const struct arm_platform meson8b_platform = { - .ap_devmap = meson_platform_devmap, + .ap_devmap = meson8b_platform_devmap, .ap_bootstrap = meson8b_platform_bootstrap, .ap_init_attach_args = meson_platform_init_attach_args, .ap_device_register = meson8b_platform_device_register, @@ -447,12 +454,34 @@ ARM_PLATFORM(meson8b, "amlogic,meson8b", #endif /* SOC_MESON8B */ #if defined(SOC_MESONGX) +static void +mesongx_platform_reset(void) +{ + bus_space_tag_t bst = _bs_tag; + bus_space_handle_t bsh; + uint32_t val; + + bus_space_map(bst, MESONGX_WATCHDOG_BASE, MESONGX_WATCHDOG_SIZE, 0, ); + + val = bus_space_read_4(bst, bsh, MESONGX_WATCHDOG_CNTL); + val |= MESONGX_WATCHDOG_CNTL_WDOG_EN; + bus_space_write_4(bst, bsh, MESONGX_WATCHDOG_CNTL, val); + + bus_space_write_4(bst, bsh, MESONGX_WATCHDOG_TCNT, 1); + + bus_space_write_4(bst, bsh, MESONGX_WATCHDOG_RESET, 0); + + for (;;) { + __asm("wfi"); + } +} + static const struct arm_platform mesongx_platform = { .ap_devmap = meson_platform_devmap, .ap_bootstrap = meson_platform_bootstrap, .ap_init_attach_args = meson_platform_init_attach_args, .ap_device_register = meson_platform_device_register, - .ap_reset = meson_platform_reset, + .ap_reset = mesongx_platform_reset, .ap_delay = gtmr_delay, .ap_uart_freq = meson_platform_uart_freq, .ap_mpstart = arm_fdt_cpu_mpstart,
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Apr 21 12:36:39 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: Provide a separate ap_reset for Meson GX family SoCs To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Fri Apr 5 12:11:26 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: files.meson Log Message: Add dependencies for mesonfb To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/amlogic/files.meson Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/files.meson diff -u src/sys/arch/arm/amlogic/files.meson:1.5 src/sys/arch/arm/amlogic/files.meson:1.6 --- src/sys/arch/arm/amlogic/files.meson:1.5 Mon Feb 25 19:30:17 2019 +++ src/sys/arch/arm/amlogic/files.meson Fri Apr 5 12:11:26 2019 @@ -1,4 +1,4 @@ -# $NetBSD: files.meson,v 1.5 2019/02/25 19:30:17 jmcneill Exp $ +# $NetBSD: files.meson,v 1.6 2019/04/05 12:11:26 jmcneill Exp $ # # Configuration info for Amlogic Meson family SoCs # @@ -43,7 +43,7 @@ attach mesonuart at fdt with meson_uart file arch/arm/amlogic/meson_uart.c meson_uart # Framebuffer console -device mesonfb +device mesonfb: genfb, wsemuldisplaydev attach mesonfb at fdt with meson_genfb file arch/arm/amlogic/meson_genfb.c meson_genfb & soc_meson
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Fri Apr 5 12:11:26 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: files.meson Log Message: Add dependencies for mesonfb To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/amlogic/files.meson Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Fri Apr 5 12:07:02 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: Fix AO base in cpu_enable_meson8b To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_platform.c diff -u src/sys/arch/arm/amlogic/meson_platform.c:1.6 src/sys/arch/arm/amlogic/meson_platform.c:1.7 --- src/sys/arch/arm/amlogic/meson_platform.c:1.6 Fri Apr 5 11:58:02 2019 +++ src/sys/arch/arm/amlogic/meson_platform.c Fri Apr 5 12:07:02 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_platform.c,v 1.6 2019/04/05 11:58:02 jmcneill Exp $ */ +/* $NetBSD: meson_platform.c,v 1.7 2019/04/05 12:07:02 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -33,7 +33,7 @@ #include "arml2cc.h" #include -__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.6 2019/04/05 11:58:02 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.7 2019/04/05 12:07:02 jmcneill Exp $"); #include #include @@ -87,6 +87,7 @@ __KERNEL_RCSID(0, "$NetBSD: meson_platfo #define MESON8B_AOBUS_VBASE (MESON8B_ARM_VBASE + MESON8B_ARM_SIZE) #define MESON8B_AOBUS_PBASE 0xc800 #define MESON8B_AOBUS_SIZE 0x0020 +#define MESON8B_AOBUS_RTI_OFFSET 0x0010 #define MESON_AOBUS_PWR_CTRL0_REG 0xe0 #define MESON_AOBUS_PWR_CTRL1_REG 0xe4 @@ -332,7 +333,7 @@ cpu_enable_meson8b(int phandle) const bus_space_handle_t cpuconf_bsh = MESON8B_SRAM_VBASE + MESON8B_SRAM_CPUCONF_OFFSET; const bus_space_handle_t ao_bsh = - MESON8B_AOBUS_VBASE; + MESON8B_AOBUS_VBASE + MESON8B_AOBUS_RTI_OFFSET; const bus_space_handle_t cbus_bsh = MESON_CORE_APB3_VBASE + MESON_CBUS_OFFSET; uint32_t pwr_sts, pwr_cntl0, pwr_cntl1, cpuclk, mempd0;
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Fri Apr 5 12:07:02 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: Fix AO base in cpu_enable_meson8b To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Fri Apr 5 11:58:02 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: #define To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_platform.c diff -u src/sys/arch/arm/amlogic/meson_platform.c:1.5 src/sys/arch/arm/amlogic/meson_platform.c:1.6 --- src/sys/arch/arm/amlogic/meson_platform.c:1.5 Mon Feb 25 19:30:17 2019 +++ src/sys/arch/arm/amlogic/meson_platform.c Fri Apr 5 11:58:02 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_platform.c,v 1.5 2019/02/25 19:30:17 jmcneill Exp $ */ +/* $NetBSD: meson_platform.c,v 1.6 2019/04/05 11:58:02 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -33,7 +33,7 @@ #include "arml2cc.h" #include -__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.5 2019/02/25 19:30:17 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.6 2019/04/05 11:58:02 jmcneill Exp $"); #include #include @@ -67,7 +67,7 @@ __KERNEL_RCSID(0, "$NetBSD: meson_platfo #define MESON_CORE_APB3_PBASE 0xc000 #define MESON_CORE_APB3_SIZE 0x0140 -#define MESON_CBUS_OFFSET 0x0110 +#define MESON_CBUS_OFFSET 0x0110 #define MESON_WATCHDOG_BASE 0xc1109900 #define MESON_WATCHDOG_SIZE 0x8 @@ -78,30 +78,30 @@ __KERNEL_RCSID(0, "$NetBSD: meson_platfo #define MESON_WATCHDOG_RESET 0x04 #define WATCHDOG_RESET_COUNT __BITS(15,0) -#define MESON8B_ARM_VBASE (MESON_CORE_APB3_VBASE + MESON_CORE_APB3_SIZE) +#define MESON8B_ARM_VBASE (MESON_CORE_APB3_VBASE + MESON_CORE_APB3_SIZE) #define MESON8B_ARM_PBASE 0xc420 -#define MESON8B_ARM_SIZE 0x0020 -#define MESON8B_ARM_PL310_BASE 0x -#define MESON8B_ARM_SCU_BASE 0x0010 +#define MESON8B_ARM_SIZE 0x0020 +#define MESON8B_ARM_PL310_BASE 0x +#define MESON8B_ARM_SCU_BASE 0x0010 -#define MESON8B_AOBUS_VBASE (MESON8B_ARM_VBASE + MESON8B_ARM_SIZE) +#define MESON8B_AOBUS_VBASE (MESON8B_ARM_VBASE + MESON8B_ARM_SIZE) #define MESON8B_AOBUS_PBASE 0xc800 -#define MESON8B_AOBUS_SIZE 0x0020 +#define MESON8B_AOBUS_SIZE 0x0020 -#define MESON_AOBUS_PWR_CTRL0_REG 0xe0 -#define MESON_AOBUS_PWR_CTRL1_REG 0xe4 -#define MESON_AOBUS_PWR_MEM_PD0_REG 0xf4 +#define MESON_AOBUS_PWR_CTRL0_REG 0xe0 +#define MESON_AOBUS_PWR_CTRL1_REG 0xe4 +#define MESON_AOBUS_PWR_MEM_PD0_REG 0xf4 -#define MESON_CBUS_CPU_CLK_CNTL_REG 0x419c +#define MESON_CBUS_CPU_CLK_CNTL_REG 0x419c -#define MESON8B_SRAM_VBASE (MESON8B_AOBUS_VBASE + MESON8B_AOBUS_SIZE) -#define MESON8B_SRAM_PBASE 0xd900 -#define MESON8B_SRAM_SIZE 0x0020 /* 0x1 rounded up */ +#define MESON8B_SRAM_VBASE (MESON8B_AOBUS_VBASE + MESON8B_AOBUS_SIZE) +#define MESON8B_SRAM_PBASE 0xd900 +#define MESON8B_SRAM_SIZE 0x0020 /* 0x1 rounded up */ -#define MESON8B_SRAM_CPUCONF_OFFSET 0x1ff80 -#define MESON8B_SRAM_CPUCONF_CTRL_REG 0x00 -#define MESON8B_SRAM_CPUCONF_CPU_ADDR_REG(n) (0x04 * (n)) +#define MESON8B_SRAM_CPUCONF_OFFSET 0x1ff80 +#define MESON8B_SRAM_CPUCONF_CTRL_REG 0x00 +#define MESON8B_SRAM_CPUCONF_CPU_ADDR_REG(n) (0x04 * (n)) extern struct arm32_bus_dma_tag arm_generic_dma_tag; @@ -148,7 +148,7 @@ void meson_platform_early_putchar(char c) { #ifdef CONSADDR -#define CONSADDR_VA ((CONSADDR - MESON8B_AOBUS_PBASE) + MESON8B_AOBUS_VBASE) +#define CONSADDR_VA ((CONSADDR - MESON8B_AOBUS_PBASE) + MESON8B_AOBUS_VBASE) volatile uint32_t *uartaddr = cpu_earlydevice_va_p() ? (volatile uint32_t *)CONSADDR_VA : (volatile uint32_t *)CONSADDR;
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Fri Apr 5 11:58:02 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: #define To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sat Mar 16 12:52:47 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: Disable multi-segment DMA as a workaround for init crashes on ODROID-C2 when using root on eMMC To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/mesongx_mmc.c diff -u src/sys/arch/arm/amlogic/mesongx_mmc.c:1.3 src/sys/arch/arm/amlogic/mesongx_mmc.c:1.4 --- src/sys/arch/arm/amlogic/mesongx_mmc.c:1.3 Fri Mar 15 11:45:17 2019 +++ src/sys/arch/arm/amlogic/mesongx_mmc.c Sat Mar 16 12:52:47 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: mesongx_mmc.c,v 1.3 2019/03/15 11:45:17 jmcneill Exp $ */ +/* $NetBSD: mesongx_mmc.c,v 1.4 2019/03/16 12:52:47 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.3 2019/03/15 11:45:17 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.4 2019/03/16 12:52:47 jmcneill Exp $"); #include #include @@ -526,8 +526,11 @@ mesongx_mmc_attach_i(device_t self) saa.saa_dmat = sc->sc_dmat; saa.saa_clkmin = SDMMC_SDCLK_400K; saa.saa_clkmax = sc->sc_max_frequency / 1000; - saa.saa_caps = SMC_CAPS_DMA | - SMC_CAPS_MULTI_SEG_DMA; + saa.saa_caps = SMC_CAPS_DMA; +#if notyet + /* XXX causes init to die when using root on eMMC with ODROID-C2 */ + saa.saa_caps |= SMC_CAPS_MULTI_SEG_DMA; +#endif sc->sc_host_ocr = MMC_OCR_3_2V_3_3V | MMC_OCR_3_3V_3_4V;
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sat Mar 16 12:52:47 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: Disable multi-segment DMA as a workaround for init crashes on ODROID-C2 when using root on eMMC To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Fri Mar 15 11:45:17 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: Fix SCF_RSP_R1B test To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Fri Mar 15 11:45:17 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: Fix SCF_RSP_R1B test To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/mesongx_mmc.c diff -u src/sys/arch/arm/amlogic/mesongx_mmc.c:1.2 src/sys/arch/arm/amlogic/mesongx_mmc.c:1.3 --- src/sys/arch/arm/amlogic/mesongx_mmc.c:1.2 Sun Mar 3 12:54:58 2019 +++ src/sys/arch/arm/amlogic/mesongx_mmc.c Fri Mar 15 11:45:17 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: mesongx_mmc.c,v 1.2 2019/03/03 12:54:58 jmcneill Exp $ */ +/* $NetBSD: mesongx_mmc.c,v 1.3 2019/03/15 11:45:17 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.2 2019/03/03 12:54:58 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.3 2019/03/15 11:45:17 jmcneill Exp $"); #include #include @@ -957,7 +957,7 @@ mesongx_mmc_exec_command(sdmmc_chipset_h cmdflags |= MESONGX_MMC_FLAGS_RESP_128; if ((cmd->c_flags & SCF_RSP_CRC) == 0) cmdflags |= MESONGX_MMC_FLAGS_RESP_NOCRC; - if (__SHIFTOUT(cmd->c_flags, SCF_RSP_MASK) == SCF_RSP_R1B) + if ((cmd->c_flags & SCF_RSP_MASK) == SCF_RSP_R1B) cmdflags |= MESONGX_MMC_FLAGS_R1B; }
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Mar 3 12:54:58 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: Reset device at attach and fix eMMC 1.8V flags To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/mesongx_mmc.c diff -u src/sys/arch/arm/amlogic/mesongx_mmc.c:1.1 src/sys/arch/arm/amlogic/mesongx_mmc.c:1.2 --- src/sys/arch/arm/amlogic/mesongx_mmc.c:1.1 Mon Feb 25 19:30:17 2019 +++ src/sys/arch/arm/amlogic/mesongx_mmc.c Sun Mar 3 12:54:58 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: mesongx_mmc.c,v 1.1 2019/02/25 19:30:17 jmcneill Exp $ */ +/* $NetBSD: mesongx_mmc.c,v 1.2 2019/03/03 12:54:58 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.1 2019/02/25 19:30:17 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mesongx_mmc.c,v 1.2 2019/03/03 12:54:58 jmcneill Exp $"); #include #include @@ -370,6 +370,9 @@ mesongx_mmc_attach(device_t parent, devi } aprint_normal_dev(self, "interrupting on %s\n", intrstr); + if (sc->sc_pwrseq) + fdtbus_mmc_pwrseq_reset(sc->sc_pwrseq); + config_interrupts(self, mesongx_mmc_attach_i); } @@ -535,15 +538,13 @@ mesongx_mmc_attach_i(device_t self) if (of_getprop_bool(sc->sc_phandle, "cap-mmc-highspeed")) saa.saa_caps |= SMC_CAPS_MMC_HIGHSPEED; - if (sc->sc_reg_vqmmc != NULL) { - if (of_getprop_bool(sc->sc_phandle, "mmc-ddr-1_8v")) { - saa.saa_caps |= SMC_CAPS_MMC_DDR52; - sc->sc_host_ocr |= MMC_OCR_S18A; - } - if (of_getprop_bool(sc->sc_phandle, "mmc-hs200-1_8v")) { - saa.saa_caps |= SMC_CAPS_MMC_HS200; - sc->sc_host_ocr |= MMC_OCR_S18A; - } + if (of_getprop_bool(sc->sc_phandle, "mmc-ddr-1_8v")) { + saa.saa_caps |= SMC_CAPS_MMC_DDR52; + sc->sc_host_ocr |= MMC_OCR_1_65V_1_95V; + } + if (of_getprop_bool(sc->sc_phandle, "mmc-hs200-1_8v")) { + saa.saa_caps |= SMC_CAPS_MMC_HS200; + sc->sc_host_ocr |= MMC_OCR_1_65V_1_95V; } if (width == 4)
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Mar 3 12:54:58 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: mesongx_mmc.c Log Message: Reset device at attach and fix eMMC 1.8V flags To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/mesongx_mmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sat Mar 2 12:24:44 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_dwmac.c Log Message: Setup RGMII mode for Meson DWMAC To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/amlogic/meson_dwmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sat Mar 2 12:24:44 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_dwmac.c Log Message: Setup RGMII mode for Meson DWMAC To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/amlogic/meson_dwmac.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_dwmac.c diff -u src/sys/arch/arm/amlogic/meson_dwmac.c:1.3 src/sys/arch/arm/amlogic/meson_dwmac.c:1.4 --- src/sys/arch/arm/amlogic/meson_dwmac.c:1.3 Mon Feb 25 19:30:17 2019 +++ src/sys/arch/arm/amlogic/meson_dwmac.c Sat Mar 2 12:24:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_dwmac.c,v 1.3 2019/02/25 19:30:17 jmcneill Exp $ */ +/* $NetBSD: meson_dwmac.c,v 1.4 2019/03/02 12:24:44 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.3 2019/02/25 19:30:17 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_dwmac.c,v 1.4 2019/03/02 12:24:44 jmcneill Exp $"); #include #include @@ -48,8 +48,12 @@ __KERNEL_RCSID(0, "$NetBSD: meson_dwmac. #include -#define GMAC_TX_RATE_MII 2500 -#define GMAC_TX_RATE_RGMII 12500 +#define PRG_ETHERNET_ADDR0 0x00 +#define CLKGEN_ENABLE __BIT(12) +#define PHY_CLK_ENABLE __BIT(10) +#define MP2_CLK_OUT_DIV __BITS(9,7) +#define TX_CLK_DELAY __BITS(6,5) +#define PHY_INTERFACE_SEL __BIT(0) static const char * compatible[] = { "amlogic,meson8b-dwmac", @@ -87,6 +91,29 @@ meson_dwmac_reset(const int phandle) return 0; } +static void +meson_dwmac_set_mode_rgmii(int phandle, bus_space_tag_t bst, +bus_space_handle_t bsh, struct clk *clkin) +{ + u_int tx_delay; + uint32_t val; + + const u_int div = clk_get_rate(clkin) / 25000; + + if (of_getprop_uint32(phandle, "amlogic,tx-delay-ns", _delay) != 0) + tx_delay = 2; + + val = bus_space_read_4(bst, bsh, PRG_ETHERNET_ADDR0); + val |= PHY_INTERFACE_SEL; + val &= ~TX_CLK_DELAY; + val |= __SHIFTIN((tx_delay >> 1), TX_CLK_DELAY); + val &= ~MP2_CLK_OUT_DIV; + val |= __SHIFTIN(div, MP2_CLK_OUT_DIV); + val |= PHY_CLK_ENABLE; + val |= CLKGEN_ENABLE; + bus_space_write_4(bst, bsh, PRG_ETHERNET_ADDR0, val); +} + static int meson_dwmac_intr(void *arg) { @@ -109,21 +136,24 @@ meson_dwmac_attach(device_t parent, devi struct dwc_gmac_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; const int phandle = faa->faa_phandle; + bus_space_handle_t prgeth_bsh; struct fdtbus_reset *rst_gmac; - struct clk *clk_gmac; + struct clk *clk_gmac, *clk_in[2]; const char *phy_mode; char intrstr[128]; - bus_addr_t addr; - bus_size_t size; + bus_addr_t addr[2]; + bus_size_t size[2]; - if (fdtbus_get_reg(phandle, 0, , ) != 0) { + if (fdtbus_get_reg(phandle, 0, [0], [0]) != 0 || + fdtbus_get_reg(phandle, 1, [1], [1]) != 0) { aprint_error(": couldn't get registers\n"); return; } sc->sc_dev = self; sc->sc_bst = faa->faa_bst; - if (bus_space_map(sc->sc_bst, addr, size, 0, >sc_bsh) != 0) { + if (bus_space_map(sc->sc_bst, addr[0], size[0], 0, >sc_bsh) != 0 || + bus_space_map(sc->sc_bst, addr[1], size[1], 0, _bsh) != 0) { aprint_error(": couldn't map registers\n"); return; } @@ -135,7 +165,9 @@ meson_dwmac_attach(device_t parent, devi } clk_gmac = fdtbus_clock_get(phandle, "stmmaceth"); - if (clk_gmac == NULL) { + clk_in[0] = fdtbus_clock_get(phandle, "clkin0"); + clk_in[1] = fdtbus_clock_get(phandle, "clkin1"); + if (clk_gmac == NULL || clk_in[0] == NULL || clk_in[1] == NULL) { aprint_error(": couldn't get clocks\n"); return; } @@ -147,22 +179,13 @@ meson_dwmac_attach(device_t parent, devi aprint_error(": missing 'phy-mode' property\n"); return; } -#if notyet - if (strcmp(phy_mode, "mii") == 0) { - if (clk_set_rate(clk_gmac_tx, GMAC_TX_RATE_MII) != 0) { - aprint_error(": failed to set TX clock rate (MII)\n"); - return; - } - } else if (strcmp(phy_mode, "rgmii") == 0) { - if (clk_set_rate(clk_gmac_tx, GMAC_TX_RATE_RGMII) != 0) { - aprint_error(": failed to set TX clock rate (RGMII)\n"); - return; - } + + if (strcmp(phy_mode, "rgmii") == 0) { + meson_dwmac_set_mode_rgmii(phandle, sc->sc_bst, prgeth_bsh, clk_in[0]); } else { aprint_error(": unsupported phy-mode '%s'\n", phy_mode); return; } -#endif if (clk_enable(clk_gmac) != 0) { aprint_error(": couldn't enable clock\n");
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sat Mar 2 11:15:55 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_pinctrl.c Log Message: When acquiring a GPIO, disable any conflicting pinctrl function groups To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/amlogic/meson_pinctrl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_pinctrl.c diff -u src/sys/arch/arm/amlogic/meson_pinctrl.c:1.3 src/sys/arch/arm/amlogic/meson_pinctrl.c:1.4 --- src/sys/arch/arm/amlogic/meson_pinctrl.c:1.3 Mon Feb 25 19:30:17 2019 +++ src/sys/arch/arm/amlogic/meson_pinctrl.c Sat Mar 2 11:15:55 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_pinctrl.c,v 1.3 2019/02/25 19:30:17 jmcneill Exp $ */ +/* $NetBSD: meson_pinctrl.c,v 1.4 2019/03/02 11:15:55 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared D. McNeill @@ -29,7 +29,7 @@ #include "opt_soc.h" #include -__KERNEL_RCSID(0, "$NetBSD: meson_pinctrl.c,v 1.3 2019/02/25 19:30:17 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_pinctrl.c,v 1.4 2019/03/02 11:15:55 jmcneill Exp $"); #include #include @@ -321,8 +321,10 @@ meson_pinctrl_gpio_acquire(device_t dev, { struct meson_pinctrl_softc * const sc = device_private(dev); const struct meson_pinctrl_gpio *pin_def; + const struct meson_pinctrl_group *group; struct meson_pinctrl_gpio_pin *gpin; const u_int *gpio = data; + u_int n, bank; if (len != 12) return NULL; @@ -334,6 +336,15 @@ meson_pinctrl_gpio_acquire(device_t dev, if (pin_def == NULL) return NULL; + /* Disable conflicting groups */ + for (n = 0; n < sc->sc_conf->ngroups; n++) { + group = >sc_conf->groups[n]; + for (bank = 0; bank < group->nbank; bank++) { + if (group->bank[bank] == pin_def->id) +meson_pinctrl_set_group(sc, group, false); + } + } + mutex_enter(>sc_lock); meson_pinctrl_pin_dir(sc, pin_def, flags); mutex_exit(>sc_lock);
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sat Mar 2 11:15:55 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_pinctrl.c Log Message: When acquiring a GPIO, disable any conflicting pinctrl function groups To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/amlogic/meson_pinctrl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Tue Feb 26 21:55:28 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: mesongxbb_pinctrl.c Log Message: Fix GPIOH pin groups and add GPIOY To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/mesongxbb_pinctrl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/mesongxbb_pinctrl.c diff -u src/sys/arch/arm/amlogic/mesongxbb_pinctrl.c:1.1 src/sys/arch/arm/amlogic/mesongxbb_pinctrl.c:1.2 --- src/sys/arch/arm/amlogic/mesongxbb_pinctrl.c:1.1 Mon Feb 25 19:30:17 2019 +++ src/sys/arch/arm/amlogic/mesongxbb_pinctrl.c Tue Feb 26 21:55:28 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: mesongxbb_pinctrl.c,v 1.1 2019/02/25 19:30:17 jmcneill Exp $ */ +/* $NetBSD: mesongxbb_pinctrl.c,v 1.2 2019/02/26 21:55:28 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mesongxbb_pinctrl.c,v 1.1 2019/02/25 19:30:17 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mesongxbb_pinctrl.c,v 1.2 2019/02/26 21:55:28 jmcneill Exp $"); #include @@ -255,11 +255,30 @@ static const struct meson_pinctrl_gpio m CBUS_GPIO(GPIODV_21, 0, 21), CBUS_GPIO(GPIODV_22, 0, 22), + /* GPIOY */ + CBUS_GPIO(GPIOY_0, 1, 0), + CBUS_GPIO(GPIOY_1, 1, 1), + CBUS_GPIO(GPIOY_2, 1, 2), + CBUS_GPIO(GPIOY_3, 1, 3), + CBUS_GPIO(GPIOY_4, 1, 4), + CBUS_GPIO(GPIOY_5, 1, 5), + CBUS_GPIO(GPIOY_6, 1, 6), + CBUS_GPIO(GPIOY_7, 1, 7), + CBUS_GPIO(GPIOY_8, 1, 8), + CBUS_GPIO(GPIOY_9, 1, 9), + CBUS_GPIO(GPIOY_10, 1, 10), + CBUS_GPIO(GPIOY_11, 1, 11), + CBUS_GPIO(GPIOY_12, 1, 12), + CBUS_GPIO(GPIOY_13, 1, 13), + CBUS_GPIO(GPIOY_14, 1, 14), + CBUS_GPIO(GPIOY_15, 1, 15), + CBUS_GPIO(GPIOY_16, 1, 16), + /* GPIOH */ - CBUS_GPIO(GPIOH_0, 1, 0), - CBUS_GPIO(GPIOH_1, 1, 1), - CBUS_GPIO(GPIOH_2, 1, 2), - CBUS_GPIO(GPIOH_3, 1, 3), + CBUS_GPIO(GPIOH_0, 1, 20), + CBUS_GPIO(GPIOH_1, 1, 21), + CBUS_GPIO(GPIOH_2, 1, 22), + CBUS_GPIO(GPIOH_3, 1, 23), /* BOOT */ CBUS_GPIO(BOOT_0, 2, 0),
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Tue Feb 26 21:55:28 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: mesongxbb_pinctrl.c Log Message: Fix GPIOH pin groups and add GPIOY To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/mesongxbb_pinctrl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Mon Jan 21 16:27:48 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: Auto-detect root device on Meson8b To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_platform.c diff -u src/sys/arch/arm/amlogic/meson_platform.c:1.2 src/sys/arch/arm/amlogic/meson_platform.c:1.3 --- src/sys/arch/arm/amlogic/meson_platform.c:1.2 Sun Jan 20 16:02:32 2019 +++ src/sys/arch/arm/amlogic/meson_platform.c Mon Jan 21 16:27:48 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_platform.c,v 1.2 2019/01/20 16:02:32 jmcneill Exp $ */ +/* $NetBSD: meson_platform.c,v 1.3 2019/01/21 16:27:48 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -33,7 +33,7 @@ #include "arml2cc.h" #include -__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.2 2019/01/20 16:02:32 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.3 2019/01/21 16:27:48 jmcneill Exp $"); #include #include @@ -197,6 +197,57 @@ meson_platform_device_register(device_t } } +#if defined(SOC_MESON8B) +#define MESON8B_BOOTINFO_REG 0xd901ff04 +static int +meson8b_get_boot_id(void) +{ + static int boot_id = -1; + bus_space_tag_t bst = _generic_bs_tag; + bus_space_handle_t bsh; + + if (boot_id == -1) { + if (bus_space_map(bst, MESON8B_BOOTINFO_REG, 4, 0, ) != 0) + return -1; + + boot_id = (int)bus_space_read_4(bst, bsh, 0); + + bus_space_unmap(bst, bsh, 4); + } + + return boot_id; +} + +static void +meson8b_platform_device_register(device_t self, void *aux) +{ + device_t parent = device_parent(self); + char *ptr; + + if (device_is_a(self, "ld") && + device_is_a(parent, "sdmmc") && + (device_is_a(device_parent(parent), "mesonsdhc") || + device_is_a(device_parent(parent), "mesonsdio"))) { + + const int boot_id = meson8b_get_boot_id(); + const bool has_rootdev = get_bootconf_option(boot_args, "root", BOOTOPT_TYPE_STRING, ) != 0; + + if (!has_rootdev) { + char rootarg[64]; + snprintf(rootarg, sizeof(rootarg), " root=%sa", device_xname(self)); + + /* Assume that SDIO is used for SD cards and SDHC is used for eMMC */ + if (device_is_a(device_parent(parent), "mesonsdhc") && boot_id == 0) +strcat(boot_args, rootarg); + else if (device_is_a(device_parent(parent), "mesonsdio") && boot_id != 0) +strcat(boot_args, rootarg); + } + } + + meson_platform_device_register(self, aux); +} +#endif + static u_int meson_platform_uart_freq(void) { @@ -386,7 +437,7 @@ static const struct arm_platform meson8b .ap_devmap = meson_platform_devmap, .ap_bootstrap = meson8b_platform_bootstrap, .ap_init_attach_args = meson_platform_init_attach_args, - .ap_device_register = meson_platform_device_register, + .ap_device_register = meson8b_platform_device_register, .ap_reset = meson_platform_reset, .ap_delay = a9tmr_delay, .ap_uart_freq = meson_platform_uart_freq,
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Mon Jan 21 16:27:48 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: Auto-detect root device on Meson8b To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 20:22:13 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_rtc.c Log Message: todr_attach -> fdtbus_todr_attach To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson_rtc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 20:22:13 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_rtc.c Log Message: todr_attach -> fdtbus_todr_attach To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson_rtc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_rtc.c diff -u src/sys/arch/arm/amlogic/meson_rtc.c:1.1 src/sys/arch/arm/amlogic/meson_rtc.c:1.2 --- src/sys/arch/arm/amlogic/meson_rtc.c:1.1 Sun Jan 20 17:58:22 2019 +++ src/sys/arch/arm/amlogic/meson_rtc.c Sun Jan 20 20:22:13 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_rtc.c,v 1.1 2019/01/20 17:58:22 jmcneill Exp $ */ +/* $NetBSD: meson_rtc.c,v 1.2 2019/01/20 20:22:13 jmcneill Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: meson_rtc.c,v 1.1 2019/01/20 17:58:22 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_rtc.c,v 1.2 2019/01/20 20:22:13 jmcneill Exp $"); #include #include @@ -149,7 +149,7 @@ meson_rtc_attach(device_t parent, device aprint_normal(" battery not present or discharged\n"); } else { aprint_normal("\n"); - todr_attach(>sc_todr); + fdtbus_todr_attach(self, phandle, >sc_todr); } }
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 17:58:22 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: files.meson Added Files: src/sys/arch/arm/amlogic: meson_rtc.c meson_rtcreg.h Log Message: Add Amlogic Meson RTC driver (FDT version) To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/amlogic/files.meson cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/amlogic/meson_rtc.c \ src/sys/arch/arm/amlogic/meson_rtcreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/files.meson diff -u src/sys/arch/arm/amlogic/files.meson:1.3 src/sys/arch/arm/amlogic/files.meson:1.4 --- src/sys/arch/arm/amlogic/files.meson:1.3 Sun Jan 20 00:44:01 2019 +++ src/sys/arch/arm/amlogic/files.meson Sun Jan 20 17:58:22 2019 @@ -1,4 +1,4 @@ -# $NetBSD: files.meson,v 1.3 2019/01/20 00:44:01 jmcneill Exp $ +# $NetBSD: files.meson,v 1.4 2019/01/20 17:58:22 jmcneill Exp $ # # Configuration info for Amlogic Meson family SoCs # @@ -58,9 +58,9 @@ attach mesonusbphy at fdt with meson_usb file arch/arm/amlogic/meson_usbphy.c meson_usbphy # RTC -#device mesonrtc -#attach mesonrtc at fdt with meson_rtc -#file arch/arm/amlogic/meson_rtc.c meson_rtc +device mesonrtc +attach mesonrtc at fdt with meson_rtc +file arch/arm/amlogic/meson_rtc.c meson_rtc # RNG device mesonrng Added files: Index: src/sys/arch/arm/amlogic/meson_rtc.c diff -u /dev/null src/sys/arch/arm/amlogic/meson_rtc.c:1.1 --- /dev/null Sun Jan 20 17:58:22 2019 +++ src/sys/arch/arm/amlogic/meson_rtc.c Sun Jan 20 17:58:22 2019 @@ -0,0 +1,386 @@ +/* $NetBSD: meson_rtc.c,v 1.1 2019/01/20 17:58:22 jmcneill Exp $ */ + +/*- + * Copyright (c) 2015 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: meson_rtc.c,v 1.1 2019/01/20 17:58:22 jmcneill Exp $"); + +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#define RESET_RETRY_TIMES 3 +#define RTC_COMM_DELAY 5 +#define RTC_RESET_DELAY 100 +#define RTC_STATIC_VALUE_INIT 0x180a /* XXX: MAGIC? */ + +struct meson_rtc_softc { + device_t sc_dev; + bus_space_tag_t sc_bst; + bus_space_handle_t sc_bsh; + struct todr_chip_handle sc_todr; + int sc_osc_failed; + unsigned int sc_busy; +}; + +static const char * const compatible[] = { + "amlogic,meson8b-rtc", + NULL +}; + +static int meson_rtc_match(device_t, cfdata_t, void *); +static void meson_rtc_attach(device_t, device_t, void *); +static int meson_rtc_todr_gettime(todr_chip_handle_t, struct timeval *); +static int meson_rtc_todr_settime(todr_chip_handle_t, struct timeval *); + +CFATTACH_DECL_NEW(meson_rtc, sizeof(struct meson_rtc_softc), + meson_rtc_match, meson_rtc_attach, NULL, NULL); + +#define RTC_WRITE(sc, reg, val) \ + bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val)) +#define RTC_READ(sc, reg) \ + bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg)) + +static inline void +setbits(struct meson_rtc_softc *sc, uint32_t reg, uint32_t bits) +{ + + RTC_WRITE(sc, reg, RTC_READ(sc, reg) | bits); +} + +static inline void +clrbits(struct meson_rtc_softc *sc, uint32_t reg, uint32_t bits) +{ + + RTC_WRITE(sc, reg, RTC_READ(sc, reg) & ~bits); +} + +static int +meson_rtc_check_osc_clk(struct meson_rtc_softc *sc) +{ + uint32_t cnt1, cnt2; + + setbits(sc, AO_RTC_REG3, AO_RTC_REG3_COUNT_ALWAYS); + + /* + * Wait for 50uS. 32.768khz is 30.5uS. This should be long + * enough for one full cycle of 32.768 khz. + */ + cnt1 = RTC_READ(sc, AO_RTC_REG2); + delay(50); + cnt2 = RTC_READ(sc, AO_RTC_REG2); + +
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 17:58:22 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: files.meson Added Files: src/sys/arch/arm/amlogic: meson_rtc.c meson_rtcreg.h Log Message: Add Amlogic Meson RTC driver (FDT version) To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/amlogic/files.meson cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/amlogic/meson_rtc.c \ src/sys/arch/arm/amlogic/meson_rtcreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 17:28:00 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_clk.h Log Message: Add CLK_SET_RATE_PARENT for mux clocks and add MESON_CLK_PLL_RATE which is like MESON_CLK_PLL but accepts a custom set_rate function To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson_clk.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 17:28:34 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson8b_clkc.c Log Message: Add support for changing CPU frequency To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson8b_clkc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson8b_clkc.c diff -u src/sys/arch/arm/amlogic/meson8b_clkc.c:1.1 src/sys/arch/arm/amlogic/meson8b_clkc.c:1.2 --- src/sys/arch/arm/amlogic/meson8b_clkc.c:1.1 Sat Jan 19 20:56:03 2019 +++ src/sys/arch/arm/amlogic/meson8b_clkc.c Sun Jan 20 17:28:34 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson8b_clkc.c,v 1.1 2019/01/19 20:56:03 jmcneill Exp $ */ +/* $NetBSD: meson8b_clkc.c,v 1.2 2019/01/20 17:28:34 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: meson8b_clkc.c,v 1.1 2019/01/19 20:56:03 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: meson8b_clkc.c,v 1.2 2019/01/20 17:28:34 jmcneill Exp $"); #include #include @@ -54,6 +54,9 @@ __KERNEL_RCSID(1, "$NetBSD: meson8b_clkc #define HHI_SYS_CPU_CLK_CNTL1 CBUS_REG(0x57) #define HHI_MPEG_CLK_CNTL CBUS_REG(0x5d) #define HHI_SYS_CPU_CLK_CNTL0 CBUS_REG(0x67) +#define HHI_SYS_CPU_CLK_CNTL0_CLKSEL __BIT(7) +#define HHI_SYS_CPU_CLK_CNTL0_SOUTSEL __BITS(3,2) +#define HHI_SYS_CPU_CLK_CNTL0_PLLSEL __BITS(1,0) #define HHI_MPLL_CNTL CBUS_REG(0xa0) #define HHI_MPLL_CNTL2 CBUS_REG(0xa1) #define HHI_MPLL_CNTL5 CBUS_REG(0xa4) @@ -62,6 +65,10 @@ __KERNEL_RCSID(1, "$NetBSD: meson8b_clkc #define HHI_MPLL_CNTL8 CBUS_REG(0xa7) #define HHI_MPLL_CNTL9 CBUS_REG(0xa8) #define HHI_SYS_PLL_CNTL CBUS_REG(0xc0) +#define HHI_SYS_PLL_CNTL_LOCK __BIT(31) +#define HHI_SYS_PLL_CNTL_OD __BITS(17,16) +#define HHI_SYS_PLL_CNTL_DIV __BITS(14,9) +#define HHI_SYS_PLL_CNTL_MUL __BITS(8,0) static int meson8b_clkc_match(device_t, cfdata_t, void *); static void meson8b_clkc_attach(device_t, device_t, void *); @@ -87,23 +94,92 @@ static const char *cpu_scale_out_sel_par static const char *cpu_clk_parents[] = { "xtal", "cpu_scale_out_sel" }; static const char *periph_clk_sel_parents[] = { "cpu_clk_div2", "cpu_clk_div3", "cpu_clk_div4", "cpu_clk_div5", "cpu_clk_div6", "cpu_clk_div7", "cpu_clk_div8" }; +static int +meson8b_clkc_pll_sys_set_rate(struct meson_clk_softc *sc, +struct meson_clk_clk *clk, u_int rate) +{ + struct clk *clkp, *clkp_parent; + + KASSERT(clk->type == MESON_CLK_PLL); + + clkp = >base; + clkp_parent = clk_get_parent(clkp); + if (clkp_parent == NULL) + return ENXIO; + + const u_int old_rate = clk_get_rate(clkp); + if (old_rate == rate) + return 0; + + const u_int parent_rate = clk_get_rate(clkp_parent); + if (parent_rate == 0) + return EIO; + + uint32_t cntl0 = CLK_READ(sc, HHI_SYS_CPU_CLK_CNTL0); + uint32_t cntl = CLK_READ(sc, HHI_SYS_PLL_CNTL); + + u_int new_mul = rate / parent_rate; + u_int new_div = 1; + u_int new_od = 0; + + if (rate < 600 * 100) { + new_od = 2; + new_mul *= 4; + } else if (rate < 1200 * 100) { + new_od = 1; + new_mul *= 2; + } + + if ((cntl0 & HHI_SYS_CPU_CLK_CNTL0_CLKSEL) == 0) + return EIO; + if (__SHIFTOUT(cntl0, HHI_SYS_CPU_CLK_CNTL0_PLLSEL) != 1) + return EIO; + if (__SHIFTOUT(cntl0, HHI_SYS_CPU_CLK_CNTL0_SOUTSEL) != 0) + return EIO; + + cntl &= ~HHI_SYS_PLL_CNTL_MUL; + cntl |= __SHIFTIN(new_mul, HHI_SYS_PLL_CNTL_MUL); + cntl &= ~HHI_SYS_PLL_CNTL_DIV; + cntl |= __SHIFTIN(new_div, HHI_SYS_PLL_CNTL_DIV); + cntl &= ~HHI_SYS_PLL_CNTL_OD; + cntl |= __SHIFTIN(new_od, HHI_SYS_PLL_CNTL_OD); + + /* Switch CPU to XTAL clock */ + cntl0 &= ~HHI_SYS_CPU_CLK_CNTL0_CLKSEL; + CLK_WRITE(sc, HHI_SYS_CPU_CLK_CNTL0, cntl0); + + delay((100 * old_rate) / parent_rate); + + /* Update multiplier */ + do { + CLK_WRITE(sc, HHI_SYS_PLL_CNTL, cntl); + + /* Switch CPU to sys pll */ + cntl0 |= HHI_SYS_CPU_CLK_CNTL0_CLKSEL; + CLK_WRITE(sc, HHI_SYS_CPU_CLK_CNTL0, cntl0); + } while ((CLK_READ(sc, HHI_SYS_PLL_CNTL) & HHI_SYS_PLL_CNTL_LOCK) == 0); + + return 0; +} + static struct meson_clk_clk meson8b_clkc_clks[] = { MESON_CLK_FIXED(MESON8B_CLOCK_XTAL, "xtal", 2400), - MESON_CLK_PLL(MESON8B_CLOCK_PLL_SYS_DCO, "pll_sys_dco", "xtal", + MESON_CLK_PLL_RATE(MESON8B_CLOCK_PLL_SYS_DCO, "pll_sys_dco", "xtal", MESON_CLK_PLL_REG(HHI_SYS_PLL_CNTL, __BIT(30)), /* enable */ MESON_CLK_PLL_REG(HHI_SYS_PLL_CNTL, __BITS(8,0)), /* m */ MESON_CLK_PLL_REG(HHI_SYS_PLL_CNTL, __BITS(13,9)), /* n */ MESON_CLK_PLL_REG_INVALID,/* frac */ MESON_CLK_PLL_REG(HHI_SYS_PLL_CNTL, __BIT(31)), /* l */ MESON_CLK_PLL_REG(HHI_SYS_PLL_CNTL, __BIT(29)), /* reset */ + meson8b_clkc_pll_sys_set_rate, 0), MESON_CLK_DIV(MESON8B_CLOCK_PLL_SYS, "sys_pll", "pll_sys_dco", HHI_SYS_PLL_CNTL, /* reg */ __BITS(17,16), /* div */ - MESON_CLK_DIV_POWER_OF_TWO), +
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 17:28:00 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_clk.h Log Message: Add CLK_SET_RATE_PARENT for mux clocks and add MESON_CLK_PLL_RATE which is like MESON_CLK_PLL but accepts a custom set_rate function To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson_clk.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_clk.h diff -u src/sys/arch/arm/amlogic/meson_clk.h:1.1 src/sys/arch/arm/amlogic/meson_clk.h:1.2 --- src/sys/arch/arm/amlogic/meson_clk.h:1.1 Sat Jan 19 20:56:03 2019 +++ src/sys/arch/arm/amlogic/meson_clk.h Sun Jan 20 17:28:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_clk.h,v 1.1 2019/01/19 20:56:03 jmcneill Exp $ */ +/* $NetBSD: meson_clk.h,v 1.2 2019/01/20 17:28:00 jmcneill Exp $ */ /*- * Copyright (c) 2017-2019 Jared McNeill @@ -199,6 +199,7 @@ const char *meson_clk_mux_get_parent(str [_id] = { \ .type = MESON_CLK_MUX, \ .base.name = (_name), \ + .base.flags = CLK_SET_RATE_PARENT, \ .u.mux.parents = (_parents),\ .u.mux.nparents = __arraycount(_parents), \ .u.mux.reg = (_reg), \ @@ -236,6 +237,24 @@ u_int meson_clk_pll_get_rate(struct meso const char *meson_clk_pll_get_parent(struct meson_clk_softc *, struct meson_clk_clk *); +#define MESON_CLK_PLL_RATE(_id, _name, _parent, _enable, _m, _n, _frac, _l, \ + _reset, _setratefn, _flags) \ + [_id] = { \ + .type = MESON_CLK_PLL, \ + .base.name = (_name), \ + .u.pll.parent = (_parent),\ + .u.pll.enable = _enable,\ + .u.pll.m = _m, \ + .u.pll.n = _n, \ + .u.pll.frac = _frac, \ + .u.pll.l = _l, \ + .u.pll.reset = _reset, \ + .u.pll.flags = (_flags),\ + .set_rate = (_setratefn),\ + .get_rate = meson_clk_pll_get_rate, \ + .get_parent = meson_clk_pll_get_parent, \ + } + #define MESON_CLK_PLL(_id, _name, _parent, _enable, _m, _n, _frac, _l, \ _reset, _flags) \ [_id] = { \
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 17:28:34 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson8b_clkc.c Log Message: Add support for changing CPU frequency To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson8b_clkc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 17:27:30 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_clk_div.c Log Message: Always honour MESON_CLK_DIV_SET_RATE_PARENT To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson_clk_div.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 17:27:30 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_clk_div.c Log Message: Always honour MESON_CLK_DIV_SET_RATE_PARENT To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson_clk_div.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_clk_div.c diff -u src/sys/arch/arm/amlogic/meson_clk_div.c:1.1 src/sys/arch/arm/amlogic/meson_clk_div.c:1.2 --- src/sys/arch/arm/amlogic/meson_clk_div.c:1.1 Sat Jan 19 20:56:03 2019 +++ src/sys/arch/arm/amlogic/meson_clk_div.c Sun Jan 20 17:27:30 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_clk_div.c,v 1.1 2019/01/19 20:56:03 jmcneill Exp $ */ +/* $NetBSD: meson_clk_div.c,v 1.2 2019/01/20 17:27:30 jmcneill Exp $ */ /*- * Copyright (c) 2017-2019 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: meson_clk_div.c,v 1.1 2019/01/19 20:56:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_clk_div.c,v 1.2 2019/01/20 17:27:30 jmcneill Exp $"); #include #include @@ -90,12 +90,11 @@ meson_clk_div_set_rate(struct meson_clk_ if (clkp_parent == NULL) return ENXIO; - if (div->div == 0) { - if ((div->flags & MESON_CLK_DIV_SET_RATE_PARENT) != 0) - return clk_set_rate(clkp_parent, new_rate); - else - return ENXIO; - } + if ((div->flags & MESON_CLK_DIV_SET_RATE_PARENT) != 0) + return clk_set_rate(clkp_parent, new_rate); + + if (div->div == 0) + return ENXIO; val = CLK_READ(sc, div->reg);
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 16:02:33 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: Re-add support for awge0.mac-address, fb.scale, and fb.depth cmdline options To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_platform.c diff -u src/sys/arch/arm/amlogic/meson_platform.c:1.1 src/sys/arch/arm/amlogic/meson_platform.c:1.2 --- src/sys/arch/arm/amlogic/meson_platform.c:1.1 Sat Jan 19 20:56:03 2019 +++ src/sys/arch/arm/amlogic/meson_platform.c Sun Jan 20 16:02:32 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_platform.c,v 1.1 2019/01/19 20:56:03 jmcneill Exp $ */ +/* $NetBSD: meson_platform.c,v 1.2 2019/01/20 16:02:32 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -33,7 +33,7 @@ #include "arml2cc.h" #include -__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.1 2019/01/19 20:56:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: meson_platform.c,v 1.2 2019/01/20 16:02:32 jmcneill Exp $"); #include #include @@ -58,6 +58,8 @@ __KERNEL_RCSID(0, "$NetBSD: meson_platfo #include #include +#include + #include #define MESON_CORE_APB3_VBASE KERNEL_IO_VBASE @@ -168,6 +170,31 @@ meson_platform_early_putchar(char c) static void meson_platform_device_register(device_t self, void *aux) { + prop_dictionary_t dict = device_properties(self); + + if (device_is_a(self, "awge") && device_unit(self) == 0) { + uint8_t enaddr[ETHER_ADDR_LEN]; + if (get_bootconf_option(boot_args, "awge0.mac-address", + BOOTOPT_TYPE_MACADDR, enaddr)) { + prop_data_t pd = prop_data_create_data(enaddr, + sizeof(enaddr)); + prop_dictionary_set(dict, "mac-address", pd); + prop_object_release(pd); + } + } + + if (device_is_a(self, "genfb")) { + int scale, depth; + + if (get_bootconf_option(boot_args, "fb.scale", + BOOTOPT_TYPE_INT, ) && scale > 0) { + prop_dictionary_set_uint32(dict, "scale", scale); + } + if (get_bootconf_option(boot_args, "fb.depth", + BOOTOPT_TYPE_INT, )) { + prop_dictionary_set_uint32(dict, "depth", depth); + } + } } static u_int
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 16:02:33 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_platform.c Log Message: Re-add support for awge0.mac-address, fb.scale, and fb.depth cmdline options To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson_platform.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 15:56:40 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_uart.c Log Message: Only enable RX interrupts if the device is open. Previously interrupts were enabled unconditionally, which caused the interrupt handler to consume input before WSDISPLAY_MULTICONS had a change to poll for data. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson_uart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 15:56:40 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: meson_uart.c Log Message: Only enable RX interrupts if the device is open. Previously interrupts were enabled unconditionally, which caused the interrupt handler to consume input before WSDISPLAY_MULTICONS had a change to poll for data. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/meson_uart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/meson_uart.c diff -u src/sys/arch/arm/amlogic/meson_uart.c:1.1 src/sys/arch/arm/amlogic/meson_uart.c:1.2 --- src/sys/arch/arm/amlogic/meson_uart.c:1.1 Sat Jan 19 20:56:03 2019 +++ src/sys/arch/arm/amlogic/meson_uart.c Sun Jan 20 15:56:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: meson_uart.c,v 1.1 2019/01/19 20:56:03 jmcneill Exp $ */ +/* $NetBSD: meson_uart.c,v 1.2 2019/01/20 15:56:40 jmcneill Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ #include -__KERNEL_RCSID(1, "$NetBSD: meson_uart.c,v 1.1 2019/01/19 20:56:03 jmcneill Exp $"); +__KERNEL_RCSID(1, "$NetBSD: meson_uart.c,v 1.2 2019/01/20 15:56:40 jmcneill Exp $"); #define cn_trap() \ do {\ @@ -226,8 +226,7 @@ meson_uart_attach(device_t parent, devic bus_space_write_4(sc->sc_bst, sc->sc_bsh, UART_MISC_REG, misc); control = bus_space_read_4(sc->sc_bst, sc->sc_bsh, UART_CONTROL_REG); - control &= ~UART_CONTROL_TX_INT_EN; - control |= UART_CONTROL_RX_INT_EN; + control &= ~(UART_CONTROL_TX_INT_EN|UART_CONTROL_RX_INT_EN); bus_space_write_4(sc->sc_bst, sc->sc_bsh, UART_CONTROL_REG, control); } @@ -291,6 +290,7 @@ meson_uart_open(dev_t dev, int flag, int struct meson_uart_softc *sc = device_lookup_private(_cd, minor(dev)); struct tty *tp = sc->sc_tty; + uint32_t control; if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp) != 0) { @@ -306,6 +306,10 @@ meson_uart_open(dev_t dev, int flag, int tp->t_lflag = TTYDEF_LFLAG; tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; ttsetwater(tp); + + control = bus_space_read_4(sc->sc_bst, sc->sc_bsh, UART_CONTROL_REG); + control |= UART_CONTROL_RX_INT_EN; + bus_space_write_4(sc->sc_bst, sc->sc_bsh, UART_CONTROL_REG, control); } tp->t_state |= TS_CARR_ON; @@ -318,10 +322,17 @@ meson_uart_close(dev_t dev, int flag, in struct meson_uart_softc *sc = device_lookup_private(_cd, minor(dev)); struct tty *tp = sc->sc_tty; + uint32_t control; tp->t_linesw->l_close(tp, flag); ttyclose(tp); + if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) { + control = bus_space_read_4(sc->sc_bst, sc->sc_bsh, UART_CONTROL_REG); + control &= ~UART_CONTROL_RX_INT_EN; + bus_space_write_4(sc->sc_bst, sc->sc_bsh, UART_CONTROL_REG, control); + } + return 0; }
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 13:07:28 UTC 2019 Removed Files: src/sys/arch/arm/amlogic: files.amlogic Log Message: Remove unused file. To generate a diff of this commit: cvs rdiff -u -r1.14 -r0 src/sys/arch/arm/amlogic/files.amlogic Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Jan 20 13:07:28 UTC 2019 Removed Files: src/sys/arch/arm/amlogic: files.amlogic Log Message: Remove unused file. To generate a diff of this commit: cvs rdiff -u -r1.14 -r0 src/sys/arch/arm/amlogic/files.amlogic Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sat Jan 19 21:43:43 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: files.meson Added Files: src/sys/arch/arm/amlogic: meson_canvasreg.h meson_genfb.c meson_hdmireg.h meson_vpureg.h Log Message: Add Meson (FDT) framebuffer support. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/files.meson cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/amlogic/meson_canvasreg.h \ src/sys/arch/arm/amlogic/meson_genfb.c \ src/sys/arch/arm/amlogic/meson_hdmireg.h \ src/sys/arch/arm/amlogic/meson_vpureg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sat Jan 19 21:43:43 UTC 2019 Modified Files: src/sys/arch/arm/amlogic: files.meson Added Files: src/sys/arch/arm/amlogic: meson_canvasreg.h meson_genfb.c meson_hdmireg.h meson_vpureg.h Log Message: Add Meson (FDT) framebuffer support. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/amlogic/files.meson cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/amlogic/meson_canvasreg.h \ src/sys/arch/arm/amlogic/meson_genfb.c \ src/sys/arch/arm/amlogic/meson_hdmireg.h \ src/sys/arch/arm/amlogic/meson_vpureg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/files.meson diff -u src/sys/arch/arm/amlogic/files.meson:1.1 src/sys/arch/arm/amlogic/files.meson:1.2 --- src/sys/arch/arm/amlogic/files.meson:1.1 Sat Jan 19 20:56:03 2019 +++ src/sys/arch/arm/amlogic/files.meson Sat Jan 19 21:43:43 2019 @@ -1,4 +1,4 @@ -# $NetBSD: files.meson,v 1.1 2019/01/19 20:56:03 jmcneill Exp $ +# $NetBSD: files.meson,v 1.2 2019/01/19 21:43:43 jmcneill Exp $ # # Configuration info for Amlogic Meson family SoCs # @@ -32,6 +32,10 @@ device mesonuart attach mesonuart at fdt with meson_uart file arch/arm/amlogic/meson_uart.c meson_uart +# Framebuffer console +attach genfb at fdt with meson_genfb +file arch/arm/amlogic/meson_genfb.c meson_genfb & soc_meson + # GPIO device mesonpinctrl: gpiobus attach mesonpinctrl at fdt with meson_pinctrl Added files: Index: src/sys/arch/arm/amlogic/meson_canvasreg.h diff -u /dev/null src/sys/arch/arm/amlogic/meson_canvasreg.h:1.1 --- /dev/null Sat Jan 19 21:43:43 2019 +++ src/sys/arch/arm/amlogic/meson_canvasreg.h Sat Jan 19 21:43:43 2019 @@ -0,0 +1,54 @@ +/* $NetBSD: meson_canvasreg.h,v 1.1 2019/01/19 21:43:43 jmcneill Exp $ */ + +/*- + * Copyright (c) 2015 Jared McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _MESON_CANVASREG_H +#define _MESON_CANVASREG_H + +#define CANVAS_REG(n) ((n) << 2) + +#define DC_CAV_LUT_DATAL_REG CANVAS_REG(0x12) +#define DC_CAV_LUT_DATAH_REG CANVAS_REG(0x13) +#define DC_CAV_LUT_ADDR_REG CANVAS_REG(0x14) + +#define DC_CAV_LUT_DATAL_FBADDR __BITS(28,0) +#define DC_CAV_LUT_DATAL_WIDTH_L __BITS(31,29) + +#define DC_CAV_LUT_DATAH_BLKMODE __BITS(25,24) +#define DC_CAV_LUT_DATAH_BLKMODE_LINEAR 0 +#define DC_CAV_LUT_DATAH_BLKMODE_32X32 1 +#define DC_CAV_LUT_DATAH_BLKMODE_64X64 2 +#define DC_CAV_LUT_DATAH_YWRAP __BIT(23) +#define DC_CAV_LUT_DATAH_XWRAP __BIT(22) +#define DC_CAV_LUT_DATAH_HEIGHT __BITS(21,9) +#define DC_CAV_LUT_DATAH_WIDTH_H __BITS(8,0) + +#define DC_CAV_LUT_ADDR_WR_EN __BIT(9) +#define DC_CAV_LUT_ADDR_RD_EN __BIT(8) +#define DC_CAV_LUT_ADDR_INDEX __BITS(2,0) + +#endif /* _MESON_CANVASREG_H */ Index: src/sys/arch/arm/amlogic/meson_genfb.c diff -u /dev/null src/sys/arch/arm/amlogic/meson_genfb.c:1.1 --- /dev/null Sat Jan 19 21:43:43 2019 +++ src/sys/arch/arm/amlogic/meson_genfb.c Sat Jan 19 21:43:43 2019 @@ -0,0 +1,728 @@ +/* $NetBSD: meson_genfb.c,v 1.1 2019/01/19 21:43:43 jmcneill Exp $ */ + +/*- + * Copyright (c) 2015-2019 Jared McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: riastradh Date: Mon Sep 3 18:51:30 UTC 2018 Modified Files: src/sys/arch/arm/amlogic: amlogic_rng.c Log Message: Simplify amlogic rng. Compile-tested only, but this is basically the same as a bunch of other RNG driver simplifications I made a while back. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/amlogic/amlogic_rng.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/amlogic_rng.c diff -u src/sys/arch/arm/amlogic/amlogic_rng.c:1.3 src/sys/arch/arm/amlogic/amlogic_rng.c:1.4 --- src/sys/arch/arm/amlogic/amlogic_rng.c:1.3 Mon Apr 13 21:18:40 2015 +++ src/sys/arch/arm/amlogic/amlogic_rng.c Mon Sep 3 18:51:30 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: amlogic_rng.c,v 1.3 2015/04/13 21:18:40 riastradh Exp $ */ +/* $NetBSD: amlogic_rng.c,v 1.4 2018/09/03 18:51:30 riastradh Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -29,7 +29,7 @@ #include "locators.h" #include -__KERNEL_RCSID(0, "$NetBSD: amlogic_rng.c,v 1.3 2015/04/13 21:18:40 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: amlogic_rng.c,v 1.4 2018/09/03 18:51:30 riastradh Exp $"); #include #include @@ -37,7 +37,6 @@ __KERNEL_RCSID(0, "$NetBSD: amlogic_rng. #include #include #include -#include #include #include @@ -49,22 +48,15 @@ struct amlogic_rng_softc; static int amlogic_rng_match(device_t, cfdata_t, void *); static void amlogic_rng_attach(device_t, device_t, void *); -static void amlogic_rng_get(struct amlogic_rng_softc *); -static void amlogic_rng_get_intr(void *); -static void amlogic_rng_get_cb(size_t, void *); +static void amlogic_rng_get(size_t, void *); struct amlogic_rng_softc { device_t sc_dev; bus_space_tag_t sc_bst; bus_space_handle_t sc_bsh; - void * sc_sih; - + kmutex_t sc_lock; krndsource_t sc_rndsource; - size_t sc_bytes_wanted; - - kmutex_t sc_intr_lock; - kmutex_t sc_rnd_lock; }; CFATTACH_DECL_NEW(amlogic_rng, sizeof(struct amlogic_rng_softc), @@ -88,69 +80,33 @@ amlogic_rng_attach(device_t parent, devi bus_space_subregion(aio->aio_core_bst, aio->aio_bsh, loc->loc_offset, loc->loc_size, >sc_bsh); - mutex_init(>sc_intr_lock, MUTEX_DEFAULT, IPL_SERIAL); - mutex_init(>sc_rnd_lock, MUTEX_DEFAULT, IPL_SERIAL); - + mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_VM); + amlogic_rng_init(); aprint_naive("\n"); aprint_normal("\n"); - sc->sc_sih = softint_establish(SOFTINT_SERIAL|SOFTINT_MPSAFE, - amlogic_rng_get_intr, sc); - if (sc->sc_sih == NULL) { - aprint_error_dev(self, "couldn't establish softint\n"); - return; - } - - rndsource_setcb(>sc_rndsource, amlogic_rng_get_cb, sc); + rndsource_setcb(>sc_rndsource, amlogic_rng_get, sc); rnd_attach_source(>sc_rndsource, device_xname(self), RND_TYPE_RNG, RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB); - amlogic_rng_get_cb(RND_POOLBITS / NBBY, sc); + amlogic_rng_get(RND_POOLBITS / NBBY, sc); } static void -amlogic_rng_get(struct amlogic_rng_softc *sc) +amlogic_rng_get(size_t bytes_wanted, void *priv) { + struct amlogic_rng_softc * const sc = priv; uint32_t data[2]; - mutex_spin_enter(>sc_intr_lock); - while (sc->sc_bytes_wanted) { + mutex_spin_enter(>sc_lock); + while (bytes_wanted) { bus_space_read_region_4(sc->sc_bst, sc->sc_bsh, 0, data, 2); - mutex_spin_exit(>sc_intr_lock); - mutex_spin_enter(>sc_rnd_lock); - rnd_add_data(>sc_rndsource, data, sizeof(data), + rnd_add_data_sync(>sc_rndsource, data, sizeof(data), sizeof(data) * NBBY); - mutex_spin_exit(>sc_rnd_lock); - mutex_spin_enter(>sc_intr_lock); - sc->sc_bytes_wanted -= MIN(sc->sc_bytes_wanted, sizeof(data)); + bytes_wanted -= MIN(bytes_wanted, sizeof(data)); } explicit_memset(data, 0, sizeof(data)); - mutex_spin_exit(>sc_intr_lock); -} - -static void -amlogic_rng_get_cb(size_t bytes_wanted, void *priv) -{ - struct amlogic_rng_softc * const sc = priv; - - mutex_spin_enter(>sc_intr_lock); - if (sc->sc_bytes_wanted == 0) { - softint_schedule(sc->sc_sih); - } - if (bytes_wanted > (UINT_MAX - sc->sc_bytes_wanted)) { - sc->sc_bytes_wanted = UINT_MAX; - } else { - sc->sc_bytes_wanted += bytes_wanted; - } - mutex_spin_exit(>sc_intr_lock); -} - -static void -amlogic_rng_get_intr(void *priv) -{ - struct amlogic_rng_softc * const sc = priv; - - amlogic_rng_get(sc); + mutex_spin_exit(>sc_lock); }
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: riastradh Date: Mon Sep 3 18:51:30 UTC 2018 Modified Files: src/sys/arch/arm/amlogic: amlogic_rng.c Log Message: Simplify amlogic rng. Compile-tested only, but this is basically the same as a bunch of other RNG driver simplifications I made a while back. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/amlogic/amlogic_rng.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Nov 29 19:16:58 UTC 2015 Modified Files: src/sys/arch/arm/amlogic: amlogic_cpufreq.c amlogic_crureg.h Log Message: Fix A9 periph clock when selecting frequencies below 1200MHz. Remove frequencies below 312MHz as they require special handling. We can now choose between 1536 1488 1320 1200 1008 816 720 600 504 408 312. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/amlogic/amlogic_cpufreq.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/amlogic/amlogic_crureg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/amlogic_cpufreq.c diff -u src/sys/arch/arm/amlogic/amlogic_cpufreq.c:1.4 src/sys/arch/arm/amlogic/amlogic_cpufreq.c:1.5 --- src/sys/arch/arm/amlogic/amlogic_cpufreq.c:1.4 Sun Nov 29 16:52:00 2015 +++ src/sys/arch/arm/amlogic/amlogic_cpufreq.c Sun Nov 29 19:16:58 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: amlogic_cpufreq.c,v 1.4 2015/11/29 16:52:00 jmcneill Exp $ */ +/* $NetBSD: amlogic_cpufreq.c,v 1.5 2015/11/29 19:16:58 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill@@ -31,7 +31,7 @@ #include "opt_amlogic.h" #include -__KERNEL_RCSID(0, "$NetBSD: amlogic_cpufreq.c,v 1.4 2015/11/29 16:52:00 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: amlogic_cpufreq.c,v 1.5 2015/11/29 19:16:58 jmcneill Exp $"); #include #include @@ -73,6 +73,9 @@ static size_t meson8b_cpu_get_available( #define CBUS_WRITE(x, v) \ bus_space_write_4(_generic_bs_tag, amlogic_core_bsh, \ AMLOGIC_CBUS_OFFSET + (x), (v)) +#define CBUS_SET_CLEAR(x, s, c) \ +amlogic_reg_set_clear(_generic_bs_tag, amlogic_core_bsh, \ + AMLOGIC_CBUS_OFFSET + (x), (s), (c)) void amlogic_cpufreq_bootstrap(void) @@ -206,7 +209,7 @@ amlogic_cpufreq_freq_helper(SYSCTLFN_ARG * meson8b */ static const u_int meson8b_rates[] = { - 1536, 1488, 1320, 1200, 1008, 816, 720, 600, 504, 408, 312, 192, 96 + 1536, 1488, 1320, 1200, 1008, 816, 720, 600, 504, 408, 312 }; static size_t @@ -248,9 +251,17 @@ meson8b_cpu_set_rate(u_int rate) uint32_t cntl0 = CBUS_READ(HHI_SYS_CPU_CLK_CNTL0_REG); uint32_t cntl = CBUS_READ(HHI_SYS_PLL_CNTL_REG); - const u_int new_mul = new_rate / xtal_rate; - const u_int new_div = 1; - const u_int new_od = 0; + u_int new_mul = new_rate / xtal_rate; + u_int new_div = 1; + u_int new_od = 0; + + if (new_rate < 600 * 100) { + new_od = 2; + new_mul *= 4; + } else if (new_rate < 1200 * 100) { + new_od = 1; + new_mul *= 2; + } /* * XXX make some assumptions about the state of cpu clk cntl regs @@ -269,7 +280,22 @@ meson8b_cpu_set_rate(u_int rate) cntl &= ~HHI_SYS_PLL_CNTL_OD; cntl |= __SHIFTIN(new_od, HHI_SYS_PLL_CNTL_OD); - CBUS_WRITE(HHI_SYS_PLL_CNTL_REG, cntl); + /* Switch CPU to XTAL clock */ + CBUS_SET_CLEAR(HHI_SYS_CPU_CLK_CNTL0_REG, 0, + HHI_SYS_CPU_CLK_CNTL0_CLKSEL); + + delay((100 * old_rate) / xtal_rate); + + /* Update multiplier */ + do { + CBUS_WRITE(HHI_SYS_PLL_CNTL_REG, cntl); + + /* Switch CPU to sys pll */ + CBUS_SET_CLEAR(HHI_SYS_CPU_CLK_CNTL0_REG, + HHI_SYS_CPU_CLK_CNTL0_CLKSEL, 0); + + delay((500 * old_rate) / new_rate); + } while (!(CBUS_READ(HHI_SYS_PLL_CNTL_REG) & HHI_SYS_PLL_CNTL_LOCK)); if (!cold) { a9tmr_update_freq(amlogic_get_rate_a9periph()); Index: src/sys/arch/arm/amlogic/amlogic_crureg.h diff -u src/sys/arch/arm/amlogic/amlogic_crureg.h:1.12 src/sys/arch/arm/amlogic/amlogic_crureg.h:1.13 --- src/sys/arch/arm/amlogic/amlogic_crureg.h:1.12 Sun Nov 29 16:52:00 2015 +++ src/sys/arch/arm/amlogic/amlogic_crureg.h Sun Nov 29 19:16:58 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: amlogic_crureg.h,v 1.12 2015/11/29 16:52:00 jmcneill Exp $ */ +/* $NetBSD: amlogic_crureg.h,v 1.13 2015/11/29 19:16:58 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -67,6 +67,7 @@ #define HHI_SYS_PLL_CNTL_MUL __BITS(8,0) #define HHI_SYS_PLL_CNTL_DIV __BITS(14,9) #define HHI_SYS_PLL_CNTL_OD __BITS(17,16) +#define HHI_SYS_PLL_CNTL_LOCK __BIT(31) #define HHI_MPLL_CNTL_REG CBUS_REG(0x10a0) #define HHI_MPLL_CNTL_MUL __BITS(8,0)
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sun Nov 29 19:16:58 UTC 2015 Modified Files: src/sys/arch/arm/amlogic: amlogic_cpufreq.c amlogic_crureg.h Log Message: Fix A9 periph clock when selecting frequencies below 1200MHz. Remove frequencies below 312MHz as they require special handling. We can now choose between 1536 1488 1320 1200 1008 816 720 600 504 408 312. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/amlogic/amlogic_cpufreq.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/amlogic/amlogic_crureg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Thu Nov 26 00:06:59 UTC 2015 Modified Files: src/sys/arch/arm/amlogic: amlogic_board.c Log Message: disable watchdog at startup To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/amlogic/amlogic_board.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/amlogic_board.c diff -u src/sys/arch/arm/amlogic/amlogic_board.c:1.15 src/sys/arch/arm/amlogic/amlogic_board.c:1.16 --- src/sys/arch/arm/amlogic/amlogic_board.c:1.15 Sat Nov 21 00:54:57 2015 +++ src/sys/arch/arm/amlogic/amlogic_board.c Thu Nov 26 00:06:59 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: amlogic_board.c,v 1.15 2015/11/21 00:54:57 jmcneill Exp $ */ +/* $NetBSD: amlogic_board.c,v 1.16 2015/11/26 00:06:59 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill@@ -29,7 +29,7 @@ #include "opt_amlogic.h" #include -__KERNEL_RCSID(0, "$NetBSD: amlogic_board.c,v 1.15 2015/11/21 00:54:57 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: amlogic_board.c,v 1.16 2015/11/26 00:06:59 jmcneill Exp $"); #define _ARM32_BUS_DMA_PRIVATE #include @@ -242,6 +242,10 @@ amlogic_rng_init(void) void amlogic_wdog_init(void) { + /* Disable watchdog */ + CBUS_WRITE(WATCHDOG_RESET_REG, 0); + CBUS_SET_CLEAR(WATCHDOG_TC_REG, 0, WATCHDOG_TC_ENABLE); + sysmon_wdog_register(_ee_wdog); }
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Thu Nov 26 00:06:59 UTC 2015 Modified Files: src/sys/arch/arm/amlogic: amlogic_board.c Log Message: disable watchdog at startup To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/amlogic/amlogic_board.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sat Nov 21 00:54:57 UTC 2015 Modified Files: src/sys/arch/arm/amlogic: amlogic_board.c amlogic_io.c amlogic_var.h Log Message: Add watchdog timer support. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/amlogic/amlogic_board.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/amlogic/amlogic_io.c cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/amlogic/amlogic_var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/amlogic_board.c diff -u src/sys/arch/arm/amlogic/amlogic_board.c:1.14 src/sys/arch/arm/amlogic/amlogic_board.c:1.15 --- src/sys/arch/arm/amlogic/amlogic_board.c:1.14 Sat Aug 8 10:51:40 2015 +++ src/sys/arch/arm/amlogic/amlogic_board.c Sat Nov 21 00:54:57 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: amlogic_board.c,v 1.14 2015/08/08 10:51:40 jmcneill Exp $ */ +/* $NetBSD: amlogic_board.c,v 1.15 2015/11/21 00:54:57 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill@@ -29,13 +29,16 @@ #include "opt_amlogic.h" #include -__KERNEL_RCSID(0, "$NetBSD: amlogic_board.c,v 1.14 2015/08/08 10:51:40 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: amlogic_board.c,v 1.15 2015/11/21 00:54:57 jmcneill Exp $"); #define _ARM32_BUS_DMA_PRIVATE #include #include #include #include +#include + +#include #include @@ -46,8 +49,22 @@ __KERNEL_RCSID(0, "$NetBSD: amlogic_boar #include #include +#define AMLOGIC_EE_WDOG_PERIOD_DEFAULT 8 +#define AMLOGIC_EE_WDOG_PERIOD_MAX 8 +#define AMLOGIC_EE_WDOG_TICKS_PER_SEC 7812 + bus_space_handle_t amlogic_core_bsh; +static int amlogic_ee_wdog_setmode(struct sysmon_wdog *); +static int amlogic_ee_wdog_tickle(struct sysmon_wdog *); + +static struct sysmon_wdog amlogic_ee_wdog = { + .smw_name = "EE-watchdog", + .smw_setmode = amlogic_ee_wdog_setmode, + .smw_tickle = amlogic_ee_wdog_tickle, + .smw_period = AMLOGIC_EE_WDOG_PERIOD_DEFAULT +}; + struct arm32_bus_dma_tag amlogic_dma_tag = { _BUS_DMAMAP_FUNCS, _BUS_DMAMEM_FUNCS, @@ -223,6 +240,44 @@ amlogic_rng_init(void) } void +amlogic_wdog_init(void) +{ + sysmon_wdog_register(_ee_wdog); +} + +static int +amlogic_ee_wdog_setmode(struct sysmon_wdog *smw) +{ + if ((smw->smw_mode & WDOG_MODE_MASK) == WDOG_MODE_DISARMED) { + CBUS_WRITE(WATCHDOG_RESET_REG, 0); + CBUS_SET_CLEAR(WATCHDOG_TC_REG, 0, WATCHDOG_TC_ENABLE); + return 0; + } + + if (smw->smw_period == WDOG_PERIOD_DEFAULT) { + amlogic_ee_wdog.smw_period = AMLOGIC_EE_WDOG_PERIOD_DEFAULT; + } else if (smw->smw_period == 0 || + smw->smw_period > AMLOGIC_EE_WDOG_PERIOD_MAX) { + return EINVAL; + } else { + amlogic_ee_wdog.smw_period = smw->smw_period; + } + u_int tcnt = amlogic_ee_wdog.smw_period * AMLOGIC_EE_WDOG_TICKS_PER_SEC; + CBUS_WRITE(WATCHDOG_RESET_REG, 0); + CBUS_WRITE(WATCHDOG_TC_REG, WATCHDOG_TC_CPUS | WATCHDOG_TC_ENABLE | + __SHIFTIN(tcnt, WATCHDOG_TC_TCNT)); + + return 0; +} + +static int +amlogic_ee_wdog_tickle(struct sysmon_wdog *smw) +{ + CBUS_WRITE(WATCHDOG_RESET_REG, 0); + return 0; +} + +void amlogic_sdhc_init(void) { /* enable SDHC clk */ Index: src/sys/arch/arm/amlogic/amlogic_io.c diff -u src/sys/arch/arm/amlogic/amlogic_io.c:1.12 src/sys/arch/arm/amlogic/amlogic_io.c:1.13 --- src/sys/arch/arm/amlogic/amlogic_io.c:1.12 Sat Aug 8 14:01:44 2015 +++ src/sys/arch/arm/amlogic/amlogic_io.c Sat Nov 21 00:54:57 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: amlogic_io.c,v 1.12 2015/08/08 14:01:44 jmcneill Exp $ */ +/* $NetBSD: amlogic_io.c,v 1.13 2015/11/21 00:54:57 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -29,7 +29,7 @@ #include "opt_amlogic.h" #include -__KERNEL_RCSID(0, "$NetBSD: amlogic_io.c,v 1.12 2015/08/08 14:01:44 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: amlogic_io.c,v 1.13 2015/11/21 00:54:57 jmcneill Exp $"); #include #include @@ -99,6 +99,7 @@ amlogicio_attach(device_t parent, device aprint_naive("\n"); aprint_normal("\n"); + amlogic_wdog_init(); amlogic_usbphy_init(0); amlogic_usbphy_init(1); Index: src/sys/arch/arm/amlogic/amlogic_var.h diff -u src/sys/arch/arm/amlogic/amlogic_var.h:1.11 src/sys/arch/arm/amlogic/amlogic_var.h:1.12 --- src/sys/arch/arm/amlogic/amlogic_var.h:1.11 Tue Aug 4 01:23:07 2015 +++ src/sys/arch/arm/amlogic/amlogic_var.h Sat Nov 21 00:54:57 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: amlogic_var.h,v 1.11 2015/08/04 01:23:07 jmcneill Exp $ */ +/* $NetBSD: amlogic_var.h,v 1.12 2015/11/21 00:54:57 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill @@ -59,6 +59,7 @@ void amlogic_bootstrap(void); void amlogic_cpufreq_bootstrap(void); void amlogic_cpufreq_init(void); +void amlogic_wdog_init(void); void amlogic_usbphy_init(int); void amlogic_eth_init(void); void amlogic_rng_init(void);
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Sat Nov 21 00:54:57 UTC 2015 Modified Files: src/sys/arch/arm/amlogic: amlogic_board.c amlogic_io.c amlogic_var.h Log Message: Add watchdog timer support. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/amlogic/amlogic_board.c cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/amlogic/amlogic_io.c cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/amlogic/amlogic_var.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Thu Oct 29 21:07:48 UTC 2015 Modified Files: src/sys/arch/arm/amlogic: amlogic_sdhc.c Log Message: only advertise HS200 and 8-bit mode on the eMMC slot To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/amlogic/amlogic_sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/amlogic/amlogic_sdhc.c diff -u src/sys/arch/arm/amlogic/amlogic_sdhc.c:1.11 src/sys/arch/arm/amlogic/amlogic_sdhc.c:1.12 --- src/sys/arch/arm/amlogic/amlogic_sdhc.c:1.11 Sat Aug 8 15:36:39 2015 +++ src/sys/arch/arm/amlogic/amlogic_sdhc.c Thu Oct 29 21:07:48 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: amlogic_sdhc.c,v 1.11 2015/08/08 15:36:39 jmcneill Exp $ */ +/* $NetBSD: amlogic_sdhc.c,v 1.12 2015/10/29 21:07:48 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill@@ -29,7 +29,7 @@ #include "locators.h" #include -__KERNEL_RCSID(0, "$NetBSD: amlogic_sdhc.c,v 1.11 2015/08/08 15:36:39 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: amlogic_sdhc.c,v 1.12 2015/10/29 21:07:48 jmcneill Exp $"); #include #include @@ -205,14 +205,17 @@ amlogic_sdhc_attach_i(device_t self) saa.saa_clkmax = pll_freq; /* Do not advertise DMA capabilities, we handle DMA ourselves */ saa.saa_caps = SMC_CAPS_4BIT_MODE| - SMC_CAPS_8BIT_MODE| SMC_CAPS_SD_HIGHSPEED| SMC_CAPS_MMC_HIGHSPEED| SMC_CAPS_UHS_SDR50| SMC_CAPS_UHS_SDR104| - SMC_CAPS_MMC_HS200| SMC_CAPS_AUTO_STOP; + if (sc->sc_port == AMLOGIC_SDHC_PORT_C) { + saa.saa_caps |= SMC_CAPS_MMC_HS200; + saa.saa_caps |= SMC_CAPS_8BIT_MODE; + } + sc->sc_sdmmc_dev = config_found(self, , NULL); }
CVS commit: src/sys/arch/arm/amlogic
Module Name:src Committed By: jmcneill Date: Thu Oct 29 21:07:48 UTC 2015 Modified Files: src/sys/arch/arm/amlogic: amlogic_sdhc.c Log Message: only advertise HS200 and 8-bit mode on the eMMC slot To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/amlogic/amlogic_sdhc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.