Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -uNpr sunxi.orig/files.sunxi sunxi/files.sunxi
- --- sunxi.orig/files.sunxi 2019-12-10 12:01:47.000000000 +0900
- +++ sunxi/files.sunxi 2020-01-02 12:14:40.577814807 +0900
- @@ -77,6 +77,11 @@ device sun50ih6rccu: sunxi_ccu
- attach sun50ih6rccu at fdt with sunxi_h6_r_ccu
- file arch/arm/sunxi/sun50i_h6_r_ccu.c sunxi_h6_r_ccu
- +# CCU (F1C100s)
- +device sunivf1c100sccu: sunxi_ccu
- +attach sunivf1c100sccu at fdt with suniv_f1c100s_ccu
- +file arch/arm/sunxi/suniv_f1c100s_ccu.c suniv_f1c100s_ccu
- +
- # Misc. clock resets
- device sunxiresets
- attach sunxiresets at fdt with sunxi_resets
- @@ -134,6 +139,7 @@ file arch/arm/sunxi/sun8i_h3_gpio.c sun
- file arch/arm/sunxi/sun9i_a80_gpio.c sunxi_gpio & soc_sun9i_a80
- file arch/arm/sunxi/sun50i_a64_gpio.c sunxi_gpio & soc_sun50i_a64
- file arch/arm/sunxi/sun50i_h6_gpio.c sunxi_gpio & soc_sun50i_h6
- +file arch/arm/sunxi/suniv_f1c100s_gpio.c sunxi_gpio & soc_suniv_f1c100s
- # PWM
- device sunxipwm: pwm
- @@ -389,3 +395,4 @@ defflag opt_soc.h SOC_SUN50I: SOC_SUNX
- defflag opt_soc.h SOC_SUN50I_A64: SOC_SUN50I
- defflag opt_soc.h SOC_SUN50I_H5: SOC_SUN50I, SOC_SUN8I_H3
- defflag opt_soc.h SOC_SUN50I_H6: SOC_SUN50I
- +defflag opt_soc.h SOC_SUNIV_F1C100S: SOC_SUNXI
- diff -uNpr sunxi.orig/suniv_f1c100s_ccu.c sunxi/suniv_f1c100s_ccu.c
- --- sunxi.orig/suniv_f1c100s_ccu.c 1970-01-01 09:00:00.000000000 +0900
- +++ sunxi/suniv_f1c100s_ccu.c 2020-01-02 11:46:01.839322117 +0900
- @@ -0,0 +1,253 @@
- +/* $NetBSD: suniv_f1c100s_ccu.c,v 1.5 2017/11/09 21:52:32 jmcneill Exp $ */
- +
- +/*-
- + * Copyright (c) 2017 Jared McNeill <[email protected]>
- + * 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.
- + */
- +
- +#include <sys/cdefs.h>
- +
- +__KERNEL_RCSID(1, "$NetBSD: suniv_f1c100s_ccu.c,v 1.5 2017/11/09 21:52:32 jmcneill Exp $");
- +
- +#include <sys/param.h>
- +#include <sys/bus.h>
- +#include <sys/device.h>
- +#include <sys/systm.h>
- +
- +#include <dev/fdt/fdtvar.h>
- +
- +#include <arm/sunxi/sunxi_ccu.h>
- +#include <arm/sunxi/suniv_f1c100s_ccu.h>
- +
- +#define PLL_CPU_CTRL_REG 0x000
- +#define PLL_AUDIO_CTRL_REG 0x008
- +#define PLL_VIDEO_CTRL_REG 0x010
- +#define PLL_VE_CTRL_REG 0x018
- +#define PLL_DDR_CTRL_REG 0x020
- +#define PLL_PERIPH_CTRL_REG 0x028
- +#define CPU_CLK_SRC_REG 0x050
- +#define AHB_APB_HCLKC_CFG_REG 0x054
- +#define BUS_CLK_GATING_REG0 0x060
- +#define BUS_CLK_GATING_REG1 0x064
- +#define BUS_CLK_GATING_REG2 0x068
- +#define SDMMC0_CLK_REG 0x088
- +#define SDMMC1_CLK_REG 0x08c
- +#define DAUDIO_CLK_REG 0x0b0
- +#define OWA_CLK_REG 0x0b4
- +#define CIR_CLK_REG 0x0b8
- +#define USBPHY_CLK_REG 0x0cc
- +#define DRAM_GATING_REG 0x100
- +#define BE_CLK_REG 0x104
- +#define FE_CLK_REG 0x10c
- +#define TCON_CLK_REG 0x118
- +#define DI_CLK_REG 0x11c
- +#define TVE_CLK_REG 0x120
- +#define TVD_CLK_REG 0x124
- +#define CSI_CLK_REG 0x134
- +#define VE_CLK_REG 0x13c
- +#define AUDIO_CODEC_CLK_REG 0x140
- +#define AVS_CLK_REG 0x144
- +#define PLL_STABLE_TIME_REG0 0x200
- +#define PLL_STABLE_TIME_REG1 0x204
- +#define PLL_CPU_BIAS_REG 0x220
- +#define PLL_AUDIO_BIAS_REG 0x224
- +#define PLL_VIDEO_BIAS_REG 0x228
- +#define PLL_VE_BIAS_REG 0x22c
- +#define PLL_DDR_BIAS_REG 0x230
- +#define PLL_PERIPH_BIAS_REG 0x234
- +#define PLL_CPU_TUN_REG 0x250
- +#define PLL_DDR_TUN_REG 0x260
- +#define PLL_AUDIO_PAT_CTRL_REG 0x284
- +#define PLL_VIDEO_PAT_CTRL_REG 0x288
- +#define PLL_DDR_PAT_CTRL_REG 0x290
- +#define BUS_SOFT_RST_REG0 0x2c0
- +#define BUS_SOFT_RST_REG1 0x2c4
- +#define BUS_SOFT_RST_REG2 0x2d0
- +
- +static int suniv_f1c100s_ccu_match(device_t, cfdata_t, void *);
- +static void suniv_f1c100s_ccu_attach(device_t, device_t, void *);
- +
- +static const char * const compatible[] = {
- + "allwinner,suniv-f1c100s-ccu",
- + NULL
- +};
- +
- +CFATTACH_DECL_NEW(suniv_f1c100s_ccu, sizeof(struct sunxi_ccu_softc),
- + suniv_f1c100s_ccu_match, suniv_f1c100s_ccu_attach, NULL, NULL);
- +
- +static struct sunxi_ccu_reset suniv_f1c100s_ccu_resets[] = {
- + SUNXI_CCU_RESET(F1C100S_RST_USB_PHY0, USBPHY_CLK_REG, 0);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_DMA, BUS_SOFT_RST_REG0, 6);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_MMC0, BUS_SOFT_RST_REG0, 8);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_MMC1, BUS_SOFT_RST_REG0, 9);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_DRAM, BUS_SOFT_RST_REG0, 14);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_SPI0, BUS_SOFT_RST_REG0, 20);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_SPI1, BUS_SOFT_RST_REG0, 21);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_OTG, BUS_SOFT_RST_REG0, 24);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_VE, BUS_SOFT_RST_REG1, 0);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_LCD, BUS_SOFT_RST_REG1, 4);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_DEINTERLACE, BUS_SOFT_RST_REG1, 5);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_CSI, BUS_SOFT_RST_REG1, 8);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_TVD, BUS_SOFT_RST_REG1, 9);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_TVE, 10);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_DE_BE, BUS_SOFT_RST_REG1, 12);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_DE_FE, BUS_SOFT_RST_REG1, 14);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_CODEC, BUS_SOFT_RST_REG2, 0);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_SPDIF, BUS_SOFT_RST_REG2, 1);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_IR, BUS_SOFT_RST_REG2, 2);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_RSB, BUS_SOFT_RST_REG2, 3);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_I2S0, BUS_SOFT_RST_REG2, 12);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_I2C0, BUS_SOFT_RST_REG2, 16);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_I2C1, BUS_SOFT_RST_REG2, 17);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_I2C2, BUS_SOFT_RST_REG2, 18);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_UART0, BUS_SOFT_RST_REG2, 20);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_UART1, BUS_SOFT_RST_REG2, 21);
- + SUNXI_CCU_RESET(F1C100S_RST_BUS_UART2, BUS_SOFT_RST_REG2, 22);
- +};
- +
- +static const char *mod_parents[] = { "osc24m" };
- +
- +static struct sunxi_ccu_clk suniv_f1c100s_ccu_clks[] = {
- + SUNXI_CCU_NM(F1C100S_CLK_MMC0, "mmc0", mod_parents,
- + SDMMC0_CLK_REG, /* reg */
- + __BITS(17,16), /* n */
- + __BITS(3,0), /* m */
- + __BITS(25,24), /* sel */
- + __BIT(31), /* enable */
- + SUNXI_CCU_NM_POWER_OF_TWO),
- + SUNXI_CCU_NM(F1C100S_CLK_MMC1, "mmc1", mod_parents,
- + SDMMC1_CLK_REG, /* reg */
- + __BITS(17,16), /* n */
- + __BITS(3,0), /* m */
- + __BITS(25,24), /* sel */
- + __BIT(31), /* enable */
- + SUNXI_CCU_NM_POWER_OF_TWO),
- +
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_DMA, "ahb-dma", "ahb",
- + BUS_CLK_GATING_REG0, 6);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_MMC0, "ahb-mmc0", "ahb",
- + BUS_CLK_GATING_REG0, 8);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_MMC1, "ahb-mmc1", "ahb",
- + BUS_CLK_GATING_REG0, 9);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_DRAM, "ahb-dram", "ahb",
- + BUS_CLK_GATING_REG0, 14);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_SPI0, "ahb-spi0", "ahb",
- + BUS_CLK_GATING_REG0, 20);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_SPI1, "ahb-spi1", "ahb",
- + BUS_CLK_GATING_REG0, 21);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_OTG, "ahb-otg", "ahb",
- + BUS_CLK_GATING_REG0, 24);
- +
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_VE, "ahb-ve", "ahb",
- + BUS_CLK_GATING_REG1, 0);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_LCD, "ahb-lcd", "ahb",
- + BUS_CLK_GATING_REG1, 4);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_DEINTERLACE, "ahb-deinterlace", "ahb",
- + BUS_CLK_GATING_REG1, 5);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_CSI, "ahb-csi", "ahb",
- + BUS_CLK_GATING_REG1, 8);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_TVD, "ahb-tvd", "ahb",
- + BUS_CLK_GATING_REG1, 9);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_TVE, "ahb-tve", "ahb",
- + BUS_CLK_GATING_REG1, 10);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_DE_BE, "ahb-de_be", "ahb",
- + BUS_CLK_GATING_REG1, 12);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_DE_FE, "ahb-de_fe", "ahb",
- + BUS_CLK_GATING_REG1, 14);
- +
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_CODEC, "apb-codec", "apb",
- + BUS_CLK_GATING_REG2, 0);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_SPDIF, "apb-spdif", "apb",
- + BUS_CLK_GATING_REG2, 1);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_IR, "apb-ir", "apb",
- + BUS_CLK_GATING_REG2, 2);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_RSB, "apb-rsb", "apb",
- + BUS_CLK_GATING_REG2, 3);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_I2S0, "apb-i2s0", "apb",
- + BUS_CLK_GATING_REG2, 12);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_I2C0, "apb-i2c0", "apb",
- + BUS_CLK_GATING_REG2, 16);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_I2C1, "apb-i2c1", "apb",
- + BUS_CLK_GATING_REG2, 17);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_I2C2, "apb-i2c2", "apb",
- + BUS_CLK_GATING_REG2, 18);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_UART0, "apb-uart0", "apb",
- + BUS_CLK_GATING_REG2, 20);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_UART1, "apb-uart1", "apb",
- + BUS_CLK_GATING_REG2, 21);
- + SUNXI_CCU_GATE(F1C100S_CLK_BUS_UART2, "apb-uart2", "apb",
- + BUS_CLK_GATING_REG2, 22);
- +
- + SUNXI_CCU_GATE(F1C100S_CLK_USB_PHY0, "usb-phy", "osc24m",
- + USBPHY_CLK_REG, 1);
- +
- + SUNXI_CCU_GATE(F1C100S_CLK_DRAM_VE, "dram-ve", "pll_ddr",
- + DRAM_GATING_REG, 0);
- + SUNXI_CCU_GATE(F1C100S_CLK_DRAM_CSI, "dram-csi", "pll_ddr",
- + DRAM_GATING_REG, 1);
- + SUNXI_CCU_GATE(F1C100S_CLK_DRAM_DEINTERLACE, "dram-deinterlace", "pll-ddr",
- + DRAM_GATING_REG, 2);
- + SUNXI_CCU_GATE(F1C100S_CLK_DRAM_TVD, "dram-tvd", "pll_ddr",
- + DRAM_GATING_REG, 3);
- + SUNXI_CCU_GATE(F1C100S_CLK_DRAM_DE_FE, "dram-de-fe", "pll_ddr",
- + DRAM_GATING_REG, 24);
- + SUNXI_CCU_GATE(F1C100S_CLK_DRAM_DE_BE, "dram-de-be", "pll_ddr",
- + DRAM_GATING_REG, 26);
- +
- + SUNXI_CCU_GATE(F1C100S_CLK_CODEC, "codec", "pll_audio",
- + DAUDIO_CLK_REG, 31);
- +};
- +
- +static int
- +suniv_f1c100s_ccu_match(device_t parent, cfdata_t cf, void *aux)
- +{
- + struct fdt_attach_args * const faa = aux;
- +
- + return of_match_compatible(faa->faa_phandle, compatible);
- +}
- +
- +static void
- +suniv_f1c100s_ccu_attach(device_t parent, device_t self, void *aux)
- +{
- + struct sunxi_ccu_softc * const sc = device_private(self);
- + struct fdt_attach_args * const faa = aux;
- +
- + sc->sc_dev = self;
- + sc->sc_phandle = faa->faa_phandle;
- + sc->sc_bst = faa->faa_bst;
- +
- + sc->sc_resets = suniv_f1c100s_ccu_resets;
- + sc->sc_nresets = __arraycount(suniv_f1c100s_ccu_resets);
- +
- + sc->sc_clks = suniv_f1c100s_ccu_clks;
- + sc->sc_nclks = __arraycount(suniv_f1c100s_ccu_clks);
- +
- + if (sunxi_ccu_attach(sc) != 0)
- + return;
- +
- + aprint_naive("\n");
- + aprint_normal(": F1C100s CCU\n");
- +
- + sunxi_ccu_print(sc);
- +}
- diff -uNpr sunxi.orig/suniv_f1c100s_ccu.h sunxi/suniv_f1c100s_ccu.h
- --- sunxi.orig/suniv_f1c100s_ccu.h 1970-01-01 09:00:00.000000000 +0900
- +++ sunxi/suniv_f1c100s_ccu.h 2020-01-02 07:55:33.254354111 +0900
- @@ -0,0 +1,115 @@
- +/* $NetBSD: suniv_f1c100s_ccu.h,v 1.1 2017/08/25 00:07:03 jmcneill Exp $ */
- +
- +/*-
- + * Copyright (c) 2017 Jared McNeill <[email protected]>
- + * 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 _SUNIV_F1C100S_CCU_H
- +#define _SUNIV_F1C100S_CCU_H
- +
- +#define F1C100S_RST_USB_PHY0 0
- +#define F1C100S_RST_BUS_DMA 1
- +#define F1C100S_RST_BUS_MMC0 2
- +#define F1C100S_RST_BUS_MMC1 3
- +#define F1C100S_RST_BUS_DRAM 4
- +#define F1C100S_RST_BUS_SPI0 5
- +#define F1C100S_RST_BUS_SPI1 6
- +#define F1C100S_RST_BUS_OTG 7
- +#define F1C100S_RST_BUS_VE 8
- +#define F1C100S_RST_BUS_LCD 9
- +#define F1C100S_RST_BUS_DEINTERLACE 10
- +#define F1C100S_RST_BUS_CSI 11
- +#define F1C100S_RST_BUS_TVD 12
- +#define F1C100S_RST_BUS_TVE 13
- +#define F1C100S_RST_BUS_DE_BE 14
- +#define F1C100S_RST_BUS_DE_FE 15
- +#define F1C100S_RST_BUS_CODEC 16
- +#define F1C100S_RST_BUS_SPDIF 17
- +#define F1C100S_RST_BUS_IR 18
- +#define F1C100S_RST_BUS_RSB 19
- +#define F1C100S_RST_BUS_I2S0 20
- +#define F1C100S_RST_BUS_I2C0 21
- +#define F1C100S_RST_BUS_I2C1 22
- +#define F1C100S_RST_BUS_I2C2 23
- +#define F1C100S_RST_BUS_UART0 24
- +#define F1C100S_RST_BUS_UART1 25
- +#define F1C100S_RST_BUS_UART2 26
- +
- +#define F1C100S_CLK_CPU 11
- +#define F1C100S_CLK_BUS_DMA 14
- +#define F1C100S_CLK_BUS_MMC0 15
- +#define F1C100S_CLK_BUS_MMC1 16
- +#define F1C100S_CLK_BUS_DRAM 17
- +#define F1C100S_CLK_BUS_SPI0 18
- +#define F1C100S_CLK_BUS_SPI1 19
- +#define F1C100S_CLK_BUS_OTG 20
- +#define F1C100S_CLK_BUS_VE 21
- +#define F1C100S_CLK_BUS_LCD 22
- +#define F1C100S_CLK_BUS_DEINTERLACE 23
- +#define F1C100S_CLK_BUS_CSI 24
- +#define F1C100S_CLK_BUS_TVD 25
- +#define F1C100S_CLK_BUS_TVE 26
- +#define F1C100S_CLK_BUS_DE_BE 27
- +#define F1C100S_CLK_BUS_DE_FE 28
- +#define F1C100S_CLK_BUS_CODEC 29
- +#define F1C100S_CLK_BUS_SPDIF 30
- +#define F1C100S_CLK_BUS_IR 31
- +#define F1C100S_CLK_BUS_RSB 32
- +#define F1C100S_CLK_BUS_I2S0 33
- +#define F1C100S_CLK_BUS_I2C0 34
- +#define F1C100S_CLK_BUS_I2C1 35
- +#define F1C100S_CLK_BUS_I2C2 36
- +#define F1C100S_CLK_BUS_PIO 37
- +#define F1C100S_CLK_BUS_UART0 38
- +#define F1C100S_CLK_BUS_UART1 39
- +#define F1C100S_CLK_BUS_UART2 40
- +#define F1C100S_CLK_MMC0 41
- +#define F1C100S_CLK_MMC0_SAMPLE 42
- +#define F1C100S_CLK_MMC0_OUTPUT 43
- +#define F1C100S_CLK_MMC1 44
- +#define F1C100S_CLK_MMC1_SAMPLE 45
- +#define F1C100S_CLK_MMC1_OUTPUT 46
- +#define F1C100S_CLK_I2S 47
- +#define F1C100S_CLK_SPDIF 48
- +#define F1C100S_CLK_USB_PHY0 49
- +#define F1C100S_CLK_DRAM_VE 50
- +#define F1C100S_CLK_DRAM_CSI 51
- +#define F1C100S_CLK_DRAM_DEINTERLACE 52
- +#define F1C100S_CLK_DRAM_TVD 53
- +#define F1C100S_CLK_DRAM_DE_FE 54
- +#define F1C100S_CLK_DRAM_DE_BE 55
- +#define F1C100S_CLK_DE_BE 56
- +#define F1C100S_CLK_DE_FE 57
- +#define F1C100S_CLK_TCON 58
- +#define F1C100S_CLK_DEINTERLACE 59
- +#define F1C100S_CLK_TVE2_CLK 60
- +#define F1C100S_CLK_TVE1_CLK 61
- +#define F1C100S_CLK_TVD 62
- +#define F1C100S_CLK_CSI 63
- +#define F1C100S_CLK_VE 64
- +#define F1C100S_CLK_CODEC 65
- +#define F1C100S_CLK_AVS 66
- +
- +#endif /* !_SUNIV_F1C100S_CCU_H */
- diff -uNpr sunxi.orig/suniv_f1c100s_gpio.c sunxi/suniv_f1c100s_gpio.c
- --- sunxi.orig/suniv_f1c100s_gpio.c 1970-01-01 09:00:00.000000000 +0900
- +++ sunxi/suniv_f1c100s_gpio.c 2020-01-02 06:25:14.982772662 +0900
- @@ -0,0 +1,101 @@
- +/* $NetBSD: suniv_f1c100s_gpio.c,v 1.4 2018/04/03 16:01:25 bouyer Exp $ */
- +
- +/*-
- + * Copyright (c) 2016 Emmanuel Vadot <[email protected]>
- + * 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 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 AUTHOR 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 <sys/cdefs.h>
- +__KERNEL_RCSID(0, "$NetBSD: suniv_f1c100s_gpio.c,v 1.4 2018/04/03 16:01:25 bouyer Exp $");
- +
- +#include <sys/param.h>
- +#include <sys/systm.h>
- +#include <sys/kernel.h>
- +#include <sys/types.h>
- +
- +#include <arm/sunxi/sunxi_gpio.h>
- +
- +static const struct sunxi_gpio_pins f1c100s_pins[] = {
- + {"PA0", 0, 0, {"gpio_in", "gpio_out", "tp", NULL, "i2s", "uart1", "spi1"}},
- + {"PA1", 0, 1, {"gpio_in", "gpio_out", "tp", NULL, "i2s", "uart1", "spi1"}},
- + {"PA2", 0, 2, {"gpio_in", "gpio_out", "tp", "pwm0", "i2s", "uart1", "spi1"}},
- + {"PA3", 0, 3, {"gpio_in", "gpio_out", "tp", "ir", "i2s", "uart1", "spi1"}},
- +
- + {"PB3", 1, 3, {"gpio_in", "gpio_out", "ddr", "ir"}},
- +
- + {"PC0", 2, 0, {"gpio_in", "gpio_out", "spi0", "mmc1"}},
- + {"PC1", 2, 1, {"gpio_in", "gpio_out", "spi0", "mmc1"}},
- + {"PC2", 2, 2, {"gpio_in", "gpio_out", "spi0", "mmc1"}},
- + {"PC3", 2, 3, {"gpio_in", "gpio_out", "spi0", "uart0"}},
- +
- + {"PD0", 3, 0, {"gpio_in", "gpio_out", "lcd", "twi0", "rsb", NULL, "irq"}, 6, 0},
- + {"PD1", 3, 1, {"gpio_in", "gpio_out", "lcd", "uart1", NULL, NULL, "irq"}, 6, 1},
- + {"PD2", 3, 2, {"gpio_in", "gpio_out", "lcd", "uart1", NULL, NULL, "irq"}, 6, 2},
- + {"PD3", 3, 3, {"gpio_in", "gpio_out", "lcd", "uart1", NULL, NULL, "irq"}, 6, 3},
- + {"PD4", 3, 4, {"gpio_in", "gpio_out", "lcd", "uart1", NULL, NULL, "irq"}, 6, 4},
- + {"PD5", 3, 5, {"gpio_in", "gpio_out", "lcd", "twi1", NULL, NULL, "irq"}, 6, 5},
- + {"PD6", 3, 6, {"gpio_in", "gpio_out", "lcd", "twi1", NULL, NULL, "irq"}, 6, 6},
- + {"PD7", 3, 7, {"gpio_in", "gpio_out", "lcd", "i2s", NULL, NULL, "irq"}, 6, 7},
- + {"PD8", 3, 8, {"gpio_in", "gpio_out", "lcd", "i2s", NULL, NULL, "irq"}, 6, 8},
- + {"PD9", 3, 9, {"gpio_in", "gpio_out", "lcd", "i2s", NULL, NULL, "irq"}, 6, 9},
- + {"PD10", 3, 10, {"gpio_in", "gpio_out", "lcd", "i2s", NULL, NULL, "irq"}, 6, 10},
- + {"PD11", 3, 11, {"gpio_in", "gpio_out", "lcd", "i2s", NULL, NULL, "irq"}, 6, 11},
- + {"PD12", 3, 12, {"gpio_in", "gpio_out", "lcd", "twi0", "rsb", NULL, "irq"}, 6, 12},
- + {"PD13", 3, 13, {"gpio_in", "gpio_out", "lcd", "uart2", NULL, NULL, "irq"}, 6, 13},
- + {"PD14", 3, 14, {"gpio_in", "gpio_out", "lcd", "uart2", NULL, NULL, "irq"}, 6, 14},
- + {"PD15", 3, 15, {"gpio_in", "gpio_out", "lcd", "uart2", "twi2", NULL, "irq"}, 6, 15},
- + {"PD16", 3, 16, {"gpio_in", "gpio_out", "lcd", "uart2", "twi2", NULL, "irq"}, 6, 16},
- + {"PD17", 3, 17, {"gpio_in", "gpio_out", "lcd", "owa", NULL, NULL, "irq"}, 6, 17},
- + {"PD18", 3, 18, {"gpio_in", "gpio_out", "lcd", "spi0", NULL, NULL, "irq"}, 6, 18},
- + {"PD19", 3, 19, {"gpio_in", "gpio_out", "lcd", "spi0", NULL, NULL, "irq"}, 6, 19},
- + {"PD20", 3, 20, {"gpio_in", "gpio_out", "lcd", "spi0", NULL, NULL, "irq"}, 6, 20},
- + {"PD21", 3, 21, {"gpio_in", "gpio_out", "lcd", "spi0", NULL, NULL, "irq"}, 6, 21},
- +
- + {"PE0", 4, 0, {"gpio_in", "gpio_out", "csi", "lcd", "twi2", "uart0", "irq"}, 6, 0},
- + {"PE1", 4, 1, {"gpio_in", "gpio_out", "csi", "lcd", "twi2", "uart0", "irq"}, 6, 1},
- + {"PE2", 4, 2, {"gpio_in", "gpio_out", "csi", "lcd", "clk_out", NULL, "irq"}, 6, 2},
- + {"PE3", 4, 3, {"gpio_in", "gpio_out", "csi", "lcd", "i2s", "rsb", "irq"}, 6, 3},
- + {"PE4", 4, 4, {"gpio_in", "gpio_out", "csi", "lcd", "i2s", "rsb", "irq"}, 6, 4},
- + {"PE5", 4, 5, {"gpio_in", "gpio_out", "csi", "lcd", "i2s", NULL, "irq"}, 6, 5},
- + {"PE6", 4, 6, {"gpio_in", "gpio_out", "csi", "pwm1", "i2s", "owa", "irq"}, 6, 6},
- + {"PE7", 4, 7, {"gpio_in", "gpio_out", "csi", "uart2", "spi1", NULL, "irq"}, 6, 7},
- + {"PE8", 4, 8, {"gpio_in", "gpio_out", "csi", "uart2", "spi1", NULL, "irq"}, 6, 8},
- + {"PE9", 4, 9, {"gpio_in", "gpio_out", "csi", "uart2", "spi1", NULL, "irq"}, 6, 9},
- + {"PE10", 4, 10, {"gpio_in", "gpio_out", "csi", "uart2", "spi1", NULL, "irq"}, 6, 10},
- + {"PE11", 4, 11, {"gpio_in", "gpio_out", "clk_out", "twi0", "ir", NULL, "irq"}, 6, 11},
- + {"PE12", 4, 12, {"gpio_in", "gpio_out", "i2s", "twi0", "pwm0", NULL, "irq"}, 6, 12},
- +
- + {"PF0", 5, 0, {"gpio_in", "gpio_out", "mmc0", "jtag", "ir", NULL, "irq"}, 6, 0},
- + {"PF1", 5, 1, {"gpio_in", "gpio_out", "mmc0", "jtag", NULL, NULL, "irq"}, 6, 1},
- + {"PF2", 5, 2, {"gpio_in", "gpio_out", "mmc0", "uart0", NULL, NULL, "irq"}, 6, 2},
- + {"PF3", 5, 3, {"gpio_in", "gpio_out", "mmc0", "jtag", NULL, NULL, "irq"}, 6, 3},
- + {"PF4", 5, 4, {"gpio_in", "gpio_out", "mmc0", "uart0", NULL, NULL, "irq"}, 6, 4},
- + {"PF5", 5, 5, {"gpio_in", "gpio_out", "mmc0", "jtag", "pwm1", NULL, "irq"}, 6, 5},
- +};
- +
- +const struct sunxi_gpio_padconf suniv_f1c100s_padconf = {
- + .npins = __arraycount(f1c100s_pins),
- + .pins = f1c100s_pins,
- +};
- diff -uNpr sunxi.orig/sunxi_gpio.c sunxi/sunxi_gpio.c
- --- sunxi.orig/sunxi_gpio.c 2019-10-02 12:02:11.000000000 +0900
- +++ sunxi/sunxi_gpio.c 2020-01-02 06:24:53.495296344 +0900
- @@ -117,6 +117,9 @@ static const struct of_compat_data compa
- { "allwinner,sun50i-h6-pinctrl", (uintptr_t)&sun50i_h6_padconf },
- { "allwinner,sun50i-h6-r-pinctrl", (uintptr_t)&sun50i_h6_r_padconf },
- #endif
- +#ifdef SOC_SUNIV_F1C100S
- + { "allwinner,suniv-f1c100s-pinctrl", (uintptr_t)&suniv_f1c100s_padconf },
- +#endif
- { NULL }
- };
- diff -uNpr sunxi.orig/sunxi_intc.c sunxi/sunxi_intc.c
- --- sunxi.orig/sunxi_intc.c 2017-10-25 12:01:15.000000000 +0900
- +++ sunxi/sunxi_intc.c 2020-01-02 06:25:00.230385161 +0900
- @@ -44,26 +44,53 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_intc.c
- #include <arm/pic/picvar.h>
- #include <arm/fdt/arm_fdtvar.h>
- -#define INTC_MAX_SOURCES 96
- -#define INTC_MAX_GROUPS 3
- +#define SUNXI_INTC_MAX_SOURCES 96
- +#define SUNXI_INTC_MAX_GROUPS 3
- -#define INTC_VECTOR_REG 0x00
- -#define INTC_BASE_ADDR_REG 0x04
- -#define INTC_PROTECT_REG 0x08
- -#define INTC_PROTECT_EN __BIT(0)
- -#define INTC_NMII_CTRL_REG 0x0c
- -#define INTC_IRQ_PEND_REG(n) (0x10 + ((n) * 4))
- -#define INTC_FIQ_PEND_REG(n) (0x20 + ((n) * 4))
- -#define INTC_SEL_REG(n) (0x30 + ((n) * 4))
- -#define INTC_EN_REG(n) (0x40 + ((n) * 4))
- -#define INTC_MASK_REG(n) (0x50 + ((n) * 4))
- -#define INTC_RESP_REG(n) (0x60 + ((n) * 4))
- -#define INTC_FORCE_REG(n) (0x70 + ((n) * 4))
- -#define INTC_SRC_PRIO_REG(n) (0x80 + ((n) * 4))
- -
- -static const char * const compatible[] = {
- - "allwinner,sun4i-a10-ic",
- - NULL
- +#define SUNIV_INTC_MAX_SOURCES 64
- +#define SUNIV_INTC_MAX_GROUPS 2
- +
- +#define INTC_MAX_SOURCES(sc) ((sc)->sc_conf->max_sources)
- +#define INTC_MAX_GROUPS(sc) ((sc)->sc_conf->max_groups)
- +
- +#define INTC_VECTOR_REG 0x00
- +#define INTC_BASE_ADDR_REG 0x04
- +#define INTC_PROTECT_REG(sc) ((sc)->sc_conf->protect_reg_offset)
- +#define INTC_PROTECT_EN __BIT(0)
- +#define INTC_IRQ_PEND_REG(n) (0x10 + ((n) * 4))
- +#define INTC_EN_REG(sc, n) \
- + ((sc)->sc_conf->en_reg_offset + ((n) * 4))
- +#define INTC_MASK_REG(sc, n) \
- + ((sc)->sc_conf->mask_reg_offset + ((n) * 4))
- +
- +struct sunxi_intc_config {
- + int max_sources;
- + int max_groups;
- + int protect_reg_offset;
- + int en_reg_offset;
- + int mask_reg_offset;
- +};
- +
- +static const struct sunxi_intc_config sun4i_a10_ic_config = {
- + .max_sources = SUNXI_INTC_MAX_SOURCES,
- + .max_groups = SUNXI_INTC_MAX_GROUPS,
- + .protect_reg_offset = 0x08,
- + .en_reg_offset = 0x40,
- + .mask_reg_offset = 0x50,
- +};
- +
- +static const struct sunxi_intc_config suniv_ic_config = {
- + .max_sources = SUNIV_INTC_MAX_SOURCES,
- + .max_groups = SUNIV_INTC_MAX_GROUPS,
- + .protect_reg_offset = 0, /* no PROTECT_REG */
- + .en_reg_offset = 0x20,
- + .mask_reg_offset = 0x30,
- +};
- +
- +static const struct of_compat_data compat_data[] = {
- + { "allwinner,sun4i-a10-ic", (uintptr_t)&sun4i_a10_ic_config },
- + { "allwinner,suniv-ic", (uintptr_t)&suniv_ic_config },
- + { NULL }
- };
- struct sunxi_intc_softc {
- @@ -72,7 +99,9 @@ struct sunxi_intc_softc {
- bus_space_handle_t sc_bsh;
- int sc_phandle;
- - uint32_t sc_enabled_irqs[INTC_MAX_GROUPS];
- + const struct sunxi_intc_config *sc_conf;
- +
- + uint32_t sc_enabled_irqs[SUNXI_INTC_MAX_GROUPS];
- struct pic_softc sc_pic;
- };
- @@ -95,8 +124,8 @@ sunxi_intc_unblock_irqs(struct pic_softc
- KASSERT((mask & sc->sc_enabled_irqs[group]) == 0);
- sc->sc_enabled_irqs[group] |= mask;
- - INTC_WRITE(sc, INTC_EN_REG(group), sc->sc_enabled_irqs[group]);
- - INTC_WRITE(sc, INTC_MASK_REG(group), ~sc->sc_enabled_irqs[group]);
- + INTC_WRITE(sc, INTC_EN_REG(sc, group), sc->sc_enabled_irqs[group]);
- + INTC_WRITE(sc, INTC_MASK_REG(sc, group), ~sc->sc_enabled_irqs[group]);
- }
- static void
- @@ -106,14 +135,16 @@ sunxi_intc_block_irqs(struct pic_softc *
- const u_int group = irqbase / 32;
- sc->sc_enabled_irqs[group] &= ~mask;
- - INTC_WRITE(sc, INTC_EN_REG(group), sc->sc_enabled_irqs[group]);
- - INTC_WRITE(sc, INTC_MASK_REG(group), ~sc->sc_enabled_irqs[group]);
- + INTC_WRITE(sc, INTC_EN_REG(sc, group), sc->sc_enabled_irqs[group]);
- + INTC_WRITE(sc, INTC_MASK_REG(sc, group), ~sc->sc_enabled_irqs[group]);
- }
- static void
- sunxi_intc_establish_irq(struct pic_softc *pic, struct intrsource *is)
- {
- - KASSERT(is->is_irq < INTC_MAX_SOURCES);
- + struct sunxi_intc_softc * const sc = PICTOSOFTC(pic);
- +
- + KASSERT(is->is_irq < INTC_MAX_SOURCES(sc));
- KASSERT(is->is_type == IST_LEVEL);
- }
- @@ -133,10 +164,12 @@ static void *
- sunxi_intc_fdt_establish(device_t dev, u_int *specifier, int ipl, int flags,
- int (*func)(void *), void *arg)
- {
- + struct sunxi_intc_softc * const sc = device_private(dev);
- +
- /* 1st cell is the interrupt number */
- const u_int irq = be32toh(specifier[0]);
- - if (irq >= INTC_MAX_SOURCES) {
- + if (irq >= INTC_MAX_SOURCES(sc)) {
- #ifdef DIAGNOSTIC
- device_printf(dev, "IRQ %u is invalid\n", irq);
- #endif
- @@ -196,16 +229,14 @@ sunxi_intc_irq_handler(void *frame)
- struct sunxi_intc_softc * const sc = intc_softc;
- const int oldipl = ci->ci_cpl;
- const uint32_t oldipl_mask = __BIT(oldipl);
- - int ipl_mask = 0;
- + int i, ipl_mask = 0;
- ci->ci_data.cpu_nintr++;
- - if (sc->sc_enabled_irqs[0])
- - ipl_mask |= sunxi_intc_find_pending_irqs(sc, 0);
- - if (sc->sc_enabled_irqs[1])
- - ipl_mask |= sunxi_intc_find_pending_irqs(sc, 1);
- - if (sc->sc_enabled_irqs[2])
- - ipl_mask |= sunxi_intc_find_pending_irqs(sc, 2);
- + for (i = 0; i < INTC_MAX_GROUPS(sc); i++) {
- + if (sc->sc_enabled_irqs[i])
- + ipl_mask |= sunxi_intc_find_pending_irqs(sc, i);
- + }
- if ((ipl_mask & ~oldipl_mask) > oldipl_mask)
- pic_do_pending_ints(I32_bit, oldipl, frame);
- @@ -216,7 +247,7 @@ sunxi_intc_match(device_t parent, cfdata
- {
- struct fdt_attach_args * const faa = aux;
- - return of_match_compatible(faa->faa_phandle, compatible);
- + return of_match_compat_data(faa->faa_phandle, compat_data);
- }
- static void
- @@ -241,22 +272,24 @@ sunxi_intc_attach(device_t parent, devic
- aprint_error(": couldn't map registers\n");
- return;
- }
- + sc->sc_conf = (void *)of_search_compatible(phandle, compat_data)->data;
- aprint_naive("\n");
- aprint_normal(": Interrupt Controller\n");
- /* Disable IRQs */
- - for (i = 0; i < INTC_MAX_GROUPS; i++) {
- - INTC_WRITE(sc, INTC_EN_REG(i), 0);
- - INTC_WRITE(sc, INTC_MASK_REG(i), ~0U);
- + for (i = 0; i < INTC_MAX_GROUPS(sc); i++) {
- + INTC_WRITE(sc, INTC_EN_REG(sc, i), 0);
- + INTC_WRITE(sc, INTC_MASK_REG(sc, i), ~0U);
- INTC_WRITE(sc, INTC_IRQ_PEND_REG(i),
- INTC_READ(sc, INTC_IRQ_PEND_REG(i)));
- }
- /* Disable user mode access to intc registers */
- - INTC_WRITE(sc, INTC_PROTECT_REG, INTC_PROTECT_EN);
- + if (INTC_PROTECT_REG(sc))
- + INTC_WRITE(sc, INTC_PROTECT_REG(sc), INTC_PROTECT_EN);
- sc->sc_pic.pic_ops = &sunxi_intc_picops;
- - sc->sc_pic.pic_maxsources = INTC_MAX_SOURCES;
- + sc->sc_pic.pic_maxsources = INTC_MAX_SOURCES(sc);
- snprintf(sc->sc_pic.pic_name, sizeof(sc->sc_pic.pic_name), "intc");
- pic_add(&sc->sc_pic, 0);
- diff -uNpr sunxi.orig/sunxi_timer.c sunxi/sunxi_timer.c
- --- sunxi.orig/sunxi_timer.c 2019-06-15 12:01:42.000000000 +0900
- +++ sunxi/sunxi_timer.c 2020-01-02 06:25:04.595255627 +0900
- @@ -91,9 +91,11 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_timer.
- #define LOSC_CTRL_OSC32K_AUTO_SWT_EN __BIT(14)
- #define LOSC_CTRL_OSC32K_SEL __BIT(0)
- -static const char * const compatible[] = {
- - "allwinner,sun4i-a10-timer",
- - NULL
- +static const struct of_compat_data compat_data[] = {
- + { "allwinner,sun4i-a10-timer", 6 },
- + { "allwinner,sun8i-v3s-timer", 3 },
- + { "allwinner,suniv-f1c100s-timer", 3 },
- + { NULL }
- };
- struct sunxi_timer_softc {
- @@ -103,6 +105,8 @@ struct sunxi_timer_softc {
- int sc_phandle;
- struct clk *sc_clk;
- + int sc_ntimers;
- +
- struct timecounter sc_tc;
- struct timecounter sc_tc_losc;
- };
- @@ -178,7 +182,7 @@ sunxi_timer_match(device_t parent, cfdat
- {
- struct fdt_attach_args * const faa = aux;
- - return of_match_compatible(faa->faa_phandle, compatible);
- + return of_match_compat_data(faa->faa_phandle, compat_data);
- }
- static void
- @@ -211,6 +215,7 @@ sunxi_timer_attach(device_t parent, devi
- aprint_error(": couldn't map registers\n");
- return;
- }
- + sc->sc_ntimers = of_search_compatible(phandle, compat_data)->data;
- aprint_naive("\n");
- aprint_normal(": Timer\n");
- @@ -230,9 +235,6 @@ sunxi_timer_attach(device_t parent, devi
- TIMER_WRITE(sc, TMR2_CTRL_REG,
- __SHIFTIN(TMR2_CTRL_CLK_SRC_OSC24M, TMR2_CTRL_CLK_SRC) |
- TMR2_CTRL_RELOAD | TMR2_CTRL_EN);
- - /* Enable Timer 4 (timecounter for LOSC) */
- - TIMER_WRITE(sc, TMR4_INTV_VALUE_REG, ~0u);
- - TIMER_WRITE(sc, TMR4_CTRL_REG, TMR4_CTRL_RELOAD | TMR4_CTRL_EN);
- /* Timecounter setup */
- tc->tc_get_timecount = sunxi_timer_get_timecount;
- @@ -242,26 +244,31 @@ sunxi_timer_attach(device_t parent, devi
- tc->tc_quality = 200;
- tc->tc_priv = sc;
- tc_init(tc);
- - tc_losc->tc_get_timecount = sunxi_timer_get_timecount_losc;
- - tc_losc->tc_counter_mask = ~0u;
- - tc_losc->tc_frequency = 32768;
- - tc_losc->tc_name = "LOSC";
- - tc_losc->tc_quality = 150;
- - tc_losc->tc_priv = sc;
- - /*
- - * LOSC is optional to implement in hardware.
- - * Make sure it ticks before registering it.
- - */
- - reg = __SHIFTIN(LOSC_CTRL_KEY_FIELD_V, LOSC_CTRL_KEY_FIELD) |
- - LOSC_CTRL_OSC32K_AUTO_SWT_EN |
- - LOSC_CTRL_OSC32K_SEL;
- - TIMER_WRITE(sc, LOSC_CTRL_REG, reg);
- - ticks = sunxi_timer_get_timecount_losc(tc_losc);
- - delay(100);
- - if (ticks != sunxi_timer_get_timecount_losc(tc_losc))
- - tc_init(tc_losc);
- - else
- - TIMER_WRITE(sc, LOSC_CTRL_REG, reg & ~LOSC_CTRL_OSC32K_SEL);
- +
- + /* Timer 4 (timecounter for LOSC) is optional */
- + if (sc->sc_ntimers > 3) {
- + tc_losc->tc_get_timecount = sunxi_timer_get_timecount_losc;
- + tc_losc->tc_counter_mask = ~0u;
- + tc_losc->tc_frequency = 32768;
- + tc_losc->tc_name = "LOSC";
- + tc_losc->tc_quality = 150;
- + tc_losc->tc_priv = sc;
- +
- + /* Make sure it ticks before registering it. */
- + TIMER_WRITE(sc, TMR4_INTV_VALUE_REG, ~0u);
- + TIMER_WRITE(sc, TMR4_CTRL_REG, TMR4_CTRL_RELOAD | TMR4_CTRL_EN);
- + reg = __SHIFTIN(LOSC_CTRL_KEY_FIELD_V, LOSC_CTRL_KEY_FIELD) |
- + LOSC_CTRL_OSC32K_AUTO_SWT_EN |
- + LOSC_CTRL_OSC32K_SEL;
- + TIMER_WRITE(sc, LOSC_CTRL_REG, reg);
- + ticks = sunxi_timer_get_timecount_losc(tc_losc);
- + delay(100);
- + if (ticks != sunxi_timer_get_timecount_losc(tc_losc))
- + tc_init(tc_losc);
- + else
- + TIMER_WRITE(sc, LOSC_CTRL_REG,
- + reg & ~LOSC_CTRL_OSC32K_SEL);
- + }
- /* Use this as the OS timer in UP configurations */
- if (!arm_has_mpext_p) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement