Sun Oct 8 18:00:36 2017 UTC ()
Add Allwinner A80 (sun9i) support.
(jmcneill)
diff -r1.31 -r1.32 src/sys/arch/arm/sunxi/files.sunxi
diff -r0 -r1.1 src/sys/arch/arm/sunxi/sun9i_a80_ccu.c
diff -r0 -r1.1 src/sys/arch/arm/sunxi/sun9i_a80_ccu.h
diff -r0 -r1.1 src/sys/arch/arm/sunxi/sun9i_a80_gpio.c
diff -r0 -r1.1 src/sys/arch/arm/sunxi/sun9i_a80_mmcclk.c
diff -r1.14 -r1.15 src/sys/arch/arm/sunxi/sunxi_gpio.c
diff -r1.6 -r1.7 src/sys/arch/arm/sunxi/sunxi_gpio.h
diff -r1.9 -r1.10 src/sys/arch/arm/sunxi/sunxi_mmc.c
diff -r1.9 -r1.10 src/sys/arch/arm/sunxi/sunxi_platform.c
diff -r1.1 -r1.2 src/sys/arch/arm/sunxi/sunxi_platform.h
--- src/sys/arch/arm/sunxi/files.sunxi 2017/10/07 21:53:16 1.31
+++ src/sys/arch/arm/sunxi/files.sunxi 2017/10/08 18:00:36 1.32
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: files.sunxi,v 1.31 2017/10/07 21:53:16 jmcneill Exp $ | | 1 | # $NetBSD: files.sunxi,v 1.32 2017/10/08 18:00:36 jmcneill Exp $ |
2 | # | | 2 | # |
3 | # Configuration info for Allwinner sunxi family SoCs | | 3 | # Configuration info for Allwinner sunxi family SoCs |
4 | # | | 4 | # |
5 | # | | 5 | # |
6 | | | 6 | |
7 | include "arch/arm/pic/files.pic" | | 7 | include "arch/arm/pic/files.pic" |
8 | include "arch/arm/cortex/files.cortex" | | 8 | include "arch/arm/cortex/files.cortex" |
9 | | | 9 | |
10 | file arch/arm/arm32/arm32_boot.c | | 10 | file arch/arm/arm32/arm32_boot.c |
11 | file arch/arm/arm32/arm32_kvminit.c | | 11 | file arch/arm/arm32/arm32_kvminit.c |
12 | file arch/arm/arm32/arm32_reboot.c | | 12 | file arch/arm/arm32/arm32_reboot.c |
13 | file arch/arm/arm32/irq_dispatch.S | | 13 | file arch/arm/arm32/irq_dispatch.S |
14 | file arch/arm/arm32/armv7_generic_space.c | | 14 | file arch/arm/arm32/armv7_generic_space.c |
| @@ -48,61 +48,72 @@ device sun8ia83tccu: sunxi_ccu | | | @@ -48,61 +48,72 @@ device sun8ia83tccu: sunxi_ccu |
48 | attach sun8ia83tccu at fdt with sunxi_a83t_ccu | | 48 | attach sun8ia83tccu at fdt with sunxi_a83t_ccu |
49 | file arch/arm/sunxi/sun8i_a83t_ccu.c sunxi_a83t_ccu | | 49 | file arch/arm/sunxi/sun8i_a83t_ccu.c sunxi_a83t_ccu |
50 | | | 50 | |
51 | # CCU (H3) | | 51 | # CCU (H3) |
52 | device sun8ih3ccu: sunxi_ccu | | 52 | device sun8ih3ccu: sunxi_ccu |
53 | attach sun8ih3ccu at fdt with sunxi_h3_ccu | | 53 | attach sun8ih3ccu at fdt with sunxi_h3_ccu |
54 | file arch/arm/sunxi/sun8i_h3_ccu.c sunxi_h3_ccu | | 54 | file arch/arm/sunxi/sun8i_h3_ccu.c sunxi_h3_ccu |
55 | | | 55 | |
56 | # CCU (H3 PRCM) | | 56 | # CCU (H3 PRCM) |
57 | device sun8ih3rccu: sunxi_ccu | | 57 | device sun8ih3rccu: sunxi_ccu |
58 | attach sun8ih3rccu at fdt with sunxi_h3_r_ccu | | 58 | attach sun8ih3rccu at fdt with sunxi_h3_r_ccu |
59 | file arch/arm/sunxi/sun8i_h3_r_ccu.c sunxi_h3_r_ccu | | 59 | file arch/arm/sunxi/sun8i_h3_r_ccu.c sunxi_h3_r_ccu |
60 | | | 60 | |
| | | 61 | # CCU (A80) |
| | | 62 | device sun9ia80ccu: sunxi_ccu |
| | | 63 | attach sun9ia80ccu at fdt with sunxi_a80_ccu |
| | | 64 | file arch/arm/sunxi/sun9i_a80_ccu.c sunxi_a80_ccu |
| | | 65 | |
61 | # CCU (A64) | | 66 | # CCU (A64) |
62 | device sun50ia64ccu: sunxi_ccu | | 67 | device sun50ia64ccu: sunxi_ccu |
63 | attach sun50ia64ccu at fdt with sunxi_a64_ccu | | 68 | attach sun50ia64ccu at fdt with sunxi_a64_ccu |
64 | file arch/arm/sunxi/sun50i_a64_ccu.c sunxi_a64_ccu | | 69 | file arch/arm/sunxi/sun50i_a64_ccu.c sunxi_a64_ccu |
65 | | | 70 | |
66 | # Misc. clock resets | | 71 | # Misc. clock resets |
67 | device sunxiresets | | 72 | device sunxiresets |
68 | attach sunxiresets at fdt with sunxi_resets | | 73 | attach sunxiresets at fdt with sunxi_resets |
69 | file arch/arm/sunxi/sunxi_resets.c sunxi_resets | | 74 | file arch/arm/sunxi/sunxi_resets.c sunxi_resets |
70 | | | 75 | |
71 | # Misc. clock gates | | 76 | # Misc. clock gates |
72 | device sunxigates | | 77 | device sunxigates |
73 | attach sunxigates at fdt with sunxi_gates | | 78 | attach sunxigates at fdt with sunxi_gates |
74 | file arch/arm/sunxi/sunxi_gates.c sunxi_gates | | 79 | file arch/arm/sunxi/sunxi_gates.c sunxi_gates |
75 | | | 80 | |
76 | # GMAC MII/RGMII clock mux | | 81 | # GMAC MII/RGMII clock mux |
77 | device sunxigmacclk | | 82 | device sunxigmacclk |
78 | attach sunxigmacclk at fdt with sunxi_gmacclk | | 83 | attach sunxigmacclk at fdt with sunxi_gmacclk |
79 | file arch/arm/sunxi/sunxi_gmacclk.c sunxi_gmacclk | | 84 | file arch/arm/sunxi/sunxi_gmacclk.c sunxi_gmacclk |
80 | | | 85 | |
| | | 86 | # SD/MMC-COMM (A80) |
| | | 87 | device sun9immcclk |
| | | 88 | attach sun9immcclk at fdt with sunxi_a80_mmcclk |
| | | 89 | file arch/arm/sunxi/sun9i_a80_mmcclk.c sunxi_a80_mmcclk |
| | | 90 | |
81 | # Interrupt controller | | 91 | # Interrupt controller |
82 | device sunxiintc: pic, pic_splfuncs | | 92 | device sunxiintc: pic, pic_splfuncs |
83 | attach sunxiintc at fdt with sunxi_intc | | 93 | attach sunxiintc at fdt with sunxi_intc |
84 | file arch/arm/sunxi/sunxi_intc.c sunxi_intc | | 94 | file arch/arm/sunxi/sunxi_intc.c sunxi_intc |
85 | | | 95 | |
86 | # GPIO | | 96 | # GPIO |
87 | device sunxigpio: gpiobus | | 97 | device sunxigpio: gpiobus |
88 | attach sunxigpio at fdt with sunxi_gpio | | 98 | attach sunxigpio at fdt with sunxi_gpio |
89 | file arch/arm/sunxi/sunxi_gpio.c sunxi_gpio | | 99 | file arch/arm/sunxi/sunxi_gpio.c sunxi_gpio |
90 | file arch/arm/sunxi/sun4i_a10_gpio.c sunxi_gpio & soc_sun4i_a10 | | 100 | file arch/arm/sunxi/sun4i_a10_gpio.c sunxi_gpio & soc_sun4i_a10 |
91 | file arch/arm/sunxi/sun5i_a13_gpio.c sunxi_gpio & soc_sun5i_a13 | | 101 | file arch/arm/sunxi/sun5i_a13_gpio.c sunxi_gpio & soc_sun5i_a13 |
92 | file arch/arm/sunxi/sun6i_a31_gpio.c sunxi_gpio & soc_sun6i_a31 | | 102 | file arch/arm/sunxi/sun6i_a31_gpio.c sunxi_gpio & soc_sun6i_a31 |
93 | file arch/arm/sunxi/sun7i_a20_gpio.c sunxi_gpio & soc_sun7i_a20 | | 103 | file arch/arm/sunxi/sun7i_a20_gpio.c sunxi_gpio & soc_sun7i_a20 |
94 | file arch/arm/sunxi/sun8i_a83t_gpio.c sunxi_gpio & soc_sun8i_a83t | | 104 | file arch/arm/sunxi/sun8i_a83t_gpio.c sunxi_gpio & soc_sun8i_a83t |
95 | file arch/arm/sunxi/sun8i_h3_gpio.c sunxi_gpio & soc_sun8i_h3 | | 105 | file arch/arm/sunxi/sun8i_h3_gpio.c sunxi_gpio & soc_sun8i_h3 |
| | | 106 | file arch/arm/sunxi/sun9i_a80_gpio.c sunxi_gpio & soc_sun9i_a80 |
96 | file arch/arm/sunxi/sun50i_a64_gpio.c sunxi_gpio & soc_sun50i_a64 | | 107 | file arch/arm/sunxi/sun50i_a64_gpio.c sunxi_gpio & soc_sun50i_a64 |
97 | | | 108 | |
98 | # UART | | 109 | # UART |
99 | attach com at fdt with sunxi_com | | 110 | attach com at fdt with sunxi_com |
100 | file arch/arm/sunxi/sunxi_com.c sunxi_com needs-flag | | 111 | file arch/arm/sunxi/sunxi_com.c sunxi_com needs-flag |
101 | | | 112 | |
102 | # SD/MMC | | 113 | # SD/MMC |
103 | device sunximmc: sdmmcbus | | 114 | device sunximmc: sdmmcbus |
104 | attach sunximmc at fdt with sunxi_mmc | | 115 | attach sunximmc at fdt with sunxi_mmc |
105 | file arch/arm/sunxi/sunxi_mmc.c sunxi_mmc | | 116 | file arch/arm/sunxi/sunxi_mmc.c sunxi_mmc |
106 | | | 117 | |
107 | # USB PHY | | 118 | # USB PHY |
108 | device sunxiusbphy | | 119 | device sunxiusbphy |
| @@ -203,15 +214,17 @@ file arch/arm/sunxi/sunxi_sata.c sunxi_ | | | @@ -203,15 +214,17 @@ file arch/arm/sunxi/sunxi_sata.c sunxi_ |
203 | # SOC parameters | | 214 | # SOC parameters |
204 | defflag opt_soc.h SOC_SUNXI | | 215 | defflag opt_soc.h SOC_SUNXI |
205 | defflag opt_soc.h SOC_SUN4I: SOC_SUNXI | | 216 | defflag opt_soc.h SOC_SUN4I: SOC_SUNXI |
206 | defflag opt_soc.h SOC_SUN4I_A10: SOC_SUN4I | | 217 | defflag opt_soc.h SOC_SUN4I_A10: SOC_SUN4I |
207 | defflag opt_soc.h SOC_SUN5I: SOC_SUNXI | | 218 | defflag opt_soc.h SOC_SUN5I: SOC_SUNXI |
208 | defflag opt_soc.h SOC_SUN5I_A13: SOC_SUN5I | | 219 | defflag opt_soc.h SOC_SUN5I_A13: SOC_SUN5I |
209 | defflag opt_soc.h SOC_SUN6I: SOC_SUNXI | | 220 | defflag opt_soc.h SOC_SUN6I: SOC_SUNXI |
210 | defflag opt_soc.h SOC_SUN6I_A31: SOC_SUN6I | | 221 | defflag opt_soc.h SOC_SUN6I_A31: SOC_SUN6I |
211 | defflag opt_soc.h SOC_SUN7I: SOC_SUNXI | | 222 | defflag opt_soc.h SOC_SUN7I: SOC_SUNXI |
212 | defflag opt_soc.h SOC_SUN7I_A20: SOC_SUN7I | | 223 | defflag opt_soc.h SOC_SUN7I_A20: SOC_SUN7I |
213 | defflag opt_soc.h SOC_SUN8I: SOC_SUNXI | | 224 | defflag opt_soc.h SOC_SUN8I: SOC_SUNXI |
214 | defflag opt_soc.h SOC_SUN8I_A83T: SOC_SUN8I | | 225 | defflag opt_soc.h SOC_SUN8I_A83T: SOC_SUN8I |
215 | defflag opt_soc.h SOC_SUN8I_H3: SOC_SUN8I | | 226 | defflag opt_soc.h SOC_SUN8I_H3: SOC_SUN8I |
| | | 227 | defflag opt_soc.h SOC_SUN9I: SOC_SUNXI |
| | | 228 | defflag opt_soc.h SOC_SUN9I_A80: SOC_SUN9I |
216 | defflag opt_soc.h SOC_SUN50I: SOC_SUNXI | | 229 | defflag opt_soc.h SOC_SUN50I: SOC_SUNXI |
217 | defflag opt_soc.h SOC_SUN50I_A64: SOC_SUN50I | | 230 | defflag opt_soc.h SOC_SUN50I_A64: SOC_SUN50I |
/* $NetBSD: sun9i_a80_ccu.c,v 1.1 2017/10/08 18:00:36 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca>
* 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: sun9i_a80_ccu.c,v 1.1 2017/10/08 18:00:36 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/sun9i_a80_ccu.h>
/* CCU */
#define PLL_PERIPH0_CTRL_REG 0x00c
#define PLL_PERIPH1_CTRL_REG 0x02c
#define GTBUS_CLK_CFG_REG 0x05c
#define AHB0_CLK_CFG_REG 0x060
#define AHB1_CLK_CFG_REG 0x064
#define AHB2_CLK_CFG_REG 0x068
#define APB0_CLK_CFG_REG 0x070
#define APB1_CLK_CFG_REG 0x074
/* CCU_SCLK */
#define SDMMC0_CLK_REG 0x410
#define SDMMC1_CLK_REG 0x414
#define SDMMC2_CLK_REG 0x418
#define BUS_CLK_GATING_REG0 0x580
#define BUS_CLK_GATING_REG1 0x584
#define BUS_CLK_GATING_REG2 0x588
#define BUS_CLK_GATING_REG3 0x590
#define BUS_CLK_GATING_REG4 0x594
#define BUS_SOFT_RST_REG0 0x5a0
#define BUS_SOFT_RST_REG1 0x5a4
#define BUS_SOFT_RST_REG2 0x5a8
#define BUS_SOFT_RST_REG3 0x5b0
#define BUS_SOFT_RST_REG4 0x5b4
static int sun9i_a80_ccu_match(device_t, cfdata_t, void *);
static void sun9i_a80_ccu_attach(device_t, device_t, void *);
static const char * compatible[] = {
"allwinner,sun9i-a80-ccu",
NULL
};
CFATTACH_DECL_NEW(sunxi_a80_ccu, sizeof(struct sunxi_ccu_softc),
sun9i_a80_ccu_match, sun9i_a80_ccu_attach, NULL, NULL);
static struct sunxi_ccu_reset sun9i_a80_ccu_resets[] = {
SUNXI_CCU_RESET(A80_RST_BUS_FD, BUS_SOFT_RST_REG0, 0),
SUNXI_CCU_RESET(A80_RST_BUS_GPU_CTRL, BUS_SOFT_RST_REG0, 3),
SUNXI_CCU_RESET(A80_RST_BUS_SS, BUS_SOFT_RST_REG0, 5),
SUNXI_CCU_RESET(A80_RST_BUS_MMC, BUS_SOFT_RST_REG0, 8),
SUNXI_CCU_RESET(A80_RST_BUS_NAND1, BUS_SOFT_RST_REG0, 12),
SUNXI_CCU_RESET(A80_RST_BUS_NAND0, BUS_SOFT_RST_REG0, 13),
SUNXI_CCU_RESET(A80_RST_BUS_TS, BUS_SOFT_RST_REG0, 18),
SUNXI_CCU_RESET(A80_RST_BUS_SPI0, BUS_SOFT_RST_REG0, 20),
SUNXI_CCU_RESET(A80_RST_BUS_SPI1, BUS_SOFT_RST_REG0, 21),
SUNXI_CCU_RESET(A80_RST_BUS_SPI2, BUS_SOFT_RST_REG0, 22),
SUNXI_CCU_RESET(A80_RST_BUS_SPI3, BUS_SOFT_RST_REG0, 23),
SUNXI_CCU_RESET(A80_RST_BUS_OTG_PHY, BUS_SOFT_RST_REG1, 1),
SUNXI_CCU_RESET(A80_RST_BUS_MSGBOX, BUS_SOFT_RST_REG1, 21),
SUNXI_CCU_RESET(A80_RST_BUS_SPINLOCK, BUS_SOFT_RST_REG1, 22),
SUNXI_CCU_RESET(A80_RST_BUS_HSTIMER, BUS_SOFT_RST_REG1, 23),
SUNXI_CCU_RESET(A80_RST_BUS_DMA, BUS_SOFT_RST_REG1, 24),
SUNXI_CCU_RESET(A80_RST_BUS_LCD0, BUS_SOFT_RST_REG2, 0),
SUNXI_CCU_RESET(A80_RST_BUS_LCD1, BUS_SOFT_RST_REG2, 1),
SUNXI_CCU_RESET(A80_RST_BUS_CSI, BUS_SOFT_RST_REG2, 4),
SUNXI_CCU_RESET(A80_RST_BUS_DE, BUS_SOFT_RST_REG2, 7),
SUNXI_CCU_RESET(A80_RST_BUS_MP, BUS_SOFT_RST_REG2, 8),
SUNXI_CCU_RESET(A80_RST_BUS_GPU, BUS_SOFT_RST_REG2, 9),
SUNXI_CCU_RESET(A80_RST_BUS_LRADC, BUS_SOFT_RST_REG3, 15),
SUNXI_CCU_RESET(A80_RST_BUS_GPADC, BUS_SOFT_RST_REG3, 17),
SUNXI_CCU_RESET(A80_RST_BUS_I2C0, BUS_SOFT_RST_REG4, 0),
SUNXI_CCU_RESET(A80_RST_BUS_I2C1, BUS_SOFT_RST_REG4, 1),
SUNXI_CCU_RESET(A80_RST_BUS_I2C2, BUS_SOFT_RST_REG4, 2),
SUNXI_CCU_RESET(A80_RST_BUS_I2C3, BUS_SOFT_RST_REG4, 3),
SUNXI_CCU_RESET(A80_RST_BUS_I2C4, BUS_SOFT_RST_REG4, 4),
SUNXI_CCU_RESET(A80_RST_BUS_UART0, BUS_SOFT_RST_REG4, 16),
SUNXI_CCU_RESET(A80_RST_BUS_UART1, BUS_SOFT_RST_REG4, 17),
SUNXI_CCU_RESET(A80_RST_BUS_UART2, BUS_SOFT_RST_REG4, 18),
SUNXI_CCU_RESET(A80_RST_BUS_UART3, BUS_SOFT_RST_REG4, 19),
SUNXI_CCU_RESET(A80_RST_BUS_UART4, BUS_SOFT_RST_REG4, 20),
SUNXI_CCU_RESET(A80_RST_BUS_UART5, BUS_SOFT_RST_REG4, 21),
};
static const char *gtbus_parents[] = { "hosc", "pll_periph0", "pll_periph1" };
static const char *ahb0_parents[] = { "gtbus", "pll_periph0", "pll_periph1" };
static const char *ahb1_parents[] = { "gtbus", "pll_periph0", "pll_periph1" };
static const char *ahb2_parents[] = { "hosc", "pll_periph0", "pll_periph1" };
static const char *apb_parents[] = { "hosc", "pll_periph0" };
static const char *mmc_parents[] = { "hosc", "pll_periph0" };
static struct sunxi_ccu_clk sun9i_a80_ccu_clks[] = {
SUNXI_CCU_NKMP(A80_CLK_PLL_PERIPH0, "pll_periph0", "hosc",
PLL_PERIPH0_CTRL_REG, /* reg */
__BITS(15,8), /* n */
__BIT(16), /* k */
0, /* m */
__BIT(18), /* p */
__BIT(31), /* enable */
SUNXI_CCU_NKMP_FACTOR_N_EXACT),
SUNXI_CCU_NKMP(A80_CLK_PLL_PERIPH1, "pll_periph1", "hosc",
PLL_PERIPH1_CTRL_REG, /* reg */
__BITS(15,8), /* n */
__BIT(16), /* k */
0, /* m */
__BIT(18), /* p */
__BIT(31), /* enable */
SUNXI_CCU_NKMP_FACTOR_N_EXACT),
SUNXI_CCU_DIV(A80_CLK_GTBUS, "gtbus", gtbus_parents,
GTBUS_CLK_CFG_REG, /* reg */
__BITS(1,0), /* div */
__BITS(25,24), /* sel */
0),
SUNXI_CCU_DIV(A80_CLK_AHB0, "ahb0", ahb0_parents,
AHB0_CLK_CFG_REG, /* reg */
__BITS(1,0), /* div */
__BITS(25,24), /* sel */
SUNXI_CCU_DIV_POWER_OF_TWO),
SUNXI_CCU_DIV(A80_CLK_AHB1, "ahb1", ahb1_parents,
AHB1_CLK_CFG_REG, /* reg */
__BITS(1,0), /* div */
__BITS(25,24), /* sel */
SUNXI_CCU_DIV_POWER_OF_TWO),
SUNXI_CCU_DIV(A80_CLK_AHB2, "ahb2", ahb2_parents,
AHB2_CLK_CFG_REG, /* reg */
__BITS(1,0), /* div */
__BITS(25,24), /* sel */
SUNXI_CCU_DIV_POWER_OF_TWO),
SUNXI_CCU_DIV(A80_CLK_APB0, "apb0", apb_parents,
APB0_CLK_CFG_REG, /* reg */
__BITS(1,0), /* div */
__BIT(24), /* sel */
SUNXI_CCU_DIV_POWER_OF_TWO),
SUNXI_CCU_NM(A80_CLK_APB1, "apb1", apb_parents,
APB1_CLK_CFG_REG, /* reg */
__BITS(17,16), /* n */
__BITS(4,0), /* m */
__BIT(24), /* sel */
0, /* enable */
SUNXI_CCU_NM_POWER_OF_TWO),
SUNXI_CCU_NM(A80_CLK_MMC0, "mmc0", mmc_parents,
SDMMC0_CLK_REG, /* reg */
__BITS(17,16), /* n */
__BITS(3,0), /* m */
__BITS(27,24), /* sel */
__BIT(31), /* enable */
SUNXI_CCU_NM_POWER_OF_TWO),
SUNXI_CCU_PHASE(A80_CLK_MMC0_SAMPLE, "mmc0_sample", "mmc0",
SDMMC0_CLK_REG, __BITS(22,20)),
SUNXI_CCU_PHASE(A80_CLK_MMC0_OUTPUT, "mmc0_output", "mmc0",
SDMMC0_CLK_REG, __BITS(10,8)),
SUNXI_CCU_NM(A80_CLK_MMC1, "mmc1", mmc_parents,
SDMMC1_CLK_REG, /* reg */
__BITS(17,16), /* n */
__BITS(3,0), /* m */
__BITS(27,24), /* sel */
__BIT(31), /* enable */
SUNXI_CCU_NM_POWER_OF_TWO),
SUNXI_CCU_PHASE(A80_CLK_MMC1_SAMPLE, "mmc1_sample", "mmc1",
SDMMC1_CLK_REG, __BITS(22,20)),
SUNXI_CCU_PHASE(A80_CLK_MMC1_OUTPUT, "mmc1_output", "mmc1",
SDMMC1_CLK_REG, __BITS(10,8)),
SUNXI_CCU_NM(A80_CLK_MMC2, "mmc2", mmc_parents,
SDMMC2_CLK_REG, /* reg */
__BITS(17,16), /* n */
__BITS(3,0), /* m */
__BITS(27,24), /* sel */
__BIT(31), /* enable */
SUNXI_CCU_NM_POWER_OF_TWO),
SUNXI_CCU_PHASE(A80_CLK_MMC2_SAMPLE, "mmc2_sample", "mmc2",
SDMMC2_CLK_REG, __BITS(22,20)),
SUNXI_CCU_PHASE(A80_CLK_MMC2_OUTPUT, "mmc2_output", "mmc2",
SDMMC2_CLK_REG, __BITS(10,8)),
SUNXI_CCU_GATE(A80_CLK_BUS_FD, "ahb0-fd", "ahb0",
BUS_CLK_GATING_REG0, 0),
SUNXI_CCU_GATE(A80_CLK_BUS_GPU_CTRL, "ahb0-gpu-ctrl", "ahb0",
BUS_CLK_GATING_REG0, 3),
SUNXI_CCU_GATE(A80_CLK_BUS_SS, "ahb0-ss", "ahb0",
BUS_CLK_GATING_REG0, 5),
SUNXI_CCU_GATE(A80_CLK_BUS_MMC, "ahb0-mmc", "ahb0",
BUS_CLK_GATING_REG0, 8),
SUNXI_CCU_GATE(A80_CLK_BUS_NAND1, "ahb0-nand1", "ahb0",
BUS_CLK_GATING_REG0, 12),
SUNXI_CCU_GATE(A80_CLK_BUS_NAND0, "ahb0-nand0", "ahb0",
BUS_CLK_GATING_REG0, 13),
SUNXI_CCU_GATE(A80_CLK_BUS_TS, "ahb0-ts", "ahb0",
BUS_CLK_GATING_REG0, 18),
SUNXI_CCU_GATE(A80_CLK_BUS_SPI0, "ahb0-spi0", "ahb0",
BUS_CLK_GATING_REG0, 20),
SUNXI_CCU_GATE(A80_CLK_BUS_SPI1, "ahb0-spi1", "ahb0",
BUS_CLK_GATING_REG0, 21),
SUNXI_CCU_GATE(A80_CLK_BUS_SPI2, "ahb0-spi2", "ahb0",
BUS_CLK_GATING_REG0, 22),
SUNXI_CCU_GATE(A80_CLK_BUS_SPI3, "ahb0-spi3", "ahb0",
BUS_CLK_GATING_REG0, 23),
SUNXI_CCU_GATE(A80_CLK_BUS_USB, "ahb1-usb", "ahb1",
BUS_CLK_GATING_REG1, 1),
SUNXI_CCU_GATE(A80_CLK_BUS_MSGBOX, "ahb1-msgbox", "ahb1",
BUS_CLK_GATING_REG1, 21),
SUNXI_CCU_GATE(A80_CLK_BUS_SPINLOCK, "ahb1-spinlock", "ahb1",
BUS_CLK_GATING_REG1, 22),
SUNXI_CCU_GATE(A80_CLK_BUS_HSTIMER, "ahb1-hstimer", "ahb1",
BUS_CLK_GATING_REG1, 23),
SUNXI_CCU_GATE(A80_CLK_BUS_DMA, "ahb1-dma", "ahb1",
BUS_CLK_GATING_REG1, 24),
SUNXI_CCU_GATE(A80_CLK_BUS_LCD0, "ahb2-lcd0", "ahb2",
BUS_CLK_GATING_REG2, 0),
SUNXI_CCU_GATE(A80_CLK_BUS_LCD1, "ahb2-lcd1", "ahb2",
BUS_CLK_GATING_REG2, 1),
SUNXI_CCU_GATE(A80_CLK_BUS_CSI, "ahb2-csi", "ahb2",
BUS_CLK_GATING_REG2, 4),
SUNXI_CCU_GATE(A80_CLK_BUS_DE, "ahb2-de", "ahb2",
BUS_CLK_GATING_REG2, 7),
SUNXI_CCU_GATE(A80_CLK_BUS_MP, "ahb2-mp", "ahb2",
BUS_CLK_GATING_REG2, 8),
SUNXI_CCU_GATE(A80_CLK_BUS_PIO, "apb0-pio", "apb0",
BUS_CLK_GATING_REG3, 5),
SUNXI_CCU_GATE(A80_CLK_BUS_LRADC, "apb0-lradc", "apb0",
BUS_CLK_GATING_REG3, 15),
SUNXI_CCU_GATE(A80_CLK_BUS_GPADC, "apb0-gpadc", "apb0",
BUS_CLK_GATING_REG3, 17),
SUNXI_CCU_GATE(A80_CLK_BUS_I2C0, "apb1-i2c0", "apb1",
BUS_CLK_GATING_REG4, 0),
SUNXI_CCU_GATE(A80_CLK_BUS_I2C1, "apb1-i2c1", "apb1",
BUS_CLK_GATING_REG4, 1),
SUNXI_CCU_GATE(A80_CLK_BUS_I2C2, "apb1-i2c2", "apb1",
BUS_CLK_GATING_REG4, 2),
SUNXI_CCU_GATE(A80_CLK_BUS_I2C3, "apb1-i2c3", "apb1",
BUS_CLK_GATING_REG4, 3),
SUNXI_CCU_GATE(A80_CLK_BUS_I2C4, "apb1-i2c4", "apb1",
BUS_CLK_GATING_REG4, 4),
SUNXI_CCU_GATE(A80_CLK_BUS_UART0, "apb1-uart0", "apb1",
BUS_CLK_GATING_REG4, 16),
SUNXI_CCU_GATE(A80_CLK_BUS_UART1, "apb1-uart1", "apb1",
BUS_CLK_GATING_REG4, 17),
SUNXI_CCU_GATE(A80_CLK_BUS_UART2, "apb1-uart2", "apb1",
BUS_CLK_GATING_REG4, 18),
SUNXI_CCU_GATE(A80_CLK_BUS_UART3, "apb1-uart3", "apb1",
BUS_CLK_GATING_REG4, 19),
SUNXI_CCU_GATE(A80_CLK_BUS_UART4, "apb1-uart4", "apb1",
BUS_CLK_GATING_REG4, 20),
SUNXI_CCU_GATE(A80_CLK_BUS_UART5, "apb1-uart5", "apb1",
BUS_CLK_GATING_REG4, 21),
};
static int
sun9i_a80_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
sun9i_a80_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 = sun9i_a80_ccu_resets;
sc->sc_nresets = __arraycount(sun9i_a80_ccu_resets);
sc->sc_clks = sun9i_a80_ccu_clks;
sc->sc_nclks = __arraycount(sun9i_a80_ccu_clks);
if (sunxi_ccu_attach(sc) != 0)
return;
aprint_naive("\n");
aprint_normal(": A80 CCU\n");
sunxi_ccu_print(sc);
}
/* $NetBSD: sun9i_a80_ccu.h,v 1.1 2017/10/08 18:00:36 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca>
* 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 _SUN9I_A80_CCU_H
#define _SUN9I_A80_CCU_H
#define A80_RST_BUS_FD 0
#define A80_RST_BUS_VE 1
#define A80_RST_BUS_GPU_CTRL 2
#define A80_RST_BUS_SS 3
#define A80_RST_BUS_MMC 4
#define A80_RST_BUS_NAND0 5
#define A80_RST_BUS_NAND1 6
#define A80_RST_BUS_SDRAM 7
#define A80_RST_BUS_SATA 8
#define A80_RST_BUS_TS 9
#define A80_RST_BUS_SPI0 10
#define A80_RST_BUS_SPI1 11
#define A80_RST_BUS_SPI2 12
#define A80_RST_BUS_SPI3 13
#define A80_RST_BUS_OTG 14
#define A80_RST_BUS_OTG_PHY 15
#define A80_RST_BUS_MIPI_HSI 16
#define A80_RST_BUS_GMAC 17
#define A80_RST_BUS_MSGBOX 18
#define A80_RST_BUS_SPINLOCK 19
#define A80_RST_BUS_HSTIMER 20
#define A80_RST_BUS_DMA 21
#define A80_RST_BUS_LCD0 22
#define A80_RST_BUS_LCD1 23
#define A80_RST_BUS_EDP 24
#define A80_RST_BUS_LVDS 25
#define A80_RST_BUS_CSI 26
#define A80_RST_BUS_HDMI0 27
#define A80_RST_BUS_HDMI1 28
#define A80_RST_BUS_DE 29
#define A80_RST_BUS_MP 30
#define A80_RST_BUS_GPU 31
#define A80_RST_BUS_MIPI_DSI 32
#define A80_RST_BUS_SPDIF 33
#define A80_RST_BUS_AC97 34
#define A80_RST_BUS_I2S0 35
#define A80_RST_BUS_I2S1 36
#define A80_RST_BUS_LRADC 37
#define A80_RST_BUS_GPADC 38
#define A80_RST_BUS_CIR_TX 39
#define A80_RST_BUS_I2C0 40
#define A80_RST_BUS_I2C1 41
#define A80_RST_BUS_I2C2 42
#define A80_RST_BUS_I2C3 43
#define A80_RST_BUS_I2C4 44
#define A80_RST_BUS_UART0 45
#define A80_RST_BUS_UART1 46
#define A80_RST_BUS_UART2 47
#define A80_RST_BUS_UART3 48
#define A80_RST_BUS_UART4 49
#define A80_RST_BUS_UART5 50
#define A80_CLK_PLL_C0CPUX 0
#define A80_CLK_PLL_C1CPUX 1
#define A80_CLK_PLL_AUDIO 2
#define A80_CLK_PLL_PERIPH0 3
#define A80_CLK_PLL_VE 4
#define A80_CLK_PLL_DDR 5
#define A80_CLK_PLL_VIDEO0 6
#define A80_CLK_PLL_VIDEO1 7
#define A80_CLK_PLL_GPU 8
#define A80_CLK_PLL_DE 9
#define A80_CLK_PLL_ISP 10
#define A80_CLK_PLL_PERIPH1 11
#define A80_CLK_C0CPUX 12
#define A80_CLK_C1CPUX 13
#define A80_CLK_ATB0 14
#define A80_CLK_AXI0 15
#define A80_CLK_ATB1 16
#define A80_CLK_AXI1 17
#define A80_CLK_GTBUS 18
#define A80_CLK_AHB0 19
#define A80_CLK_AHB1 20
#define A80_CLK_AHB2 21
#define A80_CLK_APB0 22
#define A80_CLK_APB1 23
#define A80_CLK_CCI400 24
#define A80_CLK_ATS 25
#define A80_CLK_TRACE 26
#define A80_CLK_OUT_A 27
#define A80_CLK_OUT_B 28
#define A80_CLK_NAND0_0 29
#define A80_CLK_NAND0_1 30
#define A80_CLK_NAND1_0 31
#define A80_CLK_NAND1_1 32
#define A80_CLK_MMC0 33
#define A80_CLK_MMC0_SAMPLE 34
#define A80_CLK_MMC0_OUTPUT 35
#define A80_CLK_MMC1 36
#define A80_CLK_MMC1_SAMPLE 37
#define A80_CLK_MMC1_OUTPUT 38
#define A80_CLK_MMC2 39
#define A80_CLK_MMC2_SAMPLE 40
#define A80_CLK_MMC2_OUTPUT 41
#define A80_CLK_MMC3 42
#define A80_CLK_MMC3_SAMPLE 43
#define A80_CLK_MMC3_OUTPUT 44
#define A80_CLK_TS 45
#define A80_CLK_SS 46
#define A80_CLK_SPI0 47
#define A80_CLK_SPI1 48
#define A80_CLK_SPI2 49
#define A80_CLK_SPI3 50
#define A80_CLK_I2S0 51
#define A80_CLK_I2S1 52
#define A80_CLK_SPDIF 53
#define A80_CLK_SDRAM 54
#define A80_CLK_DE 55
#define A80_CLK_EDP 56
#define A80_CLK_MP 57
#define A80_CLK_LCD0 58
#define A80_CLK_LCD1 59
#define A80_CLK_MIPI_DSI0 60
#define A80_CLK_MIPI_DSI1 61
#define A80_CLK_HDMI 62
#define A80_CLK_HDMI_SLOW 63
#define A80_CLK_MIPI_CSI 64
#define A80_CLK_CSI_ISP 65
#define A80_CLK_CSI_MISC 66
#define A80_CLK_CSI0_MCLK 67
#define A80_CLK_CSI1_MCLK 68
#define A80_CLK_FD 69
#define A80_CLK_VE 70
#define A80_CLK_AVS 71
#define A80_CLK_GPU_CORE 72
#define A80_CLK_GPU_MEMORY 73
#define A80_CLK_GPU_AXI 74
#define A80_CLK_SATA 75
#define A80_CLK_AC97 76
#define A80_CLK_MIPI_HSI 77
#define A80_CLK_GPADC 78
#define A80_CLK_CIR_TX 79
#define A80_CLK_BUS_FD 80
#define A80_CLK_BUS_VE 81
#define A80_CLK_BUS_GPU_CTRL 82
#define A80_CLK_BUS_SS 83
#define A80_CLK_BUS_MMC 84
#define A80_CLK_BUS_NAND0 85
#define A80_CLK_BUS_NAND1 86
#define A80_CLK_BUS_SDRAM 87
#define A80_CLK_BUS_MIPI_HSI 88
#define A80_CLK_BUS_SATA 89
#define A80_CLK_BUS_TS 90
#define A80_CLK_BUS_SPI0 91
#define A80_CLK_BUS_SPI1 92
#define A80_CLK_BUS_SPI2 93
#define A80_CLK_BUS_SPI3 94
#define A80_CLK_BUS_OTG 95
#define A80_CLK_BUS_USB 96
#define A80_CLK_BUS_GMAC 97
#define A80_CLK_BUS_MSGBOX 98
#define A80_CLK_BUS_SPINLOCK 99
#define A80_CLK_BUS_HSTIMER 100
#define A80_CLK_BUS_DMA 101
#define A80_CLK_BUS_LCD0 102
#define A80_CLK_BUS_LCD1 103
#define A80_CLK_BUS_EDP 104
#define A80_CLK_BUS_CSI 105
#define A80_CLK_BUS_HDMI 106
#define A80_CLK_BUS_DE 107
#define A80_CLK_BUS_MP 108
#define A80_CLK_BUS_MIPI_DSI 109
#define A80_CLK_BUS_SPDIF 110
#define A80_CLK_BUS_PIO 111
#define A80_CLK_BUS_AC97 112
#define A80_CLK_BUS_I2S0 113
#define A80_CLK_BUS_I2S1 114
#define A80_CLK_BUS_LRADC 115
#define A80_CLK_BUS_GPADC 116
#define A80_CLK_BUS_TWD 117
#define A80_CLK_BUS_CIR_TX 118
#define A80_CLK_BUS_I2C0 119
#define A80_CLK_BUS_I2C1 120
#define A80_CLK_BUS_I2C2 121
#define A80_CLK_BUS_I2C3 122
#define A80_CLK_BUS_I2C4 123
#define A80_CLK_BUS_UART0 124
#define A80_CLK_BUS_UART1 125
#define A80_CLK_BUS_UART2 126
#define A80_CLK_BUS_UART3 127
#define A80_CLK_BUS_UART4 128
#define A80_CLK_BUS_UART5 129
#endif /* !_SUN9I_A80_CCU_H */
/* $NetBSD: sun9i_a80_gpio.c,v 1.1 2017/10/08 18:00:36 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca>
* 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.
*
* $FreeBSD$
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sun9i_a80_gpio.c,v 1.1 2017/10/08 18:00:36 jmcneill 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 a80_pins[] = {
{ "PA0", 0, 0, { "gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "eint" }, 6, 0, 0 },
{ "PA1", 0, 1, { "gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "eint" }, 6, 1, 0 },
{ "PA2", 0, 2, { "gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "eint" }, 6, 2, 0 },
{ "PA3", 0, 3, { "gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "eint" }, 6, 3, 0 },
{ "PA4", 0, 4, { "gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "eint" }, 6, 4, 0 },
{ "PA5", 0, 5, { "gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "eint" }, 6, 5, 0 },
{ "PA6", 0, 6, { "gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "eint" }, 6, 6, 0 },
{ "PA7", 0, 7, { "gpio_in", "gpio_out", "gmac", NULL, "uart1", NULL, "eint" }, 6, 7, 0 },
{ "PA8", 0, 8, { "gpio_in", "gpio_out", "gmac", NULL, "eclk", NULL, "eint" }, 6, 8, 0 },
{ "PA9", 0, 9, { "gpio_in", "gpio_out", "gmac", NULL, "eclk", NULL, "eint" }, 6, 9, 0 },
{ "PA10", 0, 10, { "gpio_in", "gpio_out", "gmac", NULL, "clk_out_a", NULL, "eint" }, 6, 10, 0 },
{ "PA11", 0, 11, { "gpio_in", "gpio_out", "gmac", NULL, "clk_out_b", NULL, "eint" }, 6, 11, 0 },
{ "PA12", 0, 12, { "gpio_in", "gpio_out", "gmac", NULL, "pwm3", NULL, "eint" }, 6, 12, 0 },
{ "PA13", 0, 13, { "gpio_in", "gpio_out", "gmac", NULL, "pwm3", NULL, "eint" }, 6, 13, 0 },
{ "PA14", 0, 14, { "gpio_in", "gpio_out", "gmac", NULL, "spi1", NULL, "eint" }, 6, 14, 0 },
{ "PA15", 0, 15, { "gpio_in", "gpio_out", "gmac", NULL, "spi1", NULL, "eint" }, 6, 15, 0 },
{ "PA16", 0, 16, { "gpio_in", "gpio_out", "gmac", NULL, "spi1", NULL, "eint" }, 6, 16, 0 },
{ "PA17", 0, 17, { "gpio_in", "gpio_out", "gmac", NULL, "spi1", NULL, "eint" }, 6, 17, 0 },
{ "PB5", 1, 5, { "gpio_in", "gpio_out", NULL, "uart3", NULL, NULL, "eint" }, 6, 5, 1 },
{ "PB6", 1, 6, { "gpio_in", "gpio_out", NULL, "uart3", NULL, NULL, "eint" }, 6, 6, 1 },
{ "PB14", 1, 14, { "gpio_in", "gpio_out", NULL, "mcsi", NULL, NULL, "eint" }, 6, 14, 1 },
{ "PB15", 1, 15, { "gpio_in", "gpio_out", NULL, "mcsi", "i2c4", NULL, "eint" }, 6, 15, 1 },
{ "PB16", 1, 16, { "gpio_in", "gpio_out", NULL, "mcsi", "i2c4", NULL, "eint" }, 6, 16, 1 },
{ "PC0", 2, 0, { "gpio_in", "gpio_out", "nand0", "spi0" } },
{ "PC1", 2, 1, { "gpio_in", "gpio_out", "nand0", "spi0" } },
{ "PC2", 2, 2, { "gpio_in", "gpio_out", "nand0", "spi0" } },
{ "PC3", 2, 3, { "gpio_in", "gpio_out", "nand0" } },
{ "PC4", 2, 4, { "gpio_in", "gpio_out", "nand0" } },
{ "PC5", 2, 5, { "gpio_in", "gpio_out", "nand0" } },
{ "PC6", 2, 6, { "gpio_in", "gpio_out", "nand0", "mmc2" } },
{ "PC7", 2, 7, { "gpio_in", "gpio_out", "nand0", "mmc2" } },
{ "PC8", 2, 8, { "gpio_in", "gpio_out", "nand0", "mmc2" } },
{ "PC9", 2, 9, { "gpio_in", "gpio_out", "nand0", "mmc2" } },
{ "PC10", 2, 10, { "gpio_in", "gpio_out", "nand0", "mmc2" } },
{ "PC11", 2, 11, { "gpio_in", "gpio_out", "nand0", "mmc2" } },
{ "PC12", 2, 12, { "gpio_in", "gpio_out", "nand0", "mmc2" } },
{ "PC13", 2, 13, { "gpio_in", "gpio_out", "nand0", "mmc2" } },
{ "PC14", 2, 14, { "gpio_in", "gpio_out", "nand0", "mmc2" } },
{ "PC15", 2, 15, { "gpio_in", "gpio_out", "nand0", "mmc2" } },
{ "PC16", 2, 16, { "gpio_in", "gpio_out", "nand0", "mmc2" } },
{ "PC17", 2, 17, { "gpio_in", "gpio_out", "nand0", "nand0_b" } },
{ "PC18", 2, 18, { "gpio_in", "gpio_out", "nand0", "nand0_b" } },
{ "PC19", 2, 19, { "gpio_in", "gpio_out", NULL, "spi0" } },
{ "PD0", 3, 0, { "gpio_in", "gpio_out", "lcd0", "lvds0" } },
{ "PD1", 3, 1, { "gpio_in", "gpio_out", "lcd0", "lvds0" } },
{ "PD2", 3, 2, { "gpio_in", "gpio_out", "lcd0", "lvds0" } },
{ "PD3", 3, 3, { "gpio_in", "gpio_out", "lcd0", "lvds0" } },
{ "PD4", 3, 4, { "gpio_in", "gpio_out", "lcd0", "lvds0" } },
{ "PD5", 3, 5, { "gpio_in", "gpio_out", "lcd0", "lvds0" } },
{ "PD6", 3, 6, { "gpio_in", "gpio_out", "lcd0", "lvds0" } },
{ "PD7", 3, 7, { "gpio_in", "gpio_out", "lcd0", "lvds0" } },
{ "PD8", 3, 8, { "gpio_in", "gpio_out", "lcd0", "lvds0" } },
{ "PD9", 3, 9, { "gpio_in", "gpio_out", "lcd0", "lvds0" } },
{ "PD10", 3, 10, { "gpio_in", "gpio_out", "lcd0", "lvds1" } },
{ "PD11", 3, 11, { "gpio_in", "gpio_out", "lcd0", "lvds1" } },
{ "PD12", 3, 12, { "gpio_in", "gpio_out", "lcd0", "lvds1" } },
{ "PD13", 3, 13, { "gpio_in", "gpio_out", "lcd0", "lvds1" } },
{ "PD14", 3, 14, { "gpio_in", "gpio_out", "lcd0", "lvds1" } },
{ "PD15", 3, 15, { "gpio_in", "gpio_out", "lcd0", "lvds1" } },
{ "PD16", 3, 16, { "gpio_in", "gpio_out", "lcd0", "lvds1" } },
{ "PD17", 3, 17, { "gpio_in", "gpio_out", "lcd0", "lvds1" } },
{ "PD18", 3, 18, { "gpio_in", "gpio_out", "lcd0", "lvds1" } },
{ "PD19", 3, 19, { "gpio_in", "gpio_out", "lcd0", "lvds1" } },
{ "PD20", 3, 20, { "gpio_in", "gpio_out", "lcd0" } },
{ "PD21", 3, 21, { "gpio_in", "gpio_out", "lcd0" } },
{ "PD22", 3, 22, { "gpio_in", "gpio_out", "lcd0" } },
{ "PD23", 3, 23, { "gpio_in", "gpio_out", "lcd0" } },
{ "PD24", 3, 24, { "gpio_in", "gpio_out", "lcd0" } },
{ "PD25", 3, 25, { "gpio_in", "gpio_out", "lcd0" } },
{ "PD26", 3, 26, { "gpio_in", "gpio_out", "lcd0" } },
{ "PD27", 3, 27, { "gpio_in", "gpio_out", "lcd0" } },
{ "PE0", 4, 0, { "gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "eint" }, 6, 0, 2 },
{ "PE1", 4, 1, { "gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "eint" }, 6, 1, 2 },
{ "PE2", 4, 2, { "gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "eint" }, 6, 2, 2 },
{ "PE3", 4, 3, { "gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "eint" }, 6, 3, 2 },
{ "PE4", 4, 4, { "gpio_in", "gpio_out", "csi", "spi2", "uart5", NULL, "eint" }, 6, 4, 2 },
{ "PE5", 4, 5, { "gpio_in", "gpio_out", "csi", "spi2", "uart5", NULL, "eint" }, 6, 5, 2 },
{ "PE6", 4, 6, { "gpio_in", "gpio_out", "csi", "spi2", "uart5", NULL, "eint" }, 6, 6, 2 },
{ "PE7", 4, 7, { "gpio_in", "gpio_out", "csi", "spi2", "uart5", NULL, "eint" }, 6, 7, 2 },
{ "PE8", 4, 8, { "gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "eint" }, 6, 8, 2 },
{ "PE9", 4, 9, { "gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "eint" }, 6, 9, 2 },
{ "PE10", 4, 10, { "gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "eint" }, 6, 10, 2 },
{ "PE11", 4, 11, { "gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "eint" }, 6, 11, 2 },
{ "PE12", 4, 12, { "gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "eint" }, 6, 12, 2 },
{ "PE13", 4, 13, { "gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "eint" }, 6, 13, 2 },
{ "PE14", 4, 14, { "gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "eint" }, 6, 14, 2 },
{ "PE15", 4, 15, { "gpio_in", "gpio_out", "csi", "ts", NULL, NULL, "eint" }, 6, 15, 2 },
{ "PE16", 4, 16, { "gpio_in", "gpio_out", "csi", "i2c4", NULL, NULL, "eint" }, 6, 16, 2 },
{ "PE17", 4, 17, { "gpio_in", "gpio_out", "csi", "i2c4", NULL, NULL, "eint" }, 6, 17, 2 },
{ "PF0", 5, 0, { "gpio_in", "gpio_out", "mmc0" } },
{ "PF1", 5, 1, { "gpio_in", "gpio_out", "mmc0" } },
{ "PF2", 5, 2, { "gpio_in", "gpio_out", "mmc0", "uart0" } },
{ "PF3", 5, 3, { "gpio_in", "gpio_out", "mmc0" } },
{ "PF4", 5, 4, { "gpio_in", "gpio_out", "mmc0", "uart0" } },
{ "PF5", 5, 5, { "gpio_in", "gpio_out", "mmc0" } },
{ "PG0", 6, 0, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "eint" }, 6, 0, 3 },
{ "PG1", 6, 1, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "eint" }, 6, 1, 3 },
{ "PG2", 6, 2, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "eint" }, 6, 2, 3 },
{ "PG3", 6, 3, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "eint" }, 6, 3, 3 },
{ "PG4", 6, 4, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "eint" }, 6, 4, 3 },
{ "PG5", 6, 5, { "gpio_in", "gpio_out", "mmc1", NULL, NULL, NULL, "eint" }, 6, 5, 3 },
{ "PG6", 6, 6, { "gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, "eint" }, 6, 6, 3 },
{ "PG7", 6, 7, { "gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, "eint" }, 6, 7, 3 },
{ "PG8", 6, 8, { "gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, "eint" }, 6, 8, 3 },
{ "PG9", 6, 9, { "gpio_in", "gpio_out", "uart2", NULL, NULL, NULL, "eint" }, 6, 9, 3 },
{ "PG10", 6, 10, { "gpio_in", "gpio_out", "i2c3", NULL, NULL, NULL, "eint" }, 6, 10, 3 },
{ "PG11", 6, 11, { "gpio_in", "gpio_out", "i2c3", NULL, NULL, NULL, "eint" }, 6, 11, 3 },
{ "PG12", 6, 12, { "gpio_in", "gpio_out", "uart4", NULL, NULL, NULL, "eint" }, 6, 12, 3 },
{ "PG13", 6, 13, { "gpio_in", "gpio_out", "uart4", NULL, NULL, NULL, "eint" }, 6, 13, 3 },
{ "PG14", 6, 14, { "gpio_in", "gpio_out", "uart4", NULL, NULL, NULL, "eint" }, 6, 14, 3 },
{ "PG15", 6, 15, { "gpio_in", "gpio_out", "uart4", NULL, NULL, NULL, "eint" }, 6, 15, 3 },
{ "PH0", 7, 0, { "gpio_in", "gpio_out", "i2c0" } },
{ "PH1", 7, 1, { "gpio_in", "gpio_out", "i2c0" } },
{ "PH2", 7, 2, { "gpio_in", "gpio_out", "i2c1" } },
{ "PH3", 7, 3, { "gpio_in", "gpio_out", "i2c1" } },
{ "PH4", 7, 4, { "gpio_in", "gpio_out", "i2c2" } },
{ "PH5", 7, 5, { "gpio_in", "gpio_out", "i2c2" } },
{ "PH6", 7, 6, { "gpio_in", "gpio_out", "pwm0" } },
{ "PH8", 7, 8, { "gpio_in", "gpio_out", NULL, "pwm1", NULL, NULL, "eint" }, 6, 8, 4 },
{ "PH9", 7, 9, { "gpio_in", "gpio_out", NULL, "pwm1", NULL, NULL, "eint" }, 6, 9, 4 },
{ "PH10", 7, 10, { "gpio_in", "gpio_out", NULL, "pwm2", NULL, NULL, "eint" }, 6, 10, 4 },
{ "PH11", 7, 11, { "gpio_in", "gpio_out", NULL, "pwm2", NULL, NULL, "eint" }, 6, 11, 4 },
{ "PH12", 7, 12, { "gpio_in", "gpio_out", "uart0", "spi3", NULL, NULL, "eint" }, 6, 12, 4 },
{ "PH13", 7, 13, { "gpio_in", "gpio_out", "uart0", "spi3", NULL, NULL, "eint" }, 6, 13, 4 },
{ "PH14", 7, 14, { "gpio_in", "gpio_out", "spi3", NULL, NULL, NULL, "eint" }, 6, 14, 4 },
{ "PH15", 7, 15, { "gpio_in", "gpio_out", "spi3", NULL, NULL, NULL, "eint" }, 6, 15, 4 },
{ "PH16", 7, 16, { "gpio_in", "gpio_out", "spi3", NULL, NULL, NULL, "eint" }, 6, 16, 4 },
{ "PH17", 7, 17, { "gpio_in", "gpio_out", "spi3", NULL, NULL, NULL, "eint" }, 6, 17, 4 },
{ "PH18", 7, 18, { "gpio_in", "gpio_out", "spi3", NULL, NULL, NULL, "eint" }, 6, 18, 4 },
{ "PH19", 7, 19, { "gpio_in", "gpio_out", "hdmi" } },
{ "PH20", 7, 20, { "gpio_in", "gpio_out", "hdmi" } },
{ "PH21", 7, 21, { "gpio_in", "gpio_out", "hdmi" } },
};
static const struct sunxi_gpio_pins a80_r_pins[] = {
{ "PL0", 0, 0, { "gpio_in", "gpio_out", NULL, "s_uart", NULL, NULL, "eint" }, 6, 0, 0 },
{ "PL1", 0, 1, { "gpio_in", "gpio_out", NULL, "s_uart", NULL, NULL, "eint" }, 6, 1, 0 },
{ "PL2", 0, 2, { "gpio_in", "gpio_out", NULL, "s_jtag", NULL, NULL, "eint" }, 6, 2, 0 },
{ "PL3", 0, 3, { "gpio_in", "gpio_out", NULL, "s_jtag", NULL, NULL, "eint" }, 6, 3, 0 },
{ "PL4", 0, 4, { "gpio_in", "gpio_out", NULL, "s_jtag", NULL, NULL, "eint" }, 6, 4, 0 },
{ "PL5", 0, 5, { "gpio_in", "gpio_out", NULL, "s_jtag", NULL, NULL, "eint" }, 6, 5, 0 },
{ "PL6", 0, 6, { "gpio_in", "gpio_out", NULL, "s_cir_rx", NULL, NULL, "eint" }, 6, 6, 0 },
{ "PL7", 0, 7, { "gpio_in", "gpio_out", NULL, "1wire", NULL, NULL, "eint" }, 6, 7, 0 },
{ "PL8", 0, 8, { "gpio_in", "gpio_out", "s_ps2", NULL, NULL, NULL, "eint" }, 6, 8, 0 },
{ "PL9", 0, 9, { "gpio_in", "gpio_out", "s_ps2", NULL, NULL, NULL, "eint" }, 6, 9, 0 },
{ "PM0", 1, 0, { "gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "eint" }, 6, 0, 1 },
{ "PM1", 1, 1, { "gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "eint" }, 6, 1, 1 },
{ "PM2", 1, 2, { "gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "eint" }, 6, 2, 1 },
{ "PM3", 1, 3, { "gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "eint" }, 6, 3, 1 },
{ "PM4", 1, 4, { "gpio_in", "gpio_out", NULL, "s_i2s1", NULL, NULL, "eint" }, 6, 4, 1 },
{ "PM8", 1, 8, { "gpio_in", "gpio_out", NULL, "s_i2c1", NULL, NULL, "eint" }, 6, 8, 1 },
{ "PM9", 1, 9, { "gpio_in", "gpio_out", NULL, "s_i2c1", NULL, NULL, "eint" }, 6, 9, 1 },
{ "PM10", 1, 10, { "gpio_in", "gpio_out", "s_i2s0", "s_i2s1" } },
{ "PM11", 1, 11, { "gpio_in", "gpio_out", "s_i2s0", "s_i2s1" } },
{ "PM12", 1, 12, { "gpio_in", "gpio_out", "s_i2s0", "s_i2s1" } },
{ "PM13", 1, 13, { "gpio_in", "gpio_out", "s_i2s0", "s_i2s1" } },
{ "PM14", 1, 14, { "gpio_in", "gpio_out", "s_i2s0", "s_i2s1" } },
{ "PM15", 1, 15, { "gpio_in", "gpio_out", NULL, NULL, NULL, NULL, "eint" }, 6, 15, 1 },
{ "PN0", 2, 0, { "gpio_in", "gpio_out", "s_i2c0", "s_rsb" } },
{ "PN1", 2, 1, { "gpio_in", "gpio_out", "s_i2c0", "s_rsb" } },
};
const struct sunxi_gpio_padconf sun9i_a80_padconf = {
.npins = __arraycount(a80_pins),
.pins = a80_pins,
};
const struct sunxi_gpio_padconf sun9i_a80_r_padconf = {
.npins = __arraycount(a80_r_pins),
.pins = a80_r_pins,
};
/* $NetBSD: sun9i_a80_mmcclk.c,v 1.1 2017/10/08 18:00:36 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca>
* 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: sun9i_a80_mmcclk.c,v 1.1 2017/10/08 18:00:36 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>
#define SDC_COMM(port) (0x04 * (port))
static int sun9i_a80_mmcclk_match(device_t, cfdata_t, void *);
static void sun9i_a80_mmcclk_attach(device_t, device_t, void *);
static const char * compatible[] = {
"allwinner,sun9i-a80-mmc-config-clk",
NULL
};
CFATTACH_DECL_NEW(sunxi_a80_mmcclk, sizeof(struct sunxi_ccu_softc),
sun9i_a80_mmcclk_match, sun9i_a80_mmcclk_attach, NULL, NULL);
static struct sunxi_ccu_reset sun9i_a80_mmcclk_resets[] = {
SUNXI_CCU_RESET(0, SDC_COMM(0), 18),
SUNXI_CCU_RESET(1, SDC_COMM(1), 18),
SUNXI_CCU_RESET(2, SDC_COMM(2), 18),
SUNXI_CCU_RESET(3, SDC_COMM(3), 18),
};
static struct sunxi_ccu_clk sun9i_a80_mmcclk_clks[] = {
SUNXI_CCU_GATE(0, "mmc0_config", "ahb", SDC_COMM(0), 16),
SUNXI_CCU_GATE(1, "mmc1_config", "ahb", SDC_COMM(1), 16),
SUNXI_CCU_GATE(2, "mmc2_config", "ahb", SDC_COMM(2), 16),
SUNXI_CCU_GATE(3, "mmc3_config", "ahb", SDC_COMM(3), 16),
};
static int
sun9i_a80_mmcclk_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
sun9i_a80_mmcclk_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 = sun9i_a80_mmcclk_resets;
sc->sc_nresets = __arraycount(sun9i_a80_mmcclk_resets);
sc->sc_clks = sun9i_a80_mmcclk_clks;
sc->sc_nclks = __arraycount(sun9i_a80_mmcclk_clks);
if (sunxi_ccu_attach(sc) != 0)
return;
aprint_naive("\n");
aprint_normal(": A80 SD/MMC-COMM\n");
sunxi_ccu_print(sc);
}
--- src/sys/arch/arm/sunxi/sunxi_gpio.c 2017/10/06 21:20:59 1.14
+++ src/sys/arch/arm/sunxi/sunxi_gpio.c 2017/10/08 18:00:36 1.15
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: sunxi_gpio.c,v 1.14 2017/10/06 21:20:59 jmcneill Exp $ */ | | 1 | /* $NetBSD: sunxi_gpio.c,v 1.15 2017/10/08 18:00:36 jmcneill Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca> | | 4 | * Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca> |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -19,116 +19,124 @@ | | | @@ -19,116 +19,124 @@ |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | | 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
26 | * SUCH DAMAGE. | | 26 | * SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include "opt_soc.h" | | 29 | #include "opt_soc.h" |
30 | | | 30 | |
31 | #include <sys/cdefs.h> | | 31 | #include <sys/cdefs.h> |
32 | __KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.14 2017/10/06 21:20:59 jmcneill Exp $"); | | 32 | __KERNEL_RCSID(0, "$NetBSD: sunxi_gpio.c,v 1.15 2017/10/08 18:00:36 jmcneill Exp $"); |
33 | | | 33 | |
34 | #include <sys/param.h> | | 34 | #include <sys/param.h> |
35 | #include <sys/bus.h> | | 35 | #include <sys/bus.h> |
36 | #include <sys/device.h> | | 36 | #include <sys/device.h> |
37 | #include <sys/intr.h> | | 37 | #include <sys/intr.h> |
38 | #include <sys/systm.h> | | 38 | #include <sys/systm.h> |
39 | #include <sys/mutex.h> | | 39 | #include <sys/mutex.h> |
40 | #include <sys/kmem.h> | | 40 | #include <sys/kmem.h> |
41 | #include <sys/gpio.h> | | 41 | #include <sys/gpio.h> |
42 | #include <sys/bitops.h> | | 42 | #include <sys/bitops.h> |
43 | #include <sys/lwp.h> | | 43 | #include <sys/lwp.h> |
44 | | | 44 | |
45 | #include <dev/fdt/fdtvar.h> | | 45 | #include <dev/fdt/fdtvar.h> |
46 | #include <dev/gpio/gpiovar.h> | | 46 | #include <dev/gpio/gpiovar.h> |
47 | | | 47 | |
48 | #include <arm/sunxi/sunxi_gpio.h> | | 48 | #include <arm/sunxi/sunxi_gpio.h> |
49 | | | 49 | |
| | | 50 | #define SUNXI_GPIO_MAX_EINT_BANK 5 |
50 | #define SUNXI_GPIO_MAX_EINT 32 | | 51 | #define SUNXI_GPIO_MAX_EINT 32 |
51 | | | 52 | |
52 | #define SUNXI_GPIO_PORT(port) (0x24 * (port)) | | 53 | #define SUNXI_GPIO_PORT(port) (0x24 * (port)) |
53 | #define SUNXI_GPIO_CFG(port, pin) (SUNXI_GPIO_PORT(port) + 0x00 + (0x4 * ((pin) / 8))) | | 54 | #define SUNXI_GPIO_CFG(port, pin) (SUNXI_GPIO_PORT(port) + 0x00 + (0x4 * ((pin) / 8))) |
54 | #define SUNXI_GPIO_CFG_PINMASK(pin) (0x7 << (((pin) % 8) * 4)) | | 55 | #define SUNXI_GPIO_CFG_PINMASK(pin) (0x7 << (((pin) % 8) * 4)) |
55 | #define SUNXI_GPIO_DATA(port) (SUNXI_GPIO_PORT(port) + 0x10) | | 56 | #define SUNXI_GPIO_DATA(port) (SUNXI_GPIO_PORT(port) + 0x10) |
56 | #define SUNXI_GPIO_DRV(port, pin) (SUNXI_GPIO_PORT(port) + 0x14 + (0x4 * ((pin) / 16))) | | 57 | #define SUNXI_GPIO_DRV(port, pin) (SUNXI_GPIO_PORT(port) + 0x14 + (0x4 * ((pin) / 16))) |
57 | #define SUNXI_GPIO_DRV_PINMASK(pin) (0x3 << (((pin) % 16) * 2)) | | 58 | #define SUNXI_GPIO_DRV_PINMASK(pin) (0x3 << (((pin) % 16) * 2)) |
58 | #define SUNXI_GPIO_PULL(port, pin) (SUNXI_GPIO_PORT(port) + 0x1c + (0x4 * ((pin) / 16))) | | 59 | #define SUNXI_GPIO_PULL(port, pin) (SUNXI_GPIO_PORT(port) + 0x1c + (0x4 * ((pin) / 16))) |
59 | #define SUNXI_GPIO_PULL_DISABLE 0 | | 60 | #define SUNXI_GPIO_PULL_DISABLE 0 |
60 | #define SUNXI_GPIO_PULL_UP 1 | | 61 | #define SUNXI_GPIO_PULL_UP 1 |
61 | #define SUNXI_GPIO_PULL_DOWN 2 | | 62 | #define SUNXI_GPIO_PULL_DOWN 2 |
62 | #define SUNXI_GPIO_PULL_PINMASK(pin) (0x3 << (((pin) % 16) * 2)) | | 63 | #define SUNXI_GPIO_PULL_PINMASK(pin) (0x3 << (((pin) % 16) * 2)) |
63 | #define SUNXI_GPIO_INT_CFG(eint) (0x200 + (0x4 * ((eint) / 8))) | | 64 | #define SUNXI_GPIO_INT_CFG(bank, eint) (0x200 + (0x20 * (bank)) + (0x4 * ((eint) / 8))) |
64 | #define SUNXI_GPIO_INT_MODEMASK(eint) (0xf << (((eint) % 8) * 4)) | | 65 | #define SUNXI_GPIO_INT_MODEMASK(eint) (0xf << (((eint) % 8) * 4)) |
65 | #define SUNXI_GPIO_INT_MODE_POS_EDGE 0x0 | | 66 | #define SUNXI_GPIO_INT_MODE_POS_EDGE 0x0 |
66 | #define SUNXI_GPIO_INT_MODE_NEG_EDGE 0x1 | | 67 | #define SUNXI_GPIO_INT_MODE_NEG_EDGE 0x1 |
67 | #define SUNXI_GPIO_INT_MODE_HIGH_LEVEL 0x2 | | 68 | #define SUNXI_GPIO_INT_MODE_HIGH_LEVEL 0x2 |
68 | #define SUNXI_GPIO_INT_MODE_LOW_LEVEL 0x3 | | 69 | #define SUNXI_GPIO_INT_MODE_LOW_LEVEL 0x3 |
69 | #define SUNXI_GPIO_INT_MODE_DOUBLE_EDGE 0x4 | | 70 | #define SUNXI_GPIO_INT_MODE_DOUBLE_EDGE 0x4 |
70 | #define SUNXI_GPIO_INT_CTL 0x210 | | 71 | #define SUNXI_GPIO_INT_CTL(bank) (0x210 + 0x20 * (bank)) |
71 | #define SUNXI_GPIO_INT_STATUS 0x214 | | 72 | #define SUNXI_GPIO_INT_STATUS(bank) (0x214 + 0x20 * (bank)) |
72 | | | 73 | |
73 | static const struct of_compat_data compat_data[] = { | | 74 | static const struct of_compat_data compat_data[] = { |
74 | #ifdef SOC_SUN4I_A10 | | 75 | #ifdef SOC_SUN4I_A10 |
75 | { "allwinner,sun4i-a10-pinctrl", (uintptr_t)&sun4i_a10_padconf }, | | 76 | { "allwinner,sun4i-a10-pinctrl", (uintptr_t)&sun4i_a10_padconf }, |
76 | #endif | | 77 | #endif |
77 | #ifdef SOC_SUN5I_A13 | | 78 | #ifdef SOC_SUN5I_A13 |
78 | { "allwinner,sun5i-a13-pinctrl", (uintptr_t)&sun5i_a13_padconf }, | | 79 | { "allwinner,sun5i-a13-pinctrl", (uintptr_t)&sun5i_a13_padconf }, |
79 | #endif | | 80 | #endif |
80 | #ifdef SOC_SUN6I_A31 | | 81 | #ifdef SOC_SUN6I_A31 |
81 | { "allwinner,sun6i-a31-pinctrl", (uintptr_t)&sun6i_a31_padconf }, | | 82 | { "allwinner,sun6i-a31-pinctrl", (uintptr_t)&sun6i_a31_padconf }, |
82 | { "allwinner,sun6i-a31-r-pinctrl", (uintptr_t)&sun6i_a31_r_padconf }, | | 83 | { "allwinner,sun6i-a31-r-pinctrl", (uintptr_t)&sun6i_a31_r_padconf }, |
83 | #endif | | 84 | #endif |
84 | #ifdef SOC_SUN7I_A20 | | 85 | #ifdef SOC_SUN7I_A20 |
85 | { "allwinner,sun7i-a20-pinctrl", (uintptr_t)&sun7i_a20_padconf }, | | 86 | { "allwinner,sun7i-a20-pinctrl", (uintptr_t)&sun7i_a20_padconf }, |
86 | #endif | | 87 | #endif |
87 | #ifdef SOC_SUN8I_A83T | | 88 | #ifdef SOC_SUN8I_A83T |
88 | { "allwinner,sun8i-a83t-pinctrl", (uintptr_t)&sun8i_a83t_padconf }, | | 89 | { "allwinner,sun8i-a83t-pinctrl", (uintptr_t)&sun8i_a83t_padconf }, |
89 | { "allwinner,sun8i-a83t-r-pinctrl", (uintptr_t)&sun8i_a83t_r_padconf }, | | 90 | { "allwinner,sun8i-a83t-r-pinctrl", (uintptr_t)&sun8i_a83t_r_padconf }, |
90 | #endif | | 91 | #endif |
91 | #ifdef SOC_SUN8I_H3 | | 92 | #ifdef SOC_SUN8I_H3 |
92 | { "allwinner,sun8i-h3-pinctrl", (uintptr_t)&sun8i_h3_padconf }, | | 93 | { "allwinner,sun8i-h3-pinctrl", (uintptr_t)&sun8i_h3_padconf }, |
93 | { "allwinner,sun8i-h3-r-pinctrl", (uintptr_t)&sun8i_h3_r_padconf }, | | 94 | { "allwinner,sun8i-h3-r-pinctrl", (uintptr_t)&sun8i_h3_r_padconf }, |
94 | #endif | | 95 | #endif |
| | | 96 | #ifdef SOC_SUN9I_A80 |
| | | 97 | { "allwinner,sun9i-a80-pinctrl", (uintptr_t)&sun9i_a80_padconf }, |
| | | 98 | { "allwinner,sun9i-a80-r-pinctrl", (uintptr_t)&sun9i_a80_r_padconf }, |
| | | 99 | #endif |
95 | #ifdef SOC_SUN50I_A64 | | 100 | #ifdef SOC_SUN50I_A64 |
96 | { "allwinner,sun50i-a64-pinctrl", (uintptr_t)&sun50i_a64_padconf }, | | 101 | { "allwinner,sun50i-a64-pinctrl", (uintptr_t)&sun50i_a64_padconf }, |
97 | { "allwinner,sun50i-a64-r-pinctrl", (uintptr_t)&sun50i_a64_r_padconf }, | | 102 | { "allwinner,sun50i-a64-r-pinctrl", (uintptr_t)&sun50i_a64_r_padconf }, |
98 | #endif | | 103 | #endif |
99 | { NULL } | | 104 | { NULL } |
100 | }; | | 105 | }; |
101 | | | 106 | |
102 | struct sunxi_gpio_eint { | | 107 | struct sunxi_gpio_eint { |
103 | int (*eint_func)(void *); | | 108 | int (*eint_func)(void *); |
104 | void *eint_arg; | | 109 | void *eint_arg; |
105 | int eint_flags; | | 110 | int eint_flags; |
| | | 111 | int eint_bank; |
106 | int eint_num; | | 112 | int eint_num; |
107 | }; | | 113 | }; |
108 | | | 114 | |
109 | struct sunxi_gpio_softc { | | 115 | struct sunxi_gpio_softc { |
110 | device_t sc_dev; | | 116 | device_t sc_dev; |
111 | bus_space_tag_t sc_bst; | | 117 | bus_space_tag_t sc_bst; |
112 | bus_space_handle_t sc_bsh; | | 118 | bus_space_handle_t sc_bsh; |
113 | const struct sunxi_gpio_padconf *sc_padconf; | | 119 | const struct sunxi_gpio_padconf *sc_padconf; |
114 | kmutex_t sc_lock; | | 120 | kmutex_t sc_lock; |
115 | | | 121 | |
116 | struct gpio_chipset_tag sc_gp; | | 122 | struct gpio_chipset_tag sc_gp; |
117 | gpio_pin_t *sc_pins; | | 123 | gpio_pin_t *sc_pins; |
118 | device_t sc_gpiodev; | | 124 | device_t sc_gpiodev; |
119 | | | 125 | |
| | | 126 | u_int sc_eint_bank_max; |
| | | 127 | |
120 | void *sc_ih; | | 128 | void *sc_ih; |
121 | struct sunxi_gpio_eint sc_eint[SUNXI_GPIO_MAX_EINT]; | | 129 | struct sunxi_gpio_eint sc_eint[SUNXI_GPIO_MAX_EINT_BANK][SUNXI_GPIO_MAX_EINT]; |
122 | }; | | 130 | }; |
123 | | | 131 | |
124 | struct sunxi_gpio_pin { | | 132 | struct sunxi_gpio_pin { |
125 | struct sunxi_gpio_softc *pin_sc; | | 133 | struct sunxi_gpio_softc *pin_sc; |
126 | const struct sunxi_gpio_pins *pin_def; | | 134 | const struct sunxi_gpio_pins *pin_def; |
127 | int pin_flags; | | 135 | int pin_flags; |
128 | bool pin_actlo; | | 136 | bool pin_actlo; |
129 | }; | | 137 | }; |
130 | | | 138 | |
131 | #define GPIO_READ(sc, reg) \ | | 139 | #define GPIO_READ(sc, reg) \ |
132 | bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg)) | | 140 | bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg)) |
133 | #define GPIO_WRITE(sc, reg, val) \ | | 141 | #define GPIO_WRITE(sc, reg, val) \ |
134 | bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val)) | | 142 | bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val)) |
| @@ -378,42 +386,47 @@ sunxi_gpio_write(device_t dev, void *pri | | | @@ -378,42 +386,47 @@ sunxi_gpio_write(device_t dev, void *pri |
378 | static struct fdtbus_gpio_controller_func sunxi_gpio_funcs = { | | 386 | static struct fdtbus_gpio_controller_func sunxi_gpio_funcs = { |
379 | .acquire = sunxi_gpio_acquire, | | 387 | .acquire = sunxi_gpio_acquire, |
380 | .release = sunxi_gpio_release, | | 388 | .release = sunxi_gpio_release, |
381 | .read = sunxi_gpio_read, | | 389 | .read = sunxi_gpio_read, |
382 | .write = sunxi_gpio_write, | | 390 | .write = sunxi_gpio_write, |
383 | }; | | 391 | }; |
384 | | | 392 | |
385 | static int | | 393 | static int |
386 | sunxi_gpio_intr(void *priv) | | 394 | sunxi_gpio_intr(void *priv) |
387 | { | | 395 | { |
388 | struct sunxi_gpio_softc * const sc = priv; | | 396 | struct sunxi_gpio_softc * const sc = priv; |
389 | struct sunxi_gpio_eint *eint; | | 397 | struct sunxi_gpio_eint *eint; |
390 | uint32_t status, bit; | | 398 | uint32_t status, bit; |
| | | 399 | u_int bank; |
391 | int ret = 0; | | 400 | int ret = 0; |
392 | | | 401 | |
393 | status = GPIO_READ(sc, SUNXI_GPIO_INT_STATUS); | | 402 | for (bank = 0; bank <= sc->sc_eint_bank_max; bank++) { |
394 | GPIO_WRITE(sc, SUNXI_GPIO_INT_STATUS, status); | | 403 | status = GPIO_READ(sc, SUNXI_GPIO_INT_STATUS(bank)); |
395 | | | 404 | if (status == 0) |
396 | while ((bit = ffs32(status)) != 0) { | | | |
397 | status &= ~__BIT(bit - 1); | | | |
398 | eint = &sc->sc_eint[bit - 1]; | | | |
399 | if (eint->eint_func == NULL) | | | |
400 | continue; | | 405 | continue; |
401 | const bool mpsafe = (eint->eint_flags & FDT_INTR_MPSAFE) != 0; | | 406 | GPIO_WRITE(sc, SUNXI_GPIO_INT_STATUS(bank), status); |
402 | if (!mpsafe) | | 407 | |
403 | KERNEL_LOCK(1, curlwp); | | 408 | while ((bit = ffs32(status)) != 0) { |
404 | ret |= eint->eint_func(eint->eint_arg); | | 409 | status &= ~__BIT(bit - 1); |
405 | if (!mpsafe) | | 410 | eint = &sc->sc_eint[bank][bit - 1]; |
406 | KERNEL_UNLOCK_ONE(curlwp); | | 411 | if (eint->eint_func == NULL) |
| | | 412 | continue; |
| | | 413 | const bool mpsafe = (eint->eint_flags & FDT_INTR_MPSAFE) != 0; |
| | | 414 | if (!mpsafe) |
| | | 415 | KERNEL_LOCK(1, curlwp); |
| | | 416 | ret |= eint->eint_func(eint->eint_arg); |
| | | 417 | if (!mpsafe) |
| | | 418 | KERNEL_UNLOCK_ONE(curlwp); |
| | | 419 | } |
407 | } | | 420 | } |
408 | | | 421 | |
409 | return ret; | | 422 | return ret; |
410 | } | | 423 | } |
411 | | | 424 | |
412 | static void * | | 425 | static void * |
413 | sunxi_gpio_establish(device_t dev, u_int *specifier, int ipl, int flags, | | 426 | sunxi_gpio_establish(device_t dev, u_int *specifier, int ipl, int flags, |
414 | int (*func)(void *), void *arg) | | 427 | int (*func)(void *), void *arg) |
415 | { | | 428 | { |
416 | struct sunxi_gpio_softc * const sc = device_private(dev); | | 429 | struct sunxi_gpio_softc * const sc = device_private(dev); |
417 | const struct sunxi_gpio_pins *pin_def; | | 430 | const struct sunxi_gpio_pins *pin_def; |
418 | struct sunxi_gpio_eint *eint; | | 431 | struct sunxi_gpio_eint *eint; |
419 | uint32_t val; | | 432 | uint32_t val; |
| @@ -455,75 +468,76 @@ sunxi_gpio_establish(device_t dev, u_int | | | @@ -455,75 +468,76 @@ sunxi_gpio_establish(device_t dev, u_int |
455 | } | | 468 | } |
456 | | | 469 | |
457 | pin_def = sunxi_gpio_lookup(sc, port, pin); | | 470 | pin_def = sunxi_gpio_lookup(sc, port, pin); |
458 | if (pin_def == NULL) | | 471 | if (pin_def == NULL) |
459 | return NULL; | | 472 | return NULL; |
460 | if (pin_def->functions[pin_def->eint_func] == NULL || | | 473 | if (pin_def->functions[pin_def->eint_func] == NULL || |
461 | strcmp(pin_def->functions[pin_def->eint_func], "eint") != 0) | | 474 | strcmp(pin_def->functions[pin_def->eint_func], "eint") != 0) |
462 | return NULL; | | 475 | return NULL; |
463 | | | 476 | |
464 | KASSERT(pin_def->eint_num < SUNXI_GPIO_MAX_EINT); | | 477 | KASSERT(pin_def->eint_num < SUNXI_GPIO_MAX_EINT); |
465 | | | 478 | |
466 | mutex_enter(&sc->sc_lock); | | 479 | mutex_enter(&sc->sc_lock); |
467 | | | 480 | |
468 | eint = &sc->sc_eint[pin_def->eint_num]; | | 481 | eint = &sc->sc_eint[pin_def->eint_bank][pin_def->eint_num]; |
469 | if (eint->eint_func != NULL) { | | 482 | if (eint->eint_func != NULL) { |
470 | mutex_exit(&sc->sc_lock); | | 483 | mutex_exit(&sc->sc_lock); |
471 | return NULL; /* in use */ | | 484 | return NULL; /* in use */ |
472 | } | | 485 | } |
473 | | | 486 | |
474 | /* Set function */ | | 487 | /* Set function */ |
475 | if (sunxi_gpio_setfunc(sc, pin_def, "eint") != 0) { | | 488 | if (sunxi_gpio_setfunc(sc, pin_def, "eint") != 0) { |
476 | mutex_exit(&sc->sc_lock); | | 489 | mutex_exit(&sc->sc_lock); |
477 | return NULL; | | 490 | return NULL; |
478 | } | | 491 | } |
479 | | | 492 | |
480 | eint->eint_func = func; | | 493 | eint->eint_func = func; |
481 | eint->eint_arg = arg; | | 494 | eint->eint_arg = arg; |
482 | eint->eint_flags = flags; | | 495 | eint->eint_flags = flags; |
| | | 496 | eint->eint_bank = pin_def->eint_bank; |
483 | eint->eint_num = pin_def->eint_num; | | 497 | eint->eint_num = pin_def->eint_num; |
484 | | | 498 | |
485 | /* Configure eint mode */ | | 499 | /* Configure eint mode */ |
486 | val = GPIO_READ(sc, SUNXI_GPIO_INT_CFG(eint->eint_num)); | | 500 | val = GPIO_READ(sc, SUNXI_GPIO_INT_CFG(eint->eint_bank, eint->eint_num)); |
487 | val &= ~SUNXI_GPIO_INT_MODEMASK(eint->eint_num); | | 501 | val &= ~SUNXI_GPIO_INT_MODEMASK(eint->eint_num); |
488 | val |= __SHIFTIN(mode, SUNXI_GPIO_INT_MODEMASK(eint->eint_num)); | | 502 | val |= __SHIFTIN(mode, SUNXI_GPIO_INT_MODEMASK(eint->eint_num)); |
489 | GPIO_WRITE(sc, SUNXI_GPIO_INT_CFG(eint->eint_num), val); | | 503 | GPIO_WRITE(sc, SUNXI_GPIO_INT_CFG(eint->eint_bank, eint->eint_num), val); |
490 | | | 504 | |
491 | /* Enable eint */ | | 505 | /* Enable eint */ |
492 | val = GPIO_READ(sc, SUNXI_GPIO_INT_CTL); | | 506 | val = GPIO_READ(sc, SUNXI_GPIO_INT_CTL(eint->eint_bank)); |
493 | val |= __BIT(eint->eint_num); | | 507 | val |= __BIT(eint->eint_num); |
494 | GPIO_WRITE(sc, SUNXI_GPIO_INT_CTL, val); | | 508 | GPIO_WRITE(sc, SUNXI_GPIO_INT_CTL(eint->eint_bank), val); |
495 | | | 509 | |
496 | mutex_exit(&sc->sc_lock); | | 510 | mutex_exit(&sc->sc_lock); |
497 | | | 511 | |
498 | return eint; | | 512 | return eint; |
499 | } | | 513 | } |
500 | | | 514 | |
501 | static void | | 515 | static void |
502 | sunxi_gpio_disestablish(device_t dev, void *ih) | | 516 | sunxi_gpio_disestablish(device_t dev, void *ih) |
503 | { | | 517 | { |
504 | struct sunxi_gpio_softc * const sc = device_private(dev); | | 518 | struct sunxi_gpio_softc * const sc = device_private(dev); |
505 | struct sunxi_gpio_eint * const eint = ih; | | 519 | struct sunxi_gpio_eint * const eint = ih; |
506 | uint32_t val; | | 520 | uint32_t val; |
507 | | | 521 | |
508 | KASSERT(eint->eint_func != NULL); | | 522 | KASSERT(eint->eint_func != NULL); |
509 | | | 523 | |
510 | mutex_enter(&sc->sc_lock); | | 524 | mutex_enter(&sc->sc_lock); |
511 | | | 525 | |
512 | /* Disable eint */ | | 526 | /* Disable eint */ |
513 | val = GPIO_READ(sc, SUNXI_GPIO_INT_CTL); | | 527 | val = GPIO_READ(sc, SUNXI_GPIO_INT_CTL(eint->eint_bank)); |
514 | val &= ~__BIT(eint->eint_num); | | 528 | val &= ~__BIT(eint->eint_num); |
515 | GPIO_WRITE(sc, SUNXI_GPIO_INT_CTL, val); | | 529 | GPIO_WRITE(sc, SUNXI_GPIO_INT_CTL(eint->eint_bank), val); |
516 | GPIO_WRITE(sc, SUNXI_GPIO_INT_STATUS, __BIT(eint->eint_num)); | | 530 | GPIO_WRITE(sc, SUNXI_GPIO_INT_STATUS(eint->eint_bank), __BIT(eint->eint_num)); |
517 | | | 531 | |
518 | eint->eint_func = NULL; | | 532 | eint->eint_func = NULL; |
519 | eint->eint_arg = NULL; | | 533 | eint->eint_arg = NULL; |
520 | eint->eint_flags = 0; | | 534 | eint->eint_flags = 0; |
521 | | | 535 | |
522 | mutex_exit(&sc->sc_lock); | | 536 | mutex_exit(&sc->sc_lock); |
523 | } | | 537 | } |
524 | | | 538 | |
525 | static bool | | 539 | static bool |
526 | sunxi_gpio_intrstr(device_t dev, u_int *specifier, char *buf, size_t buflen) | | 540 | sunxi_gpio_intrstr(device_t dev, u_int *specifier, char *buf, size_t buflen) |
527 | { | | 541 | { |
528 | struct sunxi_gpio_softc * const sc = device_private(dev); | | 542 | struct sunxi_gpio_softc * const sc = device_private(dev); |
529 | const struct sunxi_gpio_pins *pin_def; | | 543 | const struct sunxi_gpio_pins *pin_def; |
| @@ -823,28 +837,37 @@ sunxi_gpio_attach(device_t parent, devic | | | @@ -823,28 +837,37 @@ sunxi_gpio_attach(device_t parent, devic |
823 | fdtbus_register_gpio_controller(self, phandle, &sunxi_gpio_funcs); | | 837 | fdtbus_register_gpio_controller(self, phandle, &sunxi_gpio_funcs); |
824 | | | 838 | |
825 | for (child = OF_child(phandle); child; child = OF_peer(child)) { | | 839 | for (child = OF_child(phandle); child; child = OF_peer(child)) { |
826 | if (!of_hasprop(child, "function") || !of_hasprop(child, "pins")) | | 840 | if (!of_hasprop(child, "function") || !of_hasprop(child, "pins")) |
827 | continue; | | 841 | continue; |
828 | fdtbus_register_pinctrl_config(self, child, &sunxi_pinctrl_funcs); | | 842 | fdtbus_register_pinctrl_config(self, child, &sunxi_pinctrl_funcs); |
829 | } | | 843 | } |
830 | | | 844 | |
831 | fdtbus_pinctrl_configure(); | | 845 | fdtbus_pinctrl_configure(); |
832 | | | 846 | |
833 | sunxi_gpio_attach_ports(sc); | | 847 | sunxi_gpio_attach_ports(sc); |
834 | | | 848 | |
835 | /* Disable all external interrupts */ | | 849 | /* Disable all external interrupts */ |
836 | GPIO_WRITE(sc, SUNXI_GPIO_INT_CTL, 0); | | 850 | for (int i = 0; i < sc->sc_padconf->npins; i++) { |
837 | GPIO_WRITE(sc, SUNXI_GPIO_INT_STATUS, GPIO_READ(sc, SUNXI_GPIO_INT_STATUS)); | | 851 | const struct sunxi_gpio_pins *pin_def = &sc->sc_padconf->pins[i]; |
| | | 852 | if (pin_def->eint_func == 0) |
| | | 853 | continue; |
| | | 854 | GPIO_WRITE(sc, SUNXI_GPIO_INT_CTL(pin_def->eint_bank), __BIT(pin_def->eint_num)); |
| | | 855 | GPIO_WRITE(sc, SUNXI_GPIO_INT_STATUS(pin_def->eint_bank), __BIT(pin_def->eint_num)); |
| | | 856 | |
| | | 857 | if (sc->sc_eint_bank_max < pin_def->eint_bank) |
| | | 858 | sc->sc_eint_bank_max = pin_def->eint_bank; |
| | | 859 | } |
| | | 860 | KASSERT(sc->sc_eint_bank_max < SUNXI_GPIO_MAX_EINT_BANK); |
838 | | | 861 | |
839 | if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) { | | 862 | if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) { |
840 | aprint_error_dev(self, "failed to decode interrupt\n"); | | 863 | aprint_error_dev(self, "failed to decode interrupt\n"); |
841 | return; | | 864 | return; |
842 | } | | 865 | } |
843 | sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_VM, FDT_INTR_MPSAFE, | | 866 | sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_VM, FDT_INTR_MPSAFE, |
844 | sunxi_gpio_intr, sc); | | 867 | sunxi_gpio_intr, sc); |
845 | if (sc->sc_ih == NULL) { | | 868 | if (sc->sc_ih == NULL) { |
846 | aprint_error_dev(self, "failed to establish interrupt on %s\n", | | 869 | aprint_error_dev(self, "failed to establish interrupt on %s\n", |
847 | intrstr); | | 870 | intrstr); |
848 | return; | | 871 | return; |
849 | } | | 872 | } |
850 | aprint_normal_dev(self, "interrupting on %s\n", intrstr); | | 873 | aprint_normal_dev(self, "interrupting on %s\n", intrstr); |
--- src/sys/arch/arm/sunxi/sunxi_gpio.h 2017/10/06 21:20:59 1.6
+++ src/sys/arch/arm/sunxi/sunxi_gpio.h 2017/10/08 18:00:36 1.7
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: sunxi_gpio.h,v 1.6 2017/10/06 21:20:59 jmcneill Exp $ */ | | 1 | /* $NetBSD: sunxi_gpio.h,v 1.7 2017/10/08 18:00:36 jmcneill Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca> | | 4 | * Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca> |
5 | * Copyright (c) 2016 Emmanuel Vadot <manu@bidouilliste.com> | | 5 | * Copyright (c) 2016 Emmanuel Vadot <manu@bidouilliste.com> |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -33,26 +33,27 @@ | | | @@ -33,26 +33,27 @@ |
33 | #define _ARM_SUNXI_GPIO_H | | 33 | #define _ARM_SUNXI_GPIO_H |
34 | | | 34 | |
35 | #include "opt_soc.h" | | 35 | #include "opt_soc.h" |
36 | | | 36 | |
37 | #define SUNXI_GPIO_MAXFUNC 8 | | 37 | #define SUNXI_GPIO_MAXFUNC 8 |
38 | | | 38 | |
39 | struct sunxi_gpio_pins { | | 39 | struct sunxi_gpio_pins { |
40 | const char *name; | | 40 | const char *name; |
41 | uint8_t port; | | 41 | uint8_t port; |
42 | uint8_t pin; | | 42 | uint8_t pin; |
43 | const char *functions[SUNXI_GPIO_MAXFUNC]; | | 43 | const char *functions[SUNXI_GPIO_MAXFUNC]; |
44 | uint8_t eint_func; | | 44 | uint8_t eint_func; |
45 | uint8_t eint_num; | | 45 | uint8_t eint_num; |
| | | 46 | uint8_t eint_bank; |
46 | }; | | 47 | }; |
47 | | | 48 | |
48 | struct sunxi_gpio_padconf { | | 49 | struct sunxi_gpio_padconf { |
49 | uint32_t npins; | | 50 | uint32_t npins; |
50 | const struct sunxi_gpio_pins *pins; | | 51 | const struct sunxi_gpio_pins *pins; |
51 | }; | | 52 | }; |
52 | | | 53 | |
53 | #ifdef SOC_SUN4I_A10 | | 54 | #ifdef SOC_SUN4I_A10 |
54 | extern const struct sunxi_gpio_padconf sun4i_a10_padconf; | | 55 | extern const struct sunxi_gpio_padconf sun4i_a10_padconf; |
55 | #endif | | 56 | #endif |
56 | | | 57 | |
57 | #ifdef SOC_SUN5I_A13 | | 58 | #ifdef SOC_SUN5I_A13 |
58 | extern const struct sunxi_gpio_padconf sun5i_a13_padconf; | | 59 | extern const struct sunxi_gpio_padconf sun5i_a13_padconf; |
| @@ -67,19 +68,24 @@ extern const struct sunxi_gpio_padconf s | | | @@ -67,19 +68,24 @@ extern const struct sunxi_gpio_padconf s |
67 | extern const struct sunxi_gpio_padconf sun7i_a20_padconf; | | 68 | extern const struct sunxi_gpio_padconf sun7i_a20_padconf; |
68 | #endif | | 69 | #endif |
69 | | | 70 | |
70 | #ifdef SOC_SUN8I_A83T | | 71 | #ifdef SOC_SUN8I_A83T |
71 | extern const struct sunxi_gpio_padconf sun8i_a83t_padconf; | | 72 | extern const struct sunxi_gpio_padconf sun8i_a83t_padconf; |
72 | extern const struct sunxi_gpio_padconf sun8i_a83t_r_padconf; | | 73 | extern const struct sunxi_gpio_padconf sun8i_a83t_r_padconf; |
73 | #endif | | 74 | #endif |
74 | | | 75 | |
75 | #ifdef SOC_SUN8I_H3 | | 76 | #ifdef SOC_SUN8I_H3 |
76 | extern const struct sunxi_gpio_padconf sun8i_h3_padconf; | | 77 | extern const struct sunxi_gpio_padconf sun8i_h3_padconf; |
77 | extern const struct sunxi_gpio_padconf sun8i_h3_r_padconf; | | 78 | extern const struct sunxi_gpio_padconf sun8i_h3_r_padconf; |
78 | #endif | | 79 | #endif |
79 | | | 80 | |
| | | 81 | #ifdef SOC_SUN9I_A80 |
| | | 82 | extern const struct sunxi_gpio_padconf sun9i_a80_padconf; |
| | | 83 | extern const struct sunxi_gpio_padconf sun9i_a80_r_padconf; |
| | | 84 | #endif |
| | | 85 | |
80 | #ifdef SOC_SUN50I_A64 | | 86 | #ifdef SOC_SUN50I_A64 |
81 | extern const struct sunxi_gpio_padconf sun50i_a64_padconf; | | 87 | extern const struct sunxi_gpio_padconf sun50i_a64_padconf; |
82 | extern const struct sunxi_gpio_padconf sun50i_a64_r_padconf; | | 88 | extern const struct sunxi_gpio_padconf sun50i_a64_r_padconf; |
83 | #endif | | 89 | #endif |
84 | | | 90 | |
85 | #endif /* _ARM_SUNXI_GPIO_H */ | | 91 | #endif /* _ARM_SUNXI_GPIO_H */ |
--- src/sys/arch/arm/sunxi/sunxi_mmc.c 2017/10/08 13:48:40 1.9
+++ src/sys/arch/arm/sunxi/sunxi_mmc.c 2017/10/08 18:00:36 1.10
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: sunxi_mmc.c,v 1.9 2017/10/08 13:48:40 jmcneill Exp $ */ | | 1 | /* $NetBSD: sunxi_mmc.c,v 1.10 2017/10/08 18:00:36 jmcneill Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2014-2017 Jared McNeill <jmcneill@invisible.ca> | | 4 | * Copyright (c) 2014-2017 Jared McNeill <jmcneill@invisible.ca> |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -17,27 +17,27 @@ | | | @@ -17,27 +17,27 @@ |
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | | 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
26 | * SUCH DAMAGE. | | 26 | * SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __KERNEL_RCSID(0, "$NetBSD: sunxi_mmc.c,v 1.9 2017/10/08 13:48:40 jmcneill Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: sunxi_mmc.c,v 1.10 2017/10/08 18:00:36 jmcneill Exp $"); |
31 | | | 31 | |
32 | #include <sys/param.h> | | 32 | #include <sys/param.h> |
33 | #include <sys/bus.h> | | 33 | #include <sys/bus.h> |
34 | #include <sys/device.h> | | 34 | #include <sys/device.h> |
35 | #include <sys/intr.h> | | 35 | #include <sys/intr.h> |
36 | #include <sys/systm.h> | | 36 | #include <sys/systm.h> |
37 | #include <sys/kernel.h> | | 37 | #include <sys/kernel.h> |
38 | #include <sys/gpio.h> | | 38 | #include <sys/gpio.h> |
39 | | | 39 | |
40 | #include <dev/sdmmc/sdmmcvar.h> | | 40 | #include <dev/sdmmc/sdmmcvar.h> |
41 | #include <dev/sdmmc/sdmmcchip.h> | | 41 | #include <dev/sdmmc/sdmmcchip.h> |
42 | #include <dev/sdmmc/sdmmc_ioreg.h> | | 42 | #include <dev/sdmmc/sdmmc_ioreg.h> |
43 | | | 43 | |
| @@ -48,34 +48,42 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_mmc.c, | | | @@ -48,34 +48,42 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_mmc.c, |
48 | enum sunxi_mmc_timing { | | 48 | enum sunxi_mmc_timing { |
49 | SUNXI_MMC_TIMING_400K, | | 49 | SUNXI_MMC_TIMING_400K, |
50 | SUNXI_MMC_TIMING_25M, | | 50 | SUNXI_MMC_TIMING_25M, |
51 | SUNXI_MMC_TIMING_50M, | | 51 | SUNXI_MMC_TIMING_50M, |
52 | SUNXI_MMC_TIMING_50M_DDR, | | 52 | SUNXI_MMC_TIMING_50M_DDR, |
53 | SUNXI_MMC_TIMING_50M_DDR_8BIT, | | 53 | SUNXI_MMC_TIMING_50M_DDR_8BIT, |
54 | }; | | 54 | }; |
55 | | | 55 | |
56 | struct sunxi_mmc_delay { | | 56 | struct sunxi_mmc_delay { |
57 | u_int output_phase; | | 57 | u_int output_phase; |
58 | u_int sample_phase; | | 58 | u_int sample_phase; |
59 | }; | | 59 | }; |
60 | | | 60 | |
61 | static const struct sunxi_mmc_delay sunxi_mmc_delays[] = { | | 61 | static const struct sunxi_mmc_delay sun7i_mmc_delays[] = { |
62 | [SUNXI_MMC_TIMING_400K] = { 180, 180 }, | | 62 | [SUNXI_MMC_TIMING_400K] = { 180, 180 }, |
63 | [SUNXI_MMC_TIMING_25M] = { 180, 75 }, | | 63 | [SUNXI_MMC_TIMING_25M] = { 180, 75 }, |
64 | [SUNXI_MMC_TIMING_50M] = { 90, 120 }, | | 64 | [SUNXI_MMC_TIMING_50M] = { 90, 120 }, |
65 | [SUNXI_MMC_TIMING_50M_DDR] = { 60, 120 }, | | 65 | [SUNXI_MMC_TIMING_50M_DDR] = { 60, 120 }, |
66 | [SUNXI_MMC_TIMING_50M_DDR_8BIT] = { 90, 180 }, | | 66 | [SUNXI_MMC_TIMING_50M_DDR_8BIT] = { 90, 180 }, |
67 | }; | | 67 | }; |
68 | | | 68 | |
| | | 69 | static const struct sunxi_mmc_delay sun9i_mmc_delays[] = { |
| | | 70 | [SUNXI_MMC_TIMING_400K] = { 180, 180 }, |
| | | 71 | [SUNXI_MMC_TIMING_25M] = { 180, 75 }, |
| | | 72 | [SUNXI_MMC_TIMING_50M] = { 150, 120 }, |
| | | 73 | [SUNXI_MMC_TIMING_50M_DDR] = { 54, 36 }, |
| | | 74 | [SUNXI_MMC_TIMING_50M_DDR_8BIT] = { 72, 72 }, |
| | | 75 | }; |
| | | 76 | |
69 | #define SUNXI_MMC_NDESC 16 | | 77 | #define SUNXI_MMC_NDESC 16 |
70 | | | 78 | |
71 | struct sunxi_mmc_softc; | | 79 | struct sunxi_mmc_softc; |
72 | | | 80 | |
73 | static int sunxi_mmc_match(device_t, cfdata_t, void *); | | 81 | static int sunxi_mmc_match(device_t, cfdata_t, void *); |
74 | static void sunxi_mmc_attach(device_t, device_t, void *); | | 82 | static void sunxi_mmc_attach(device_t, device_t, void *); |
75 | static void sunxi_mmc_attach_i(device_t); | | 83 | static void sunxi_mmc_attach_i(device_t); |
76 | | | 84 | |
77 | static int sunxi_mmc_intr(void *); | | 85 | static int sunxi_mmc_intr(void *); |
78 | static int sunxi_mmc_idma_setup(struct sunxi_mmc_softc *); | | 86 | static int sunxi_mmc_idma_setup(struct sunxi_mmc_softc *); |
79 | | | 87 | |
80 | static int sunxi_mmc_host_reset(sdmmc_chipset_handle_t); | | 88 | static int sunxi_mmc_host_reset(sdmmc_chipset_handle_t); |
81 | static uint32_t sunxi_mmc_host_ocr(sdmmc_chipset_handle_t); | | 89 | static uint32_t sunxi_mmc_host_ocr(sdmmc_chipset_handle_t); |
| @@ -178,43 +186,51 @@ static const struct sunxi_mmc_config sun | | | @@ -178,43 +186,51 @@ static const struct sunxi_mmc_config sun |
178 | .flags = 0, | | 186 | .flags = 0, |
179 | }; | | 187 | }; |
180 | | | 188 | |
181 | static const struct sunxi_mmc_config sun5i_a13_mmc_config = { | | 189 | static const struct sunxi_mmc_config sun5i_a13_mmc_config = { |
182 | .idma_xferlen = 0x10000, | | 190 | .idma_xferlen = 0x10000, |
183 | .dma_ftrglevel = 0x20070008, | | 191 | .dma_ftrglevel = 0x20070008, |
184 | .delays = NULL, | | 192 | .delays = NULL, |
185 | .flags = 0, | | 193 | .flags = 0, |
186 | }; | | 194 | }; |
187 | | | 195 | |
188 | static const struct sunxi_mmc_config sun7i_a20_mmc_config = { | | 196 | static const struct sunxi_mmc_config sun7i_a20_mmc_config = { |
189 | .idma_xferlen = 0x2000, | | 197 | .idma_xferlen = 0x2000, |
190 | .dma_ftrglevel = 0x20070008, | | 198 | .dma_ftrglevel = 0x20070008, |
191 | .delays = sunxi_mmc_delays, | | 199 | .delays = sun7i_mmc_delays, |
| | | 200 | .flags = 0, |
| | | 201 | }; |
| | | 202 | |
| | | 203 | static const struct sunxi_mmc_config sun9i_a80_mmc_config = { |
| | | 204 | .idma_xferlen = 0x10000, |
| | | 205 | .dma_ftrglevel = 0x200f0010, |
| | | 206 | .delays = sun9i_mmc_delays, |
192 | .flags = 0, | | 207 | .flags = 0, |
193 | }; | | 208 | }; |
194 | | | 209 | |
195 | static const struct sunxi_mmc_config sun50i_a64_mmc_config = { | | 210 | static const struct sunxi_mmc_config sun50i_a64_mmc_config = { |
196 | .idma_xferlen = 0x10000, | | 211 | .idma_xferlen = 0x10000, |
197 | .dma_ftrglevel = 0x20070008, | | 212 | .dma_ftrglevel = 0x20070008, |
198 | .delays = NULL, | | 213 | .delays = NULL, |
199 | .flags = SUNXI_MMC_FLAG_CALIB_REG | | | 214 | .flags = SUNXI_MMC_FLAG_CALIB_REG | |
200 | SUNXI_MMC_FLAG_NEW_TIMINGS | | | 215 | SUNXI_MMC_FLAG_NEW_TIMINGS | |
201 | SUNXI_MMC_FLAG_MASK_DATA0, | | 216 | SUNXI_MMC_FLAG_MASK_DATA0, |
202 | }; | | 217 | }; |
203 | | | 218 | |
204 | static const struct of_compat_data compat_data[] = { | | 219 | static const struct of_compat_data compat_data[] = { |
205 | { "allwinner,sun4i-a10-mmc", (uintptr_t)&sun4i_a10_mmc_config }, | | 220 | { "allwinner,sun4i-a10-mmc", (uintptr_t)&sun4i_a10_mmc_config }, |
206 | { "allwinner,sun5i-a13-mmc", (uintptr_t)&sun5i_a13_mmc_config }, | | 221 | { "allwinner,sun5i-a13-mmc", (uintptr_t)&sun5i_a13_mmc_config }, |
207 | { "allwinner,sun7i-a20-mmc", (uintptr_t)&sun7i_a20_mmc_config }, | | 222 | { "allwinner,sun7i-a20-mmc", (uintptr_t)&sun7i_a20_mmc_config }, |
| | | 223 | { "allwinner,sun9i-a80-mmc", (uintptr_t)&sun9i_a80_mmc_config }, |
208 | { "allwinner,sun50i-a64-mmc", (uintptr_t)&sun50i_a64_mmc_config }, | | 224 | { "allwinner,sun50i-a64-mmc", (uintptr_t)&sun50i_a64_mmc_config }, |
209 | { NULL } | | 225 | { NULL } |
210 | }; | | 226 | }; |
211 | | | 227 | |
212 | static int | | 228 | static int |
213 | sunxi_mmc_match(device_t parent, cfdata_t cf, void *aux) | | 229 | sunxi_mmc_match(device_t parent, cfdata_t cf, void *aux) |
214 | { | | 230 | { |
215 | struct fdt_attach_args * const faa = aux; | | 231 | struct fdt_attach_args * const faa = aux; |
216 | | | 232 | |
217 | return of_match_compat_data(faa->faa_phandle, compat_data); | | 233 | return of_match_compat_data(faa->faa_phandle, compat_data); |
218 | } | | 234 | } |
219 | | | 235 | |
220 | static void | | 236 | static void |
--- src/sys/arch/arm/sunxi/sunxi_platform.c 2017/10/06 21:12:23 1.9
+++ src/sys/arch/arm/sunxi/sunxi_platform.c 2017/10/08 18:00:36 1.10
--- src/sys/arch/arm/sunxi/sunxi_platform.h 2017/06/28 23:51:29 1.1
+++ src/sys/arch/arm/sunxi/sunxi_platform.h 2017/10/08 18:00:36 1.2