mediatek: update to latest kernel patchset from v4.13-rc
Signed-off-by: Muciri Gatimu <muciri@openmesh.com> Signed-off-by: Shashidhar Lakkavalli <shashidhar.lakkavalli@openmesh.com> Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <dt-bindings/phy/phy.h>
|
||||
#include <dt-bindings/reset/mt2701-resets.h>
|
||||
#include <dt-bindings/pinctrl/mt7623-pinfunc.h>
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
#include "skeleton64.dtsi"
|
||||
|
||||
|
||||
@@ -151,7 +152,7 @@
|
||||
};
|
||||
|
||||
pio: pinctrl@10005000 {
|
||||
compatible = "mediatek,mt2701-pinctrl";
|
||||
compatible = "mediatek,mt7623-pinctrl";
|
||||
reg = <0 0x1000b000 0 0x1000>;
|
||||
mediatek,pctl-regmap = <&syscfg_pctl_a>;
|
||||
pins-are-numbered;
|
||||
@@ -211,6 +212,15 @@
|
||||
clock-names = "spi", "wrap";
|
||||
};
|
||||
|
||||
cir: cir@10013000 {
|
||||
compatible = "mediatek,mt7623-cir";
|
||||
reg = <0 0x10013000 0 0x1000>;
|
||||
interrupts = <GIC_SPI 87 IRQ_TYPE_LEVEL_LOW>;
|
||||
clocks = <&infracfg CLK_INFRA_IRRX>;
|
||||
clock-names = "clk";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
sysirq: interrupt-controller@10200100 {
|
||||
compatible = "mediatek,mt7623-sysirq",
|
||||
"mediatek,mt6577-sysirq";
|
||||
@@ -240,6 +250,13 @@
|
||||
#clock-cells = <1>;
|
||||
};
|
||||
|
||||
rng: rng@1020f000 {
|
||||
compatible = "mediatek,mt7623-rng";
|
||||
reg = <0 0x1020f000 0 0x1000>;
|
||||
clocks = <&infracfg CLK_INFRA_TRNG>;
|
||||
clock-names = "rng";
|
||||
};
|
||||
|
||||
gic: interrupt-controller@10211000 {
|
||||
compatible = "arm,cortex-a7-gic";
|
||||
interrupt-controller;
|
||||
@@ -370,7 +387,7 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
spi: spi@1100a000 {
|
||||
spi0: spi@1100a000 {
|
||||
compatible = "mediatek,mt7623-spi",
|
||||
"mediatek,mt6589-spi";
|
||||
reg = <0 0x1100a000 0 0x1000>;
|
||||
@@ -399,6 +416,34 @@
|
||||
nvmem-cell-names = "calibration-data";
|
||||
};
|
||||
|
||||
spi1: spi@11016000 {
|
||||
compatible = "mediatek,mt7623-spi",
|
||||
"mediatek,mt2701-spi";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
reg = <0 0x11016000 0 0x100>;
|
||||
interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_LOW>;
|
||||
clocks = <&topckgen CLK_TOP_SYSPLL3_D2>,
|
||||
<&topckgen CLK_TOP_SPI1_SEL>,
|
||||
<&pericfg CLK_PERI_SPI1>;
|
||||
clock-names = "parent-clk", "sel-clk", "spi-clk";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
spi2: spi@11017000 {
|
||||
compatible = "mediatek,mt7623-spi",
|
||||
"mediatek,mt2701-spi";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
reg = <0 0x11017000 0 0x1000>;
|
||||
interrupts = <GIC_SPI 142 IRQ_TYPE_LEVEL_LOW>;
|
||||
clocks = <&topckgen CLK_TOP_SYSPLL3_D2>,
|
||||
<&topckgen CLK_TOP_SPI2_SEL>,
|
||||
<&pericfg CLK_PERI_SPI2>;
|
||||
clock-names = "parent-clk", "sel-clk", "spi-clk";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
nandc: nfi@1100d000 {
|
||||
compatible = "mediatek,mt7623-nfc",
|
||||
"mediatek,mt2701-nfc";
|
||||
@@ -424,6 +469,104 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
afe: audio-controller@11220000 {
|
||||
compatible = "mediatek,mt7623-audio",
|
||||
"mediatek,mt2701-audio";
|
||||
reg = <0 0x11220000 0 0x2000>,
|
||||
<0 0x112a0000 0 0x20000>;
|
||||
interrupts = <GIC_SPI 132 IRQ_TYPE_LEVEL_LOW>;
|
||||
power-domains = <&scpsys MT2701_POWER_DOMAIN_IFR_MSC>;
|
||||
|
||||
clocks = <&infracfg CLK_INFRA_AUDIO>,
|
||||
<&topckgen CLK_TOP_AUD_MUX1_SEL>,
|
||||
<&topckgen CLK_TOP_AUD_MUX2_SEL>,
|
||||
<&topckgen CLK_TOP_AUD_MUX1_DIV>,
|
||||
<&topckgen CLK_TOP_AUD_MUX2_DIV>,
|
||||
<&topckgen CLK_TOP_AUD_48K_TIMING>,
|
||||
<&topckgen CLK_TOP_AUD_44K_TIMING>,
|
||||
<&topckgen CLK_TOP_AUDPLL_MUX_SEL>,
|
||||
<&topckgen CLK_TOP_APLL_SEL>,
|
||||
<&topckgen CLK_TOP_AUD1PLL_98M>,
|
||||
<&topckgen CLK_TOP_AUD2PLL_90M>,
|
||||
<&topckgen CLK_TOP_HADDS2PLL_98M>,
|
||||
<&topckgen CLK_TOP_HADDS2PLL_294M>,
|
||||
<&topckgen CLK_TOP_AUDPLL>,
|
||||
<&topckgen CLK_TOP_AUDPLL_D4>,
|
||||
<&topckgen CLK_TOP_AUDPLL_D8>,
|
||||
<&topckgen CLK_TOP_AUDPLL_D16>,
|
||||
<&topckgen CLK_TOP_AUDPLL_D24>,
|
||||
<&topckgen CLK_TOP_AUDINTBUS_SEL>,
|
||||
<&clk26m>,
|
||||
<&topckgen CLK_TOP_SYSPLL1_D4>,
|
||||
<&topckgen CLK_TOP_AUD_K1_SRC_SEL>,
|
||||
<&topckgen CLK_TOP_AUD_K2_SRC_SEL>,
|
||||
<&topckgen CLK_TOP_AUD_K3_SRC_SEL>,
|
||||
<&topckgen CLK_TOP_AUD_K4_SRC_SEL>,
|
||||
<&topckgen CLK_TOP_AUD_K5_SRC_SEL>,
|
||||
<&topckgen CLK_TOP_AUD_K6_SRC_SEL>,
|
||||
<&topckgen CLK_TOP_AUD_K1_SRC_DIV>,
|
||||
<&topckgen CLK_TOP_AUD_K2_SRC_DIV>,
|
||||
<&topckgen CLK_TOP_AUD_K3_SRC_DIV>,
|
||||
<&topckgen CLK_TOP_AUD_K4_SRC_DIV>,
|
||||
<&topckgen CLK_TOP_AUD_K5_SRC_DIV>,
|
||||
<&topckgen CLK_TOP_AUD_K6_SRC_DIV>,
|
||||
<&topckgen CLK_TOP_AUD_I2S1_MCLK>,
|
||||
<&topckgen CLK_TOP_AUD_I2S2_MCLK>,
|
||||
<&topckgen CLK_TOP_AUD_I2S3_MCLK>,
|
||||
<&topckgen CLK_TOP_AUD_I2S4_MCLK>,
|
||||
<&topckgen CLK_TOP_AUD_I2S5_MCLK>,
|
||||
<&topckgen CLK_TOP_AUD_I2S6_MCLK>,
|
||||
<&topckgen CLK_TOP_ASM_M_SEL>,
|
||||
<&topckgen CLK_TOP_ASM_H_SEL>,
|
||||
<&topckgen CLK_TOP_UNIVPLL2_D4>,
|
||||
<&topckgen CLK_TOP_UNIVPLL2_D2>,
|
||||
<&topckgen CLK_TOP_SYSPLL_D5>;
|
||||
clock-names = "infra_sys_audio_clk",
|
||||
"top_audio_mux1_sel",
|
||||
"top_audio_mux2_sel",
|
||||
"top_audio_mux1_div",
|
||||
"top_audio_mux2_div",
|
||||
"top_audio_48k_timing",
|
||||
"top_audio_44k_timing",
|
||||
"top_audpll_mux_sel",
|
||||
"top_apll_sel",
|
||||
"top_aud1_pll_98M",
|
||||
"top_aud2_pll_90M",
|
||||
"top_hadds2_pll_98M",
|
||||
"top_hadds2_pll_294M",
|
||||
"top_audpll",
|
||||
"top_audpll_d4",
|
||||
"top_audpll_d8",
|
||||
"top_audpll_d16",
|
||||
"top_audpll_d24",
|
||||
"top_audintbus_sel",
|
||||
"clk_26m",
|
||||
"top_syspll1_d4",
|
||||
"top_aud_k1_src_sel",
|
||||
"top_aud_k2_src_sel",
|
||||
"top_aud_k3_src_sel",
|
||||
"top_aud_k4_src_sel",
|
||||
"top_aud_k5_src_sel",
|
||||
"top_aud_k6_src_sel",
|
||||
"top_aud_k1_src_div",
|
||||
"top_aud_k2_src_div",
|
||||
"top_aud_k3_src_div",
|
||||
"top_aud_k4_src_div",
|
||||
"top_aud_k5_src_div",
|
||||
"top_aud_k6_src_div",
|
||||
"top_aud_i2s1_mclk",
|
||||
"top_aud_i2s2_mclk",
|
||||
"top_aud_i2s3_mclk",
|
||||
"top_aud_i2s4_mclk",
|
||||
"top_aud_i2s5_mclk",
|
||||
"top_aud_i2s6_mclk",
|
||||
"top_asm_m_sel",
|
||||
"top_asm_h_sel",
|
||||
"top_univpll2_d4",
|
||||
"top_univpll2_d2",
|
||||
"top_syspll_d5";
|
||||
};
|
||||
|
||||
mmc0: mmc@11230000 {
|
||||
compatible = "mediatek,mt7623-mmc",
|
||||
"mediatek,mt8135-mmc";
|
||||
@@ -636,4 +779,26 @@
|
||||
#size-cells = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
hnat: hnat@1b000000 {
|
||||
compatible = "mediatek,mt7623-hnat";
|
||||
reg = <0 0x1b100000 0 0x3000>;
|
||||
mtketh-wan = "eth1";
|
||||
resets = <ðsys 0>;
|
||||
reset-names = "mtketh";
|
||||
};
|
||||
|
||||
crypto: crypto@1b240000 {
|
||||
compatible = "mediatek,mt7623-crypto", "mediatek,eip97-crypto";
|
||||
reg = <0 0x1b240000 0 0x20000>;
|
||||
interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_LOW>,
|
||||
<GIC_SPI 83 IRQ_TYPE_LEVEL_LOW>,
|
||||
<GIC_SPI 84 IRQ_TYPE_LEVEL_LOW>,
|
||||
<GIC_SPI 91 IRQ_TYPE_LEVEL_LOW>,
|
||||
<GIC_SPI 97 IRQ_TYPE_LEVEL_LOW>;
|
||||
clocks = <&topckgen CLK_TOP_ETHIF_SEL>,
|
||||
<ðsys CLK_ETHSYS_CRYPTO>;
|
||||
clock-names = "ethif","cryp";
|
||||
power-domains = <&scpsys MT2701_POWER_DOMAIN_ETH>;
|
||||
};
|
||||
};
|
||||
|
||||
241
target/linux/mediatek/files/arch/arm/boot/dts/mt6323.dtsi
Normal file
241
target/linux/mediatek/files/arch/arm/boot/dts/mt6323.dtsi
Normal file
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Copyright (c) 2017 MediaTek Inc.
|
||||
* Author: John Crispin <john@phrozen.org>
|
||||
* Sean Wang <sean.wang@mediatek.com>
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
&pwrap {
|
||||
pmic: mt6323 {
|
||||
compatible = "mediatek,mt6323";
|
||||
interrupt-parent = <&pio>;
|
||||
interrupts = <150 IRQ_TYPE_LEVEL_HIGH>;
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <2>;
|
||||
|
||||
mt6323regulator: mt6323regulator{
|
||||
compatible = "mediatek,mt6323-regulator";
|
||||
|
||||
mt6323_vproc_reg: buck_vproc{
|
||||
regulator-name = "vproc";
|
||||
regulator-min-microvolt = < 700000>;
|
||||
regulator-max-microvolt = <1350000>;
|
||||
regulator-ramp-delay = <12500>;
|
||||
regulator-always-on;
|
||||
regulator-boot-on;
|
||||
};
|
||||
|
||||
mt6323_vsys_reg: buck_vsys{
|
||||
regulator-name = "vsys";
|
||||
regulator-min-microvolt = <1400000>;
|
||||
regulator-max-microvolt = <2987500>;
|
||||
regulator-ramp-delay = <25000>;
|
||||
regulator-always-on;
|
||||
regulator-boot-on;
|
||||
};
|
||||
|
||||
mt6323_vpa_reg: buck_vpa{
|
||||
regulator-name = "vpa";
|
||||
regulator-min-microvolt = < 500000>;
|
||||
regulator-max-microvolt = <3650000>;
|
||||
};
|
||||
|
||||
mt6323_vtcxo_reg: ldo_vtcxo{
|
||||
regulator-name = "vtcxo";
|
||||
regulator-min-microvolt = <2800000>;
|
||||
regulator-max-microvolt = <2800000>;
|
||||
regulator-enable-ramp-delay = <90>;
|
||||
regulator-always-on;
|
||||
regulator-boot-on;
|
||||
};
|
||||
|
||||
mt6323_vcn28_reg: ldo_vcn28{
|
||||
regulator-name = "vcn28";
|
||||
regulator-min-microvolt = <2800000>;
|
||||
regulator-max-microvolt = <2800000>;
|
||||
regulator-enable-ramp-delay = <185>;
|
||||
};
|
||||
|
||||
mt6323_vcn33_bt_reg: ldo_vcn33_bt{
|
||||
regulator-name = "vcn33_bt";
|
||||
regulator-min-microvolt = <3300000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
regulator-enable-ramp-delay = <185>;
|
||||
};
|
||||
|
||||
mt6323_vcn33_wifi_reg: ldo_vcn33_wifi{
|
||||
regulator-name = "vcn33_wifi";
|
||||
regulator-min-microvolt = <3300000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
regulator-enable-ramp-delay = <185>;
|
||||
};
|
||||
|
||||
mt6323_va_reg: ldo_va{
|
||||
regulator-name = "va";
|
||||
regulator-min-microvolt = <2800000>;
|
||||
regulator-max-microvolt = <2800000>;
|
||||
regulator-enable-ramp-delay = <216>;
|
||||
regulator-always-on;
|
||||
regulator-boot-on;
|
||||
};
|
||||
|
||||
mt6323_vcama_reg: ldo_vcama{
|
||||
regulator-name = "vcama";
|
||||
regulator-min-microvolt = <1500000>;
|
||||
regulator-max-microvolt = <2800000>;
|
||||
regulator-enable-ramp-delay = <216>;
|
||||
};
|
||||
|
||||
mt6323_vio28_reg: ldo_vio28{
|
||||
regulator-name = "vio28";
|
||||
regulator-min-microvolt = <2800000>;
|
||||
regulator-max-microvolt = <2800000>;
|
||||
regulator-enable-ramp-delay = <216>;
|
||||
regulator-always-on;
|
||||
regulator-boot-on;
|
||||
};
|
||||
|
||||
mt6323_vusb_reg: ldo_vusb{
|
||||
regulator-name = "vusb";
|
||||
regulator-min-microvolt = <3300000>;
|
||||
regulator-max-microvolt = <3300000>;
|
||||
regulator-enable-ramp-delay = <216>;
|
||||
regulator-boot-on;
|
||||
};
|
||||
|
||||
mt6323_vmc_reg: ldo_vmc{
|
||||
regulator-name = "vmc";
|
||||
regulator-min-microvolt = <1800000>;
|
||||
regulator-max-microvolt = <3300000>;
|
||||
regulator-enable-ramp-delay = <36>;
|
||||
regulator-boot-on;
|
||||
};
|
||||
|
||||
mt6323_vmch_reg: ldo_vmch{
|
||||
regulator-name = "vmch";
|
||||
regulator-min-microvolt = <3000000>;
|
||||
regulator-max-microvolt = <3300000>;
|
||||
regulator-enable-ramp-delay = <36>;
|
||||
regulator-boot-on;
|
||||
};
|
||||
|
||||
mt6323_vemc3v3_reg: ldo_vemc3v3{
|
||||
regulator-name = "vemc3v3";
|
||||
regulator-min-microvolt = <3000000>;
|
||||
regulator-max-microvolt = <3300000>;
|
||||
regulator-enable-ramp-delay = <36>;
|
||||
regulator-boot-on;
|
||||
};
|
||||
|
||||
mt6323_vgp1_reg: ldo_vgp1{
|
||||
regulator-name = "vgp1";
|
||||
regulator-min-microvolt = <1200000>;
|
||||
regulator-max-microvolt = <3300000>;
|
||||
regulator-enable-ramp-delay = <216>;
|
||||
};
|
||||
|
||||
mt6323_vgp2_reg: ldo_vgp2{
|
||||
regulator-name = "vgp2";
|
||||
regulator-min-microvolt = <1200000>;
|
||||
regulator-max-microvolt = <3000000>;
|
||||
regulator-enable-ramp-delay = <216>;
|
||||
};
|
||||
|
||||
mt6323_vgp3_reg: ldo_vgp3{
|
||||
regulator-name = "vgp3";
|
||||
regulator-min-microvolt = <1200000>;
|
||||
regulator-max-microvolt = <1800000>;
|
||||
regulator-enable-ramp-delay = <216>;
|
||||
};
|
||||
|
||||
mt6323_vcn18_reg: ldo_vcn18{
|
||||
regulator-name = "vcn18";
|
||||
regulator-min-microvolt = <1800000>;
|
||||
regulator-max-microvolt = <1800000>;
|
||||
regulator-enable-ramp-delay = <216>;
|
||||
};
|
||||
|
||||
mt6323_vsim1_reg: ldo_vsim1{
|
||||
regulator-name = "vsim1";
|
||||
regulator-min-microvolt = <1800000>;
|
||||
regulator-max-microvolt = <3000000>;
|
||||
regulator-enable-ramp-delay = <216>;
|
||||
};
|
||||
|
||||
mt6323_vsim2_reg: ldo_vsim2{
|
||||
regulator-name = "vsim2";
|
||||
regulator-min-microvolt = <1800000>;
|
||||
regulator-max-microvolt = <3000000>;
|
||||
regulator-enable-ramp-delay = <216>;
|
||||
};
|
||||
|
||||
mt6323_vrtc_reg: ldo_vrtc{
|
||||
regulator-name = "vrtc";
|
||||
regulator-min-microvolt = <2800000>;
|
||||
regulator-max-microvolt = <2800000>;
|
||||
regulator-always-on;
|
||||
regulator-boot-on;
|
||||
};
|
||||
|
||||
mt6323_vcamaf_reg: ldo_vcamaf{
|
||||
regulator-name = "vcamaf";
|
||||
regulator-min-microvolt = <1200000>;
|
||||
regulator-max-microvolt = <3300000>;
|
||||
regulator-enable-ramp-delay = <216>;
|
||||
};
|
||||
|
||||
mt6323_vibr_reg: ldo_vibr{
|
||||
regulator-name = "vibr";
|
||||
regulator-min-microvolt = <1200000>;
|
||||
regulator-max-microvolt = <3300000>;
|
||||
regulator-enable-ramp-delay = <36>;
|
||||
};
|
||||
|
||||
mt6323_vrf18_reg: ldo_vrf18{
|
||||
regulator-name = "vrf18";
|
||||
regulator-min-microvolt = <1825000>;
|
||||
regulator-max-microvolt = <1825000>;
|
||||
regulator-enable-ramp-delay = <187>;
|
||||
};
|
||||
|
||||
mt6323_vm_reg: ldo_vm{
|
||||
regulator-name = "vm";
|
||||
regulator-min-microvolt = <1200000>;
|
||||
regulator-max-microvolt = <1800000>;
|
||||
regulator-enable-ramp-delay = <216>;
|
||||
regulator-always-on;
|
||||
regulator-boot-on;
|
||||
};
|
||||
|
||||
mt6323_vio18_reg: ldo_vio18{
|
||||
regulator-name = "vio18";
|
||||
regulator-min-microvolt = <1800000>;
|
||||
regulator-max-microvolt = <1800000>;
|
||||
regulator-enable-ramp-delay = <216>;
|
||||
regulator-always-on;
|
||||
regulator-boot-on;
|
||||
};
|
||||
|
||||
mt6323_vcamd_reg: ldo_vcamd{
|
||||
regulator-name = "vcamd";
|
||||
regulator-min-microvolt = <1200000>;
|
||||
regulator-max-microvolt = <1800000>;
|
||||
regulator-enable-ramp-delay = <216>;
|
||||
};
|
||||
|
||||
mt6323_vcamio_reg: ldo_vcamio{
|
||||
regulator-name = "vcamio";
|
||||
regulator-min-microvolt = <1800000>;
|
||||
regulator-max-microvolt = <1800000>;
|
||||
regulator-enable-ramp-delay = <216>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -363,13 +363,6 @@
|
||||
<MT7623_PIN_274_G2_RXDV_FUNC_G2_RXDV>;
|
||||
};
|
||||
|
||||
pins_eth_esw {
|
||||
pinmux = <MT7623_PIN_273_ESW_INT_FUNC_ESW_INT>;
|
||||
input-enable;
|
||||
drive-strength = <MTK_DRIVE_8mA>;
|
||||
bias-pull-up;
|
||||
};
|
||||
|
||||
pins_eth_rst {
|
||||
pinmux = <MT7623_PIN_15_GPIO15_FUNC_GPIO15>;
|
||||
output-low;
|
||||
|
||||
@@ -363,13 +363,6 @@
|
||||
<MT7623_PIN_274_G2_RXDV_FUNC_G2_RXDV>;
|
||||
};
|
||||
|
||||
pins_eth_esw {
|
||||
pinmux = <MT7623_PIN_273_ESW_INT_FUNC_ESW_INT>;
|
||||
input-enable;
|
||||
drive-strength = <MTK_DRIVE_8mA>;
|
||||
bias-pull-up;
|
||||
};
|
||||
|
||||
pins_eth_rst {
|
||||
pinmux = <MT7623_PIN_15_GPIO15_FUNC_GPIO15>;
|
||||
output-low;
|
||||
|
||||
@@ -38,6 +38,61 @@
|
||||
gpio = <&pio 135 GPIO_ACTIVE_HIGH>;
|
||||
enable-active-high;
|
||||
};
|
||||
|
||||
switch {
|
||||
compatible = "mediatek,mt7530";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
reg = <0>;
|
||||
|
||||
dsa,mii-bus = <&mdio0>;
|
||||
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <ð_default>;
|
||||
|
||||
core-supply = <&mt6323_vpa_reg>;
|
||||
io-supply = <&mt6323_vemc3v3_reg>;
|
||||
|
||||
mediatek,mcm;
|
||||
resets = <ðsys 2>;
|
||||
reset-names = "mcm";
|
||||
|
||||
ports {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
reg = <0>;
|
||||
port@0 {
|
||||
reg = <0>;
|
||||
label = "lan0";
|
||||
};
|
||||
|
||||
port@1 {
|
||||
reg = <1>;
|
||||
label = "lan1";
|
||||
};
|
||||
|
||||
port@2 {
|
||||
reg = <2>;
|
||||
label = "lan2";
|
||||
};
|
||||
|
||||
port@3 {
|
||||
reg = <3>;
|
||||
label = "lan3";
|
||||
};
|
||||
|
||||
port@6 {
|
||||
reg = <6>;
|
||||
label = "cpu";
|
||||
ethernet = <&gmac1>;
|
||||
phy-mode = "trgmii";
|
||||
fixed-link {
|
||||
speed = <1000>;
|
||||
full-duplex;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&cpu0 {
|
||||
@@ -428,7 +483,6 @@
|
||||
<MT7623_PIN_270_G2_RXD1_FUNC_G2_RXD1>,
|
||||
<MT7623_PIN_271_G2_RXD2_FUNC_G2_RXD2>,
|
||||
<MT7623_PIN_272_G2_RXD3_FUNC_G2_RXD3>,
|
||||
<MT7623_PIN_273_ESW_INT_FUNC_ESW_INT>,
|
||||
<MT7623_PIN_274_G2_RXDV_FUNC_G2_RXDV>;
|
||||
};
|
||||
|
||||
@@ -480,59 +534,6 @@
|
||||
};
|
||||
|
||||
&mdio0 {
|
||||
switch@0 {
|
||||
compatible = "mediatek,mt7530";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
reg = <0>;
|
||||
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <ð_default>;
|
||||
|
||||
core-supply = <&mt6323_vpa_reg>;
|
||||
io-supply = <&mt6323_vemc3v3_reg>;
|
||||
|
||||
mediatek,mcm;
|
||||
resets = <ðsys 2>;
|
||||
reset-names = "mcm";
|
||||
|
||||
ports {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
reg = <0>;
|
||||
port@0 {
|
||||
reg = <0>;
|
||||
label = "lan0";
|
||||
};
|
||||
|
||||
port@1 {
|
||||
reg = <1>;
|
||||
label = "lan1";
|
||||
};
|
||||
|
||||
port@2 {
|
||||
reg = <2>;
|
||||
label = "lan2";
|
||||
};
|
||||
|
||||
port@3 {
|
||||
reg = <3>;
|
||||
label = "lan3";
|
||||
};
|
||||
|
||||
port@6 {
|
||||
reg = <6>;
|
||||
label = "cpu";
|
||||
ethernet = <&gmac1>;
|
||||
phy-mode = "trgmii";
|
||||
fixed-link {
|
||||
speed = <1000>;
|
||||
full-duplex;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
phy5: ethernet-phy@5 {
|
||||
reg = <5>;
|
||||
phy-mode = "rgmii-rxid";
|
||||
|
||||
@@ -0,0 +1,443 @@
|
||||
/*
|
||||
* Copyright 2017 Sean Wang <sean.wang@mediatek.com>
|
||||
*
|
||||
* SPDX-License-Identifier: (GPL-2.0+ OR MIT)
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
#include <dt-bindings/input/input.h>
|
||||
#include "_mt7623.dtsi"
|
||||
#include "mt6323.dtsi"
|
||||
|
||||
/ {
|
||||
model = "Bananapi BPI-R2";
|
||||
compatible = "bananapi,bpi-r2", "mediatek,mt7623";
|
||||
|
||||
aliases {
|
||||
serial2 = &uart2;
|
||||
};
|
||||
|
||||
chosen {
|
||||
stdout-path = "serial2:115200n8";
|
||||
};
|
||||
|
||||
cpus {
|
||||
cpu@0 {
|
||||
proc-supply = <&mt6323_vproc_reg>;
|
||||
};
|
||||
|
||||
cpu@1 {
|
||||
proc-supply = <&mt6323_vproc_reg>;
|
||||
};
|
||||
|
||||
cpu@2 {
|
||||
proc-supply = <&mt6323_vproc_reg>;
|
||||
};
|
||||
|
||||
cpu@3 {
|
||||
proc-supply = <&mt6323_vproc_reg>;
|
||||
};
|
||||
};
|
||||
|
||||
gpio_keys {
|
||||
compatible = "gpio-keys";
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&key_pins_a>;
|
||||
|
||||
factory {
|
||||
label = "factory";
|
||||
linux,code = <BTN_0>;
|
||||
gpios = <&pio 256 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
|
||||
wps {
|
||||
label = "wps";
|
||||
linux,code = <KEY_WPS_BUTTON>;
|
||||
gpios = <&pio 257 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "gpio-leds";
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&led_pins_a>;
|
||||
|
||||
red {
|
||||
label = "bpi-r2:pio:red";
|
||||
gpios = <&pio 239 GPIO_ACTIVE_HIGH>;
|
||||
default-state = "off";
|
||||
};
|
||||
|
||||
green {
|
||||
label = "bpi-r2:pio:green";
|
||||
gpios = <&pio 240 GPIO_ACTIVE_HIGH>;
|
||||
default-state = "off";
|
||||
};
|
||||
|
||||
blue {
|
||||
label = "bpi-r2:pio:blue";
|
||||
gpios = <&pio 241 GPIO_ACTIVE_HIGH>;
|
||||
default-state = "off";
|
||||
};
|
||||
};
|
||||
|
||||
memory@80000000 {
|
||||
reg = <0 0x80000000 0 0x40000000>;
|
||||
};
|
||||
};
|
||||
|
||||
&cir {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&cir_pins_a>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&crypto {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
ð {
|
||||
status = "okay";
|
||||
gmac0: mac@0 {
|
||||
compatible = "mediatek,eth-mac";
|
||||
reg = <0>;
|
||||
phy-mode = "trgmii";
|
||||
fixed-link {
|
||||
speed = <1000>;
|
||||
full-duplex;
|
||||
pause;
|
||||
};
|
||||
};
|
||||
|
||||
mdio: mdio-bus {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
switch@0 {
|
||||
compatible = "mediatek,mt7530";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
reg = <0>;
|
||||
|
||||
pinctrl-names = "default";
|
||||
reset-gpios = <&pio 33 0>;
|
||||
core-supply = <&mt6323_vpa_reg>;
|
||||
io-supply = <&mt6323_vemc3v3_reg>;
|
||||
|
||||
ports {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
reg = <0>;
|
||||
port@0 {
|
||||
reg = <0>;
|
||||
label = "wan";
|
||||
};
|
||||
|
||||
port@1 {
|
||||
reg = <1>;
|
||||
label = "lan0";
|
||||
};
|
||||
|
||||
port@2 {
|
||||
reg = <2>;
|
||||
label = "lan1";
|
||||
};
|
||||
|
||||
port@3 {
|
||||
reg = <3>;
|
||||
label = "lan2";
|
||||
};
|
||||
|
||||
port@4 {
|
||||
reg = <4>;
|
||||
label = "lan3";
|
||||
};
|
||||
|
||||
port@6 {
|
||||
reg = <6>;
|
||||
label = "cpu";
|
||||
ethernet = <&gmac0>;
|
||||
phy-mode = "trgmii";
|
||||
fixed-link {
|
||||
speed = <1000>;
|
||||
full-duplex;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&i2c0 {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&i2c0_pins_a>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&i2c1 {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&i2c1_pins_a>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&pio {
|
||||
cir_pins_a:cir@0 {
|
||||
pins_cir {
|
||||
pinmux = <MT7623_PIN_46_IR_FUNC_IR>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
i2c0_pins_a: i2c@0 {
|
||||
pins_i2c0 {
|
||||
pinmux = <MT7623_PIN_75_SDA0_FUNC_SDA0>,
|
||||
<MT7623_PIN_76_SCL0_FUNC_SCL0>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
i2c1_pins_a: i2c@1 {
|
||||
pin_i2c1 {
|
||||
pinmux = <MT7623_PIN_57_SDA1_FUNC_SDA1>,
|
||||
<MT7623_PIN_58_SCL1_FUNC_SCL1>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
i2s0_pins_a: i2s@0 {
|
||||
pin_i2s0 {
|
||||
pinmux = <MT7623_PIN_49_I2S0_DATA_FUNC_I2S0_DATA>,
|
||||
<MT7623_PIN_72_I2S0_DATA_IN_FUNC_I2S0_DATA_IN>,
|
||||
<MT7623_PIN_73_I2S0_LRCK_FUNC_I2S0_LRCK>,
|
||||
<MT7623_PIN_74_I2S0_BCK_FUNC_I2S0_BCK>,
|
||||
<MT7623_PIN_126_I2S0_MCLK_FUNC_I2S0_MCLK>;
|
||||
drive-strength = <MTK_DRIVE_12mA>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
i2s1_pins_a: i2s@1 {
|
||||
pin_i2s1 {
|
||||
pinmux = <MT7623_PIN_33_I2S1_DATA_FUNC_I2S1_DATA>,
|
||||
<MT7623_PIN_34_I2S1_DATA_IN_FUNC_I2S1_DATA_IN>,
|
||||
<MT7623_PIN_35_I2S1_BCK_FUNC_I2S1_BCK>,
|
||||
<MT7623_PIN_36_I2S1_LRCK_FUNC_I2S1_LRCK>,
|
||||
<MT7623_PIN_37_I2S1_MCLK_FUNC_I2S1_MCLK>;
|
||||
drive-strength = <MTK_DRIVE_12mA>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
key_pins_a: keys@0 {
|
||||
pins_keys {
|
||||
pinmux = <MT7623_PIN_256_GPIO256_FUNC_GPIO256>,
|
||||
<MT7623_PIN_257_GPIO257_FUNC_GPIO257> ;
|
||||
input-enable;
|
||||
};
|
||||
};
|
||||
|
||||
led_pins_a: leds@0 {
|
||||
pins_leds {
|
||||
pinmux = <MT7623_PIN_239_EXT_SDIO0_FUNC_GPIO239>,
|
||||
<MT7623_PIN_240_EXT_XCS_FUNC_GPIO240>,
|
||||
<MT7623_PIN_241_EXT_SCK_FUNC_GPIO241>;
|
||||
};
|
||||
};
|
||||
|
||||
mmc0_pins_default: mmc0default {
|
||||
pins_cmd_dat {
|
||||
pinmux = <MT7623_PIN_111_MSDC0_DAT7_FUNC_MSDC0_DAT7>,
|
||||
<MT7623_PIN_112_MSDC0_DAT6_FUNC_MSDC0_DAT6>,
|
||||
<MT7623_PIN_113_MSDC0_DAT5_FUNC_MSDC0_DAT5>,
|
||||
<MT7623_PIN_114_MSDC0_DAT4_FUNC_MSDC0_DAT4>,
|
||||
<MT7623_PIN_118_MSDC0_DAT3_FUNC_MSDC0_DAT3>,
|
||||
<MT7623_PIN_119_MSDC0_DAT2_FUNC_MSDC0_DAT2>,
|
||||
<MT7623_PIN_120_MSDC0_DAT1_FUNC_MSDC0_DAT1>,
|
||||
<MT7623_PIN_121_MSDC0_DAT0_FUNC_MSDC0_DAT0>,
|
||||
<MT7623_PIN_116_MSDC0_CMD_FUNC_MSDC0_CMD>;
|
||||
input-enable;
|
||||
bias-pull-up;
|
||||
};
|
||||
|
||||
pins_clk {
|
||||
pinmux = <MT7623_PIN_117_MSDC0_CLK_FUNC_MSDC0_CLK>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
pins_rst {
|
||||
pinmux = <MT7623_PIN_115_MSDC0_RSTB_FUNC_MSDC0_RSTB>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
mmc0_pins_uhs: mmc0 {
|
||||
pins_cmd_dat {
|
||||
pinmux = <MT7623_PIN_111_MSDC0_DAT7_FUNC_MSDC0_DAT7>,
|
||||
<MT7623_PIN_112_MSDC0_DAT6_FUNC_MSDC0_DAT6>,
|
||||
<MT7623_PIN_113_MSDC0_DAT5_FUNC_MSDC0_DAT5>,
|
||||
<MT7623_PIN_114_MSDC0_DAT4_FUNC_MSDC0_DAT4>,
|
||||
<MT7623_PIN_118_MSDC0_DAT3_FUNC_MSDC0_DAT3>,
|
||||
<MT7623_PIN_119_MSDC0_DAT2_FUNC_MSDC0_DAT2>,
|
||||
<MT7623_PIN_120_MSDC0_DAT1_FUNC_MSDC0_DAT1>,
|
||||
<MT7623_PIN_121_MSDC0_DAT0_FUNC_MSDC0_DAT0>,
|
||||
<MT7623_PIN_116_MSDC0_CMD_FUNC_MSDC0_CMD>;
|
||||
input-enable;
|
||||
drive-strength = <MTK_DRIVE_2mA>;
|
||||
bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
|
||||
};
|
||||
|
||||
pins_clk {
|
||||
pinmux = <MT7623_PIN_117_MSDC0_CLK_FUNC_MSDC0_CLK>;
|
||||
drive-strength = <MTK_DRIVE_2mA>;
|
||||
bias-pull-down = <MTK_PUPD_SET_R1R0_01>;
|
||||
};
|
||||
|
||||
pins_rst {
|
||||
pinmux = <MT7623_PIN_115_MSDC0_RSTB_FUNC_MSDC0_RSTB>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
mmc1_pins_default: mmc1default {
|
||||
pins_cmd_dat {
|
||||
pinmux = <MT7623_PIN_107_MSDC1_DAT0_FUNC_MSDC1_DAT0>,
|
||||
<MT7623_PIN_108_MSDC1_DAT1_FUNC_MSDC1_DAT1>,
|
||||
<MT7623_PIN_109_MSDC1_DAT2_FUNC_MSDC1_DAT2>,
|
||||
<MT7623_PIN_110_MSDC1_DAT3_FUNC_MSDC1_DAT3>,
|
||||
<MT7623_PIN_105_MSDC1_CMD_FUNC_MSDC1_CMD>;
|
||||
input-enable;
|
||||
drive-strength = <MTK_DRIVE_4mA>;
|
||||
bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
|
||||
};
|
||||
|
||||
pins_clk {
|
||||
pinmux = <MT7623_PIN_106_MSDC1_CLK_FUNC_MSDC1_CLK>;
|
||||
bias-pull-down;
|
||||
drive-strength = <MTK_DRIVE_4mA>;
|
||||
};
|
||||
};
|
||||
|
||||
mmc1_pins_uhs: mmc1 {
|
||||
pins_cmd_dat {
|
||||
pinmux = <MT7623_PIN_107_MSDC1_DAT0_FUNC_MSDC1_DAT0>,
|
||||
<MT7623_PIN_108_MSDC1_DAT1_FUNC_MSDC1_DAT1>,
|
||||
<MT7623_PIN_109_MSDC1_DAT2_FUNC_MSDC1_DAT2>,
|
||||
<MT7623_PIN_110_MSDC1_DAT3_FUNC_MSDC1_DAT3>,
|
||||
<MT7623_PIN_105_MSDC1_CMD_FUNC_MSDC1_CMD>;
|
||||
input-enable;
|
||||
drive-strength = <MTK_DRIVE_4mA>;
|
||||
bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
|
||||
};
|
||||
|
||||
pins_clk {
|
||||
pinmux = <MT7623_PIN_106_MSDC1_CLK_FUNC_MSDC1_CLK>;
|
||||
drive-strength = <MTK_DRIVE_4mA>;
|
||||
bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
|
||||
};
|
||||
};
|
||||
|
||||
spi0_pins_a: spi@0 {
|
||||
pins_spi {
|
||||
pinmux = <MT7623_PIN_53_SPI0_CSN_FUNC_SPI0_CS>,
|
||||
<MT7623_PIN_54_SPI0_CK_FUNC_SPI0_CK>,
|
||||
<MT7623_PIN_55_SPI0_MI_FUNC_SPI0_MI>,
|
||||
<MT7623_PIN_56_SPI0_MO_FUNC_SPI0_MO>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
pwm_pins_a: pwm@0 {
|
||||
pins_pwm {
|
||||
pinmux = <MT7623_PIN_203_PWM0_FUNC_PWM0>,
|
||||
<MT7623_PIN_204_PWM1_FUNC_PWM1>,
|
||||
<MT7623_PIN_205_PWM2_FUNC_PWM2>,
|
||||
<MT7623_PIN_206_PWM3_FUNC_PWM3>,
|
||||
<MT7623_PIN_207_PWM4_FUNC_PWM4>;
|
||||
};
|
||||
};
|
||||
|
||||
uart0_pins_a: uart@0 {
|
||||
pins_dat {
|
||||
pinmux = <MT7623_PIN_79_URXD0_FUNC_URXD0>,
|
||||
<MT7623_PIN_80_UTXD0_FUNC_UTXD0>;
|
||||
};
|
||||
};
|
||||
|
||||
uart1_pins_a: uart@1 {
|
||||
pins_dat {
|
||||
pinmux = <MT7623_PIN_81_URXD1_FUNC_URXD1>,
|
||||
<MT7623_PIN_82_UTXD1_FUNC_UTXD1>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&pwm {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&pwm_pins_a>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&pwrap {
|
||||
mt6323 {
|
||||
mt6323led: led {
|
||||
compatible = "mediatek,mt6323-led";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
led@0 {
|
||||
reg = <0>;
|
||||
label = "bpi-r2:isink:green";
|
||||
default-state = "off";
|
||||
};
|
||||
led@1 {
|
||||
reg = <1>;
|
||||
label = "bpi-r2:isink:red";
|
||||
default-state = "off";
|
||||
};
|
||||
led@2 {
|
||||
reg = <2>;
|
||||
label = "bpi-r2:isink:blue";
|
||||
default-state = "off";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&spi0 {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&spi0_pins_a>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&uart0 {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&uart0_pins_a>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
&u3phy1 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&u3phy2 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&uart1 {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&uart1_pins_a>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
&uart2 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&usb1 {
|
||||
vusb33-supply = <&mt6323_vusb_reg>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&usb2 {
|
||||
vusb33-supply = <&mt6323_vusb_reg>;
|
||||
status = "okay";
|
||||
};
|
||||
168
target/linux/mediatek/files/drivers/char/hw_random/mtk-rng.c
Normal file
168
target/linux/mediatek/files/drivers/char/hw_random/mtk-rng.c
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Driver for Mediatek Hardware Random Number Generator
|
||||
*
|
||||
* Copyright (C) 2017 Sean Wang <sean.wang@mediatek.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
#define MTK_RNG_DEV KBUILD_MODNAME
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/hw_random.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/iopoll.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#define USEC_POLL 2
|
||||
#define TIMEOUT_POLL 20
|
||||
|
||||
#define RNG_CTRL 0x00
|
||||
#define RNG_EN BIT(0)
|
||||
#define RNG_READY BIT(31)
|
||||
|
||||
#define RNG_DATA 0x08
|
||||
|
||||
#define to_mtk_rng(p) container_of(p, struct mtk_rng, rng)
|
||||
|
||||
struct mtk_rng {
|
||||
void __iomem *base;
|
||||
struct clk *clk;
|
||||
struct hwrng rng;
|
||||
};
|
||||
|
||||
static int mtk_rng_init(struct hwrng *rng)
|
||||
{
|
||||
struct mtk_rng *priv = to_mtk_rng(rng);
|
||||
u32 val;
|
||||
int err;
|
||||
|
||||
err = clk_prepare_enable(priv->clk);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
val = readl(priv->base + RNG_CTRL);
|
||||
val |= RNG_EN;
|
||||
writel(val, priv->base + RNG_CTRL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mtk_rng_cleanup(struct hwrng *rng)
|
||||
{
|
||||
struct mtk_rng *priv = to_mtk_rng(rng);
|
||||
u32 val;
|
||||
|
||||
val = readl(priv->base + RNG_CTRL);
|
||||
val &= ~RNG_EN;
|
||||
writel(val, priv->base + RNG_CTRL);
|
||||
|
||||
clk_disable_unprepare(priv->clk);
|
||||
}
|
||||
|
||||
static bool mtk_rng_wait_ready(struct hwrng *rng, bool wait)
|
||||
{
|
||||
struct mtk_rng *priv = to_mtk_rng(rng);
|
||||
int ready;
|
||||
|
||||
ready = readl(priv->base + RNG_CTRL) & RNG_READY;
|
||||
if (!ready && wait)
|
||||
readl_poll_timeout_atomic(priv->base + RNG_CTRL, ready,
|
||||
ready & RNG_READY, USEC_POLL,
|
||||
TIMEOUT_POLL);
|
||||
return !!ready;
|
||||
}
|
||||
|
||||
static int mtk_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
|
||||
{
|
||||
struct mtk_rng *priv = to_mtk_rng(rng);
|
||||
int retval = 0;
|
||||
|
||||
while (max >= sizeof(u32)) {
|
||||
if (!mtk_rng_wait_ready(rng, wait))
|
||||
break;
|
||||
|
||||
*(u32 *)buf = readl(priv->base + RNG_DATA);
|
||||
retval += sizeof(u32);
|
||||
buf += sizeof(u32);
|
||||
max -= sizeof(u32);
|
||||
}
|
||||
|
||||
return retval || !wait ? retval : -EIO;
|
||||
}
|
||||
|
||||
static int mtk_rng_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct resource *res;
|
||||
int ret;
|
||||
struct mtk_rng *priv;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!res) {
|
||||
dev_err(&pdev->dev, "no iomem resource\n");
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
priv->rng.name = pdev->name;
|
||||
priv->rng.init = mtk_rng_init;
|
||||
priv->rng.cleanup = mtk_rng_cleanup;
|
||||
priv->rng.read = mtk_rng_read;
|
||||
|
||||
priv->clk = devm_clk_get(&pdev->dev, "rng");
|
||||
if (IS_ERR(priv->clk)) {
|
||||
ret = PTR_ERR(priv->clk);
|
||||
dev_err(&pdev->dev, "no clock for device: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
priv->base = devm_ioremap_resource(&pdev->dev, res);
|
||||
if (IS_ERR(priv->base))
|
||||
return PTR_ERR(priv->base);
|
||||
|
||||
ret = devm_hwrng_register(&pdev->dev, &priv->rng);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "failed to register rng device: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
dev_info(&pdev->dev, "registered RNG driver\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id mtk_rng_match[] = {
|
||||
{ .compatible = "mediatek,mt7623-rng" },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, mtk_rng_match);
|
||||
|
||||
static struct platform_driver mtk_rng_driver = {
|
||||
.probe = mtk_rng_probe,
|
||||
.driver = {
|
||||
.name = MTK_RNG_DEV,
|
||||
.of_match_table = mtk_rng_match,
|
||||
},
|
||||
};
|
||||
|
||||
module_platform_driver(mtk_rng_driver);
|
||||
|
||||
MODULE_DESCRIPTION("Mediatek Random Number Generator Driver");
|
||||
MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
@@ -0,0 +1,2 @@
|
||||
obj-$(CONFIG_CRYPTO_DEV_MEDIATEK) += mtk-crypto.o
|
||||
mtk-crypto-objs:= mtk-platform.o mtk-aes.o mtk-sha.o
|
||||
1304
target/linux/mediatek/files/drivers/crypto/mediatek/mtk-aes.c
Normal file
1304
target/linux/mediatek/files/drivers/crypto/mediatek/mtk-aes.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,607 @@
|
||||
/*
|
||||
* Driver for EIP97 cryptographic accelerator.
|
||||
*
|
||||
* Copyright (c) 2016 Ryder Lee <ryder.lee@mediatek.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include "mtk-platform.h"
|
||||
|
||||
#define MTK_BURST_SIZE_MSK GENMASK(7, 4)
|
||||
#define MTK_BURST_SIZE(x) ((x) << 4)
|
||||
#define MTK_DESC_SIZE(x) ((x) << 0)
|
||||
#define MTK_DESC_OFFSET(x) ((x) << 16)
|
||||
#define MTK_DESC_FETCH_SIZE(x) ((x) << 0)
|
||||
#define MTK_DESC_FETCH_THRESH(x) ((x) << 16)
|
||||
#define MTK_DESC_OVL_IRQ_EN BIT(25)
|
||||
#define MTK_DESC_ATP_PRESENT BIT(30)
|
||||
|
||||
#define MTK_DFSE_IDLE GENMASK(3, 0)
|
||||
#define MTK_DFSE_THR_CTRL_EN BIT(30)
|
||||
#define MTK_DFSE_THR_CTRL_RESET BIT(31)
|
||||
#define MTK_DFSE_RING_ID(x) (((x) >> 12) & GENMASK(3, 0))
|
||||
#define MTK_DFSE_MIN_DATA(x) ((x) << 0)
|
||||
#define MTK_DFSE_MAX_DATA(x) ((x) << 8)
|
||||
#define MTK_DFE_MIN_CTRL(x) ((x) << 16)
|
||||
#define MTK_DFE_MAX_CTRL(x) ((x) << 24)
|
||||
|
||||
#define MTK_IN_BUF_MIN_THRESH(x) ((x) << 8)
|
||||
#define MTK_IN_BUF_MAX_THRESH(x) ((x) << 12)
|
||||
#define MTK_OUT_BUF_MIN_THRESH(x) ((x) << 0)
|
||||
#define MTK_OUT_BUF_MAX_THRESH(x) ((x) << 4)
|
||||
#define MTK_IN_TBUF_SIZE(x) (((x) >> 4) & GENMASK(3, 0))
|
||||
#define MTK_IN_DBUF_SIZE(x) (((x) >> 8) & GENMASK(3, 0))
|
||||
#define MTK_OUT_DBUF_SIZE(x) (((x) >> 16) & GENMASK(3, 0))
|
||||
#define MTK_CMD_FIFO_SIZE(x) (((x) >> 8) & GENMASK(3, 0))
|
||||
#define MTK_RES_FIFO_SIZE(x) (((x) >> 12) & GENMASK(3, 0))
|
||||
|
||||
#define MTK_PE_TK_LOC_AVL BIT(2)
|
||||
#define MTK_PE_PROC_HELD BIT(14)
|
||||
#define MTK_PE_TK_TIMEOUT_EN BIT(22)
|
||||
#define MTK_PE_INPUT_DMA_ERR BIT(0)
|
||||
#define MTK_PE_OUTPUT_DMA_ERR BIT(1)
|
||||
#define MTK_PE_PKT_PORC_ERR BIT(2)
|
||||
#define MTK_PE_PKT_TIMEOUT BIT(3)
|
||||
#define MTK_PE_FATAL_ERR BIT(14)
|
||||
#define MTK_PE_INPUT_DMA_ERR_EN BIT(16)
|
||||
#define MTK_PE_OUTPUT_DMA_ERR_EN BIT(17)
|
||||
#define MTK_PE_PKT_PORC_ERR_EN BIT(18)
|
||||
#define MTK_PE_PKT_TIMEOUT_EN BIT(19)
|
||||
#define MTK_PE_FATAL_ERR_EN BIT(30)
|
||||
#define MTK_PE_INT_OUT_EN BIT(31)
|
||||
|
||||
#define MTK_HIA_SIGNATURE ((u16)0x35ca)
|
||||
#define MTK_HIA_DATA_WIDTH(x) (((x) >> 25) & GENMASK(1, 0))
|
||||
#define MTK_HIA_DMA_LENGTH(x) (((x) >> 20) & GENMASK(4, 0))
|
||||
#define MTK_CDR_STAT_CLR GENMASK(4, 0)
|
||||
#define MTK_RDR_STAT_CLR GENMASK(7, 0)
|
||||
|
||||
#define MTK_AIC_INT_MSK GENMASK(5, 0)
|
||||
#define MTK_AIC_VER_MSK (GENMASK(15, 0) | GENMASK(27, 20))
|
||||
#define MTK_AIC_VER11 0x011036c9
|
||||
#define MTK_AIC_VER12 0x012036c9
|
||||
#define MTK_AIC_G_CLR GENMASK(30, 20)
|
||||
|
||||
/**
|
||||
* EIP97 is an integrated security subsystem to accelerate cryptographic
|
||||
* functions and protocols to offload the host processor.
|
||||
* Some important hardware modules are briefly introduced below:
|
||||
*
|
||||
* Host Interface Adapter(HIA) - the main interface between the host
|
||||
* system and the hardware subsystem. It is responsible for attaching
|
||||
* processing engine to the specific host bus interface and provides a
|
||||
* standardized software view for off loading tasks to the engine.
|
||||
*
|
||||
* Command Descriptor Ring Manager(CDR Manager) - keeps track of how many
|
||||
* CD the host has prepared in the CDR. It monitors the fill level of its
|
||||
* CD-FIFO and if there's sufficient space for the next block of descriptors,
|
||||
* then it fires off a DMA request to fetch a block of CDs.
|
||||
*
|
||||
* Data fetch engine(DFE) - It is responsible for parsing the CD and
|
||||
* setting up the required control and packet data DMA transfers from
|
||||
* system memory to the processing engine.
|
||||
*
|
||||
* Result Descriptor Ring Manager(RDR Manager) - same as CDR Manager,
|
||||
* but target is result descriptors, Moreover, it also handles the RD
|
||||
* updates under control of the DSE. For each packet data segment
|
||||
* processed, the DSE triggers the RDR Manager to write the updated RD.
|
||||
* If triggered to update, the RDR Manager sets up a DMA operation to
|
||||
* copy the RD from the DSE to the correct location in the RDR.
|
||||
*
|
||||
* Data Store Engine(DSE) - It is responsible for parsing the prepared RD
|
||||
* and setting up the required control and packet data DMA transfers from
|
||||
* the processing engine to system memory.
|
||||
*
|
||||
* Advanced Interrupt Controllers(AICs) - receive interrupt request signals
|
||||
* from various sources and combine them into one interrupt output.
|
||||
* The AICs are used by:
|
||||
* - One for the HIA global and processing engine interrupts.
|
||||
* - The others for the descriptor ring interrupts.
|
||||
*/
|
||||
|
||||
/* Cryptographic engine capabilities */
|
||||
struct mtk_sys_cap {
|
||||
/* host interface adapter */
|
||||
u32 hia_ver;
|
||||
u32 hia_opt;
|
||||
/* packet engine */
|
||||
u32 pkt_eng_opt;
|
||||
/* global hardware */
|
||||
u32 hw_opt;
|
||||
};
|
||||
|
||||
static void mtk_desc_ring_link(struct mtk_cryp *cryp, u32 mask)
|
||||
{
|
||||
/* Assign rings to DFE/DSE thread and enable it */
|
||||
writel(MTK_DFSE_THR_CTRL_EN | mask, cryp->base + DFE_THR_CTRL);
|
||||
writel(MTK_DFSE_THR_CTRL_EN | mask, cryp->base + DSE_THR_CTRL);
|
||||
}
|
||||
|
||||
static void mtk_dfe_dse_buf_setup(struct mtk_cryp *cryp,
|
||||
struct mtk_sys_cap *cap)
|
||||
{
|
||||
u32 width = MTK_HIA_DATA_WIDTH(cap->hia_opt) + 2;
|
||||
u32 len = MTK_HIA_DMA_LENGTH(cap->hia_opt) - 1;
|
||||
u32 ipbuf = min((u32)MTK_IN_DBUF_SIZE(cap->hw_opt) + width, len);
|
||||
u32 opbuf = min((u32)MTK_OUT_DBUF_SIZE(cap->hw_opt) + width, len);
|
||||
u32 itbuf = min((u32)MTK_IN_TBUF_SIZE(cap->hw_opt) + width, len);
|
||||
|
||||
writel(MTK_DFSE_MIN_DATA(ipbuf - 1) |
|
||||
MTK_DFSE_MAX_DATA(ipbuf) |
|
||||
MTK_DFE_MIN_CTRL(itbuf - 1) |
|
||||
MTK_DFE_MAX_CTRL(itbuf),
|
||||
cryp->base + DFE_CFG);
|
||||
|
||||
writel(MTK_DFSE_MIN_DATA(opbuf - 1) |
|
||||
MTK_DFSE_MAX_DATA(opbuf),
|
||||
cryp->base + DSE_CFG);
|
||||
|
||||
writel(MTK_IN_BUF_MIN_THRESH(ipbuf - 1) |
|
||||
MTK_IN_BUF_MAX_THRESH(ipbuf),
|
||||
cryp->base + PE_IN_DBUF_THRESH);
|
||||
|
||||
writel(MTK_IN_BUF_MIN_THRESH(itbuf - 1) |
|
||||
MTK_IN_BUF_MAX_THRESH(itbuf),
|
||||
cryp->base + PE_IN_TBUF_THRESH);
|
||||
|
||||
writel(MTK_OUT_BUF_MIN_THRESH(opbuf - 1) |
|
||||
MTK_OUT_BUF_MAX_THRESH(opbuf),
|
||||
cryp->base + PE_OUT_DBUF_THRESH);
|
||||
|
||||
writel(0, cryp->base + PE_OUT_TBUF_THRESH);
|
||||
writel(0, cryp->base + PE_OUT_BUF_CTRL);
|
||||
}
|
||||
|
||||
static int mtk_dfe_dse_state_check(struct mtk_cryp *cryp)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
u32 val;
|
||||
|
||||
/* Check for completion of all DMA transfers */
|
||||
val = readl(cryp->base + DFE_THR_STAT);
|
||||
if (MTK_DFSE_RING_ID(val) == MTK_DFSE_IDLE) {
|
||||
val = readl(cryp->base + DSE_THR_STAT);
|
||||
if (MTK_DFSE_RING_ID(val) == MTK_DFSE_IDLE)
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
/* Take DFE/DSE thread out of reset */
|
||||
writel(0, cryp->base + DFE_THR_CTRL);
|
||||
writel(0, cryp->base + DSE_THR_CTRL);
|
||||
} else {
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mtk_dfe_dse_reset(struct mtk_cryp *cryp)
|
||||
{
|
||||
int err;
|
||||
|
||||
/* Reset DSE/DFE and correct system priorities for all rings. */
|
||||
writel(MTK_DFSE_THR_CTRL_RESET, cryp->base + DFE_THR_CTRL);
|
||||
writel(0, cryp->base + DFE_PRIO_0);
|
||||
writel(0, cryp->base + DFE_PRIO_1);
|
||||
writel(0, cryp->base + DFE_PRIO_2);
|
||||
writel(0, cryp->base + DFE_PRIO_3);
|
||||
|
||||
writel(MTK_DFSE_THR_CTRL_RESET, cryp->base + DSE_THR_CTRL);
|
||||
writel(0, cryp->base + DSE_PRIO_0);
|
||||
writel(0, cryp->base + DSE_PRIO_1);
|
||||
writel(0, cryp->base + DSE_PRIO_2);
|
||||
writel(0, cryp->base + DSE_PRIO_3);
|
||||
|
||||
err = mtk_dfe_dse_state_check(cryp);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mtk_cmd_desc_ring_setup(struct mtk_cryp *cryp,
|
||||
int i, struct mtk_sys_cap *cap)
|
||||
{
|
||||
/* Full descriptor that fits FIFO minus one */
|
||||
u32 count =
|
||||
((1 << MTK_CMD_FIFO_SIZE(cap->hia_opt)) / MTK_DESC_SZ) - 1;
|
||||
|
||||
/* Temporarily disable external triggering */
|
||||
writel(0, cryp->base + CDR_CFG(i));
|
||||
|
||||
/* Clear CDR count */
|
||||
writel(MTK_CNT_RST, cryp->base + CDR_PREP_COUNT(i));
|
||||
writel(MTK_CNT_RST, cryp->base + CDR_PROC_COUNT(i));
|
||||
|
||||
writel(0, cryp->base + CDR_PREP_PNTR(i));
|
||||
writel(0, cryp->base + CDR_PROC_PNTR(i));
|
||||
writel(0, cryp->base + CDR_DMA_CFG(i));
|
||||
|
||||
/* Configure CDR host address space */
|
||||
writel(0, cryp->base + CDR_BASE_ADDR_HI(i));
|
||||
writel(cryp->ring[i]->cmd_dma, cryp->base + CDR_BASE_ADDR_LO(i));
|
||||
|
||||
writel(MTK_DESC_RING_SZ, cryp->base + CDR_RING_SIZE(i));
|
||||
|
||||
/* Clear and disable all CDR interrupts */
|
||||
writel(MTK_CDR_STAT_CLR, cryp->base + CDR_STAT(i));
|
||||
|
||||
/*
|
||||
* Set command descriptor offset and enable additional
|
||||
* token present in descriptor.
|
||||
*/
|
||||
writel(MTK_DESC_SIZE(MTK_DESC_SZ) |
|
||||
MTK_DESC_OFFSET(MTK_DESC_OFF) |
|
||||
MTK_DESC_ATP_PRESENT,
|
||||
cryp->base + CDR_DESC_SIZE(i));
|
||||
|
||||
writel(MTK_DESC_FETCH_SIZE(count * MTK_DESC_OFF) |
|
||||
MTK_DESC_FETCH_THRESH(count * MTK_DESC_SZ),
|
||||
cryp->base + CDR_CFG(i));
|
||||
}
|
||||
|
||||
static void mtk_res_desc_ring_setup(struct mtk_cryp *cryp,
|
||||
int i, struct mtk_sys_cap *cap)
|
||||
{
|
||||
u32 rndup = 2;
|
||||
u32 count = ((1 << MTK_RES_FIFO_SIZE(cap->hia_opt)) / rndup) - 1;
|
||||
|
||||
/* Temporarily disable external triggering */
|
||||
writel(0, cryp->base + RDR_CFG(i));
|
||||
|
||||
/* Clear RDR count */
|
||||
writel(MTK_CNT_RST, cryp->base + RDR_PREP_COUNT(i));
|
||||
writel(MTK_CNT_RST, cryp->base + RDR_PROC_COUNT(i));
|
||||
|
||||
writel(0, cryp->base + RDR_PREP_PNTR(i));
|
||||
writel(0, cryp->base + RDR_PROC_PNTR(i));
|
||||
writel(0, cryp->base + RDR_DMA_CFG(i));
|
||||
|
||||
/* Configure RDR host address space */
|
||||
writel(0, cryp->base + RDR_BASE_ADDR_HI(i));
|
||||
writel(cryp->ring[i]->res_dma, cryp->base + RDR_BASE_ADDR_LO(i));
|
||||
|
||||
writel(MTK_DESC_RING_SZ, cryp->base + RDR_RING_SIZE(i));
|
||||
writel(MTK_RDR_STAT_CLR, cryp->base + RDR_STAT(i));
|
||||
|
||||
/*
|
||||
* RDR manager generates update interrupts on a per-completed-packet,
|
||||
* and the rd_proc_thresh_irq interrupt is fired when proc_pkt_count
|
||||
* for the RDR exceeds the number of packets.
|
||||
*/
|
||||
writel(MTK_RDR_PROC_THRESH | MTK_RDR_PROC_MODE,
|
||||
cryp->base + RDR_THRESH(i));
|
||||
|
||||
/*
|
||||
* Configure a threshold and time-out value for the processed
|
||||
* result descriptors (or complete packets) that are written to
|
||||
* the RDR.
|
||||
*/
|
||||
writel(MTK_DESC_SIZE(MTK_DESC_SZ) | MTK_DESC_OFFSET(MTK_DESC_OFF),
|
||||
cryp->base + RDR_DESC_SIZE(i));
|
||||
|
||||
/*
|
||||
* Configure HIA fetch size and fetch threshold that are used to
|
||||
* fetch blocks of multiple descriptors.
|
||||
*/
|
||||
writel(MTK_DESC_FETCH_SIZE(count * MTK_DESC_OFF) |
|
||||
MTK_DESC_FETCH_THRESH(count * rndup) |
|
||||
MTK_DESC_OVL_IRQ_EN,
|
||||
cryp->base + RDR_CFG(i));
|
||||
}
|
||||
|
||||
static int mtk_packet_engine_setup(struct mtk_cryp *cryp)
|
||||
{
|
||||
struct mtk_sys_cap cap;
|
||||
int i, err;
|
||||
u32 val;
|
||||
|
||||
cap.hia_ver = readl(cryp->base + HIA_VERSION);
|
||||
cap.hia_opt = readl(cryp->base + HIA_OPTIONS);
|
||||
cap.hw_opt = readl(cryp->base + EIP97_OPTIONS);
|
||||
|
||||
if (!(((u16)cap.hia_ver) == MTK_HIA_SIGNATURE))
|
||||
return -EINVAL;
|
||||
|
||||
/* Configure endianness conversion method for master (DMA) interface */
|
||||
writel(0, cryp->base + EIP97_MST_CTRL);
|
||||
|
||||
/* Set HIA burst size */
|
||||
val = readl(cryp->base + HIA_MST_CTRL);
|
||||
val &= ~MTK_BURST_SIZE_MSK;
|
||||
val |= MTK_BURST_SIZE(5);
|
||||
writel(val, cryp->base + HIA_MST_CTRL);
|
||||
|
||||
err = mtk_dfe_dse_reset(cryp);
|
||||
if (err) {
|
||||
dev_err(cryp->dev, "Failed to reset DFE and DSE.\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
mtk_dfe_dse_buf_setup(cryp, &cap);
|
||||
|
||||
/* Enable the 4 rings for the packet engines. */
|
||||
mtk_desc_ring_link(cryp, 0xf);
|
||||
|
||||
for (i = 0; i < MTK_RING_MAX; i++) {
|
||||
mtk_cmd_desc_ring_setup(cryp, i, &cap);
|
||||
mtk_res_desc_ring_setup(cryp, i, &cap);
|
||||
}
|
||||
|
||||
writel(MTK_PE_TK_LOC_AVL | MTK_PE_PROC_HELD | MTK_PE_TK_TIMEOUT_EN,
|
||||
cryp->base + PE_TOKEN_CTRL_STAT);
|
||||
|
||||
/* Clear all pending interrupts */
|
||||
writel(MTK_AIC_G_CLR, cryp->base + AIC_G_ACK);
|
||||
writel(MTK_PE_INPUT_DMA_ERR | MTK_PE_OUTPUT_DMA_ERR |
|
||||
MTK_PE_PKT_PORC_ERR | MTK_PE_PKT_TIMEOUT |
|
||||
MTK_PE_FATAL_ERR | MTK_PE_INPUT_DMA_ERR_EN |
|
||||
MTK_PE_OUTPUT_DMA_ERR_EN | MTK_PE_PKT_PORC_ERR_EN |
|
||||
MTK_PE_PKT_TIMEOUT_EN | MTK_PE_FATAL_ERR_EN |
|
||||
MTK_PE_INT_OUT_EN,
|
||||
cryp->base + PE_INTERRUPT_CTRL_STAT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mtk_aic_cap_check(struct mtk_cryp *cryp, int hw)
|
||||
{
|
||||
u32 val;
|
||||
|
||||
if (hw == MTK_RING_MAX)
|
||||
val = readl(cryp->base + AIC_G_VERSION);
|
||||
else
|
||||
val = readl(cryp->base + AIC_VERSION(hw));
|
||||
|
||||
val &= MTK_AIC_VER_MSK;
|
||||
if (val != MTK_AIC_VER11 && val != MTK_AIC_VER12)
|
||||
return -ENXIO;
|
||||
|
||||
if (hw == MTK_RING_MAX)
|
||||
val = readl(cryp->base + AIC_G_OPTIONS);
|
||||
else
|
||||
val = readl(cryp->base + AIC_OPTIONS(hw));
|
||||
|
||||
val &= MTK_AIC_INT_MSK;
|
||||
if (!val || val > 32)
|
||||
return -ENXIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mtk_aic_init(struct mtk_cryp *cryp, int hw)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = mtk_aic_cap_check(cryp, hw);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* Disable all interrupts and set initial configuration */
|
||||
if (hw == MTK_RING_MAX) {
|
||||
writel(0, cryp->base + AIC_G_ENABLE_CTRL);
|
||||
writel(0, cryp->base + AIC_G_POL_CTRL);
|
||||
writel(0, cryp->base + AIC_G_TYPE_CTRL);
|
||||
writel(0, cryp->base + AIC_G_ENABLE_SET);
|
||||
} else {
|
||||
writel(0, cryp->base + AIC_ENABLE_CTRL(hw));
|
||||
writel(0, cryp->base + AIC_POL_CTRL(hw));
|
||||
writel(0, cryp->base + AIC_TYPE_CTRL(hw));
|
||||
writel(0, cryp->base + AIC_ENABLE_SET(hw));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mtk_accelerator_init(struct mtk_cryp *cryp)
|
||||
{
|
||||
int i, err;
|
||||
|
||||
/* Initialize advanced interrupt controller(AIC) */
|
||||
for (i = 0; i < MTK_IRQ_NUM; i++) {
|
||||
err = mtk_aic_init(cryp, i);
|
||||
if (err) {
|
||||
dev_err(cryp->dev, "Failed to initialize AIC.\n");
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize packet engine */
|
||||
err = mtk_packet_engine_setup(cryp);
|
||||
if (err) {
|
||||
dev_err(cryp->dev, "Failed to configure packet engine.\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mtk_desc_dma_free(struct mtk_cryp *cryp)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MTK_RING_MAX; i++) {
|
||||
dma_free_coherent(cryp->dev, MTK_DESC_RING_SZ,
|
||||
cryp->ring[i]->res_base,
|
||||
cryp->ring[i]->res_dma);
|
||||
dma_free_coherent(cryp->dev, MTK_DESC_RING_SZ,
|
||||
cryp->ring[i]->cmd_base,
|
||||
cryp->ring[i]->cmd_dma);
|
||||
kfree(cryp->ring[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static int mtk_desc_ring_alloc(struct mtk_cryp *cryp)
|
||||
{
|
||||
struct mtk_ring **ring = cryp->ring;
|
||||
int i, err = ENOMEM;
|
||||
|
||||
for (i = 0; i < MTK_RING_MAX; i++) {
|
||||
ring[i] = kzalloc(sizeof(**ring), GFP_KERNEL);
|
||||
if (!ring[i])
|
||||
goto err_cleanup;
|
||||
|
||||
ring[i]->cmd_base = dma_zalloc_coherent(cryp->dev,
|
||||
MTK_DESC_RING_SZ,
|
||||
&ring[i]->cmd_dma,
|
||||
GFP_KERNEL);
|
||||
if (!ring[i]->cmd_base)
|
||||
goto err_cleanup;
|
||||
|
||||
ring[i]->res_base = dma_zalloc_coherent(cryp->dev,
|
||||
MTK_DESC_RING_SZ,
|
||||
&ring[i]->res_dma,
|
||||
GFP_KERNEL);
|
||||
if (!ring[i]->res_base)
|
||||
goto err_cleanup;
|
||||
|
||||
ring[i]->cmd_next = ring[i]->cmd_base;
|
||||
ring[i]->res_next = ring[i]->res_base;
|
||||
}
|
||||
return 0;
|
||||
|
||||
err_cleanup:
|
||||
for (; i--; ) {
|
||||
dma_free_coherent(cryp->dev, MTK_DESC_RING_SZ,
|
||||
ring[i]->res_base, ring[i]->res_dma);
|
||||
dma_free_coherent(cryp->dev, MTK_DESC_RING_SZ,
|
||||
ring[i]->cmd_base, ring[i]->cmd_dma);
|
||||
kfree(ring[i]);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static int mtk_crypto_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
struct mtk_cryp *cryp;
|
||||
int i, err;
|
||||
|
||||
cryp = devm_kzalloc(&pdev->dev, sizeof(*cryp), GFP_KERNEL);
|
||||
if (!cryp)
|
||||
return -ENOMEM;
|
||||
|
||||
cryp->base = devm_ioremap_resource(&pdev->dev, res);
|
||||
if (IS_ERR(cryp->base))
|
||||
return PTR_ERR(cryp->base);
|
||||
|
||||
for (i = 0; i < MTK_IRQ_NUM; i++) {
|
||||
cryp->irq[i] = platform_get_irq(pdev, i);
|
||||
if (cryp->irq[i] < 0) {
|
||||
dev_err(cryp->dev, "no IRQ:%d resource info\n", i);
|
||||
return -ENXIO;
|
||||
}
|
||||
}
|
||||
|
||||
cryp->clk_ethif = devm_clk_get(&pdev->dev, "ethif");
|
||||
cryp->clk_cryp = devm_clk_get(&pdev->dev, "cryp");
|
||||
if (IS_ERR(cryp->clk_ethif) || IS_ERR(cryp->clk_cryp))
|
||||
return -EPROBE_DEFER;
|
||||
|
||||
cryp->dev = &pdev->dev;
|
||||
pm_runtime_enable(cryp->dev);
|
||||
pm_runtime_get_sync(cryp->dev);
|
||||
|
||||
err = clk_prepare_enable(cryp->clk_ethif);
|
||||
if (err)
|
||||
goto err_clk_ethif;
|
||||
|
||||
err = clk_prepare_enable(cryp->clk_cryp);
|
||||
if (err)
|
||||
goto err_clk_cryp;
|
||||
|
||||
/* Allocate four command/result descriptor rings */
|
||||
err = mtk_desc_ring_alloc(cryp);
|
||||
if (err) {
|
||||
dev_err(cryp->dev, "Unable to allocate descriptor rings.\n");
|
||||
goto err_resource;
|
||||
}
|
||||
|
||||
/* Initialize hardware modules */
|
||||
err = mtk_accelerator_init(cryp);
|
||||
if (err) {
|
||||
dev_err(cryp->dev, "Failed to initialize cryptographic engine.\n");
|
||||
goto err_engine;
|
||||
}
|
||||
|
||||
err = mtk_cipher_alg_register(cryp);
|
||||
if (err) {
|
||||
dev_err(cryp->dev, "Unable to register cipher algorithm.\n");
|
||||
goto err_cipher;
|
||||
}
|
||||
|
||||
err = mtk_hash_alg_register(cryp);
|
||||
if (err) {
|
||||
dev_err(cryp->dev, "Unable to register hash algorithm.\n");
|
||||
goto err_hash;
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, cryp);
|
||||
return 0;
|
||||
|
||||
err_hash:
|
||||
mtk_cipher_alg_release(cryp);
|
||||
err_cipher:
|
||||
mtk_dfe_dse_reset(cryp);
|
||||
err_engine:
|
||||
mtk_desc_dma_free(cryp);
|
||||
err_resource:
|
||||
clk_disable_unprepare(cryp->clk_cryp);
|
||||
err_clk_cryp:
|
||||
clk_disable_unprepare(cryp->clk_ethif);
|
||||
err_clk_ethif:
|
||||
pm_runtime_put_sync(cryp->dev);
|
||||
pm_runtime_disable(cryp->dev);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int mtk_crypto_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct mtk_cryp *cryp = platform_get_drvdata(pdev);
|
||||
|
||||
mtk_hash_alg_release(cryp);
|
||||
mtk_cipher_alg_release(cryp);
|
||||
mtk_desc_dma_free(cryp);
|
||||
|
||||
clk_disable_unprepare(cryp->clk_cryp);
|
||||
clk_disable_unprepare(cryp->clk_ethif);
|
||||
|
||||
pm_runtime_put_sync(cryp->dev);
|
||||
pm_runtime_disable(cryp->dev);
|
||||
platform_set_drvdata(pdev, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id of_crypto_id[] = {
|
||||
{ .compatible = "mediatek,eip97-crypto" },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, of_crypto_id);
|
||||
|
||||
static struct platform_driver mtk_crypto_driver = {
|
||||
.probe = mtk_crypto_probe,
|
||||
.remove = mtk_crypto_remove,
|
||||
.driver = {
|
||||
.name = "mtk-crypto",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = of_crypto_id,
|
||||
},
|
||||
};
|
||||
module_platform_driver(mtk_crypto_driver);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Ryder Lee <ryder.lee@mediatek.com>");
|
||||
MODULE_DESCRIPTION("Cryptographic accelerator driver for EIP97");
|
||||
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Driver for EIP97 cryptographic accelerator.
|
||||
*
|
||||
* Copyright (c) 2016 Ryder Lee <ryder.lee@mediatek.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MTK_PLATFORM_H_
|
||||
#define __MTK_PLATFORM_H_
|
||||
|
||||
#include <crypto/algapi.h>
|
||||
#include <crypto/internal/aead.h>
|
||||
#include <crypto/internal/hash.h>
|
||||
#include <crypto/scatterwalk.h>
|
||||
#include <crypto/skcipher.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/scatterlist.h>
|
||||
#include "mtk-regs.h"
|
||||
|
||||
#define MTK_RDR_PROC_THRESH BIT(0)
|
||||
#define MTK_RDR_PROC_MODE BIT(23)
|
||||
#define MTK_CNT_RST BIT(31)
|
||||
#define MTK_IRQ_RDR0 BIT(1)
|
||||
#define MTK_IRQ_RDR1 BIT(3)
|
||||
#define MTK_IRQ_RDR2 BIT(5)
|
||||
#define MTK_IRQ_RDR3 BIT(7)
|
||||
|
||||
#define SIZE_IN_WORDS(x) ((x) >> 2)
|
||||
|
||||
/**
|
||||
* Ring 0/1 are used by AES encrypt and decrypt.
|
||||
* Ring 2/3 are used by SHA.
|
||||
*/
|
||||
enum {
|
||||
MTK_RING0,
|
||||
MTK_RING1,
|
||||
MTK_RING2,
|
||||
MTK_RING3,
|
||||
MTK_RING_MAX
|
||||
};
|
||||
|
||||
#define MTK_REC_NUM (MTK_RING_MAX / 2)
|
||||
#define MTK_IRQ_NUM 5
|
||||
|
||||
/**
|
||||
* struct mtk_desc - DMA descriptor
|
||||
* @hdr: the descriptor control header
|
||||
* @buf: DMA address of input buffer segment
|
||||
* @ct: DMA address of command token that control operation flow
|
||||
* @ct_hdr: the command token control header
|
||||
* @tag: the user-defined field
|
||||
* @tfm: DMA address of transform state
|
||||
* @bound: align descriptors offset boundary
|
||||
*
|
||||
* Structure passed to the crypto engine to describe where source
|
||||
* data needs to be fetched and how it needs to be processed.
|
||||
*/
|
||||
struct mtk_desc {
|
||||
__le32 hdr;
|
||||
__le32 buf;
|
||||
__le32 ct;
|
||||
__le32 ct_hdr;
|
||||
__le32 tag;
|
||||
__le32 tfm;
|
||||
__le32 bound[2];
|
||||
};
|
||||
|
||||
#define MTK_DESC_NUM 512
|
||||
#define MTK_DESC_OFF SIZE_IN_WORDS(sizeof(struct mtk_desc))
|
||||
#define MTK_DESC_SZ (MTK_DESC_OFF - 2)
|
||||
#define MTK_DESC_RING_SZ ((sizeof(struct mtk_desc) * MTK_DESC_NUM))
|
||||
#define MTK_DESC_CNT(x) ((MTK_DESC_OFF * (x)) << 2)
|
||||
#define MTK_DESC_LAST cpu_to_le32(BIT(22))
|
||||
#define MTK_DESC_FIRST cpu_to_le32(BIT(23))
|
||||
#define MTK_DESC_BUF_LEN(x) cpu_to_le32(x)
|
||||
#define MTK_DESC_CT_LEN(x) cpu_to_le32((x) << 24)
|
||||
|
||||
/**
|
||||
* struct mtk_ring - Descriptor ring
|
||||
* @cmd_base: pointer to command descriptor ring base
|
||||
* @cmd_next: pointer to the next command descriptor
|
||||
* @cmd_dma: DMA address of command descriptor ring
|
||||
* @res_base: pointer to result descriptor ring base
|
||||
* @res_next: pointer to the next result descriptor
|
||||
* @res_prev: pointer to the previous result descriptor
|
||||
* @res_dma: DMA address of result descriptor ring
|
||||
*
|
||||
* A descriptor ring is a circular buffer that is used to manage
|
||||
* one or more descriptors. There are two type of descriptor rings;
|
||||
* the command descriptor ring and result descriptor ring.
|
||||
*/
|
||||
struct mtk_ring {
|
||||
struct mtk_desc *cmd_base;
|
||||
struct mtk_desc *cmd_next;
|
||||
dma_addr_t cmd_dma;
|
||||
struct mtk_desc *res_base;
|
||||
struct mtk_desc *res_next;
|
||||
struct mtk_desc *res_prev;
|
||||
dma_addr_t res_dma;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mtk_aes_dma - Structure that holds sg list info
|
||||
* @sg: pointer to scatter-gather list
|
||||
* @nents: number of entries in the sg list
|
||||
* @remainder: remainder of sg list
|
||||
* @sg_len: number of entries in the sg mapped list
|
||||
*/
|
||||
struct mtk_aes_dma {
|
||||
struct scatterlist *sg;
|
||||
int nents;
|
||||
u32 remainder;
|
||||
u32 sg_len;
|
||||
};
|
||||
|
||||
struct mtk_aes_base_ctx;
|
||||
struct mtk_aes_rec;
|
||||
struct mtk_cryp;
|
||||
|
||||
typedef int (*mtk_aes_fn)(struct mtk_cryp *cryp, struct mtk_aes_rec *aes);
|
||||
|
||||
/**
|
||||
* struct mtk_aes_rec - AES operation record
|
||||
* @cryp: pointer to Cryptographic device
|
||||
* @queue: crypto request queue
|
||||
* @areq: pointer to async request
|
||||
* @done_task: the tasklet is use in AES interrupt
|
||||
* @queue_task: the tasklet is used to dequeue request
|
||||
* @ctx: pointer to current context
|
||||
* @src: the structure that holds source sg list info
|
||||
* @dst: the structure that holds destination sg list info
|
||||
* @aligned_sg: the scatter list is use to alignment
|
||||
* @real_dst: pointer to the destination sg list
|
||||
* @resume: pointer to resume function
|
||||
* @total: request buffer length
|
||||
* @buf: pointer to page buffer
|
||||
* @id: the current use of ring
|
||||
* @flags: it's describing AES operation state
|
||||
* @lock: the async queue lock
|
||||
*
|
||||
* Structure used to record AES execution state.
|
||||
*/
|
||||
struct mtk_aes_rec {
|
||||
struct mtk_cryp *cryp;
|
||||
struct crypto_queue queue;
|
||||
struct crypto_async_request *areq;
|
||||
struct tasklet_struct done_task;
|
||||
struct tasklet_struct queue_task;
|
||||
struct mtk_aes_base_ctx *ctx;
|
||||
struct mtk_aes_dma src;
|
||||
struct mtk_aes_dma dst;
|
||||
|
||||
struct scatterlist aligned_sg;
|
||||
struct scatterlist *real_dst;
|
||||
|
||||
mtk_aes_fn resume;
|
||||
|
||||
size_t total;
|
||||
void *buf;
|
||||
|
||||
u8 id;
|
||||
unsigned long flags;
|
||||
/* queue lock */
|
||||
spinlock_t lock;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mtk_sha_rec - SHA operation record
|
||||
* @cryp: pointer to Cryptographic device
|
||||
* @queue: crypto request queue
|
||||
* @req: pointer to ahash request
|
||||
* @done_task: the tasklet is use in SHA interrupt
|
||||
* @queue_task: the tasklet is used to dequeue request
|
||||
* @id: the current use of ring
|
||||
* @flags: it's describing SHA operation state
|
||||
* @lock: the async queue lock
|
||||
*
|
||||
* Structure used to record SHA execution state.
|
||||
*/
|
||||
struct mtk_sha_rec {
|
||||
struct mtk_cryp *cryp;
|
||||
struct crypto_queue queue;
|
||||
struct ahash_request *req;
|
||||
struct tasklet_struct done_task;
|
||||
struct tasklet_struct queue_task;
|
||||
|
||||
u8 id;
|
||||
unsigned long flags;
|
||||
/* queue lock */
|
||||
spinlock_t lock;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct mtk_cryp - Cryptographic device
|
||||
* @base: pointer to mapped register I/O base
|
||||
* @dev: pointer to device
|
||||
* @clk_ethif: pointer to ethif clock
|
||||
* @clk_cryp: pointer to crypto clock
|
||||
* @irq: global system and rings IRQ
|
||||
* @ring: pointer to descriptor rings
|
||||
* @aes: pointer to operation record of AES
|
||||
* @sha: pointer to operation record of SHA
|
||||
* @aes_list: device list of AES
|
||||
* @sha_list: device list of SHA
|
||||
* @rec: it's used to select SHA record for tfm
|
||||
*
|
||||
* Structure storing cryptographic device information.
|
||||
*/
|
||||
struct mtk_cryp {
|
||||
void __iomem *base;
|
||||
struct device *dev;
|
||||
struct clk *clk_ethif;
|
||||
struct clk *clk_cryp;
|
||||
int irq[MTK_IRQ_NUM];
|
||||
|
||||
struct mtk_ring *ring[MTK_RING_MAX];
|
||||
struct mtk_aes_rec *aes[MTK_REC_NUM];
|
||||
struct mtk_sha_rec *sha[MTK_REC_NUM];
|
||||
|
||||
struct list_head aes_list;
|
||||
struct list_head sha_list;
|
||||
|
||||
bool rec;
|
||||
};
|
||||
|
||||
int mtk_cipher_alg_register(struct mtk_cryp *cryp);
|
||||
void mtk_cipher_alg_release(struct mtk_cryp *cryp);
|
||||
int mtk_hash_alg_register(struct mtk_cryp *cryp);
|
||||
void mtk_hash_alg_release(struct mtk_cryp *cryp);
|
||||
|
||||
#endif /* __MTK_PLATFORM_H_ */
|
||||
194
target/linux/mediatek/files/drivers/crypto/mediatek/mtk-regs.h
Normal file
194
target/linux/mediatek/files/drivers/crypto/mediatek/mtk-regs.h
Normal file
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Support for MediaTek cryptographic accelerator.
|
||||
*
|
||||
* Copyright (c) 2016 MediaTek Inc.
|
||||
* Author: Ryder Lee <ryder.lee@mediatek.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __MTK_REGS_H__
|
||||
#define __MTK_REGS_H__
|
||||
|
||||
/* HIA, Command Descriptor Ring Manager */
|
||||
#define CDR_BASE_ADDR_LO(x) (0x0 + ((x) << 12))
|
||||
#define CDR_BASE_ADDR_HI(x) (0x4 + ((x) << 12))
|
||||
#define CDR_DATA_BASE_ADDR_LO(x) (0x8 + ((x) << 12))
|
||||
#define CDR_DATA_BASE_ADDR_HI(x) (0xC + ((x) << 12))
|
||||
#define CDR_ACD_BASE_ADDR_LO(x) (0x10 + ((x) << 12))
|
||||
#define CDR_ACD_BASE_ADDR_HI(x) (0x14 + ((x) << 12))
|
||||
#define CDR_RING_SIZE(x) (0x18 + ((x) << 12))
|
||||
#define CDR_DESC_SIZE(x) (0x1C + ((x) << 12))
|
||||
#define CDR_CFG(x) (0x20 + ((x) << 12))
|
||||
#define CDR_DMA_CFG(x) (0x24 + ((x) << 12))
|
||||
#define CDR_THRESH(x) (0x28 + ((x) << 12))
|
||||
#define CDR_PREP_COUNT(x) (0x2C + ((x) << 12))
|
||||
#define CDR_PROC_COUNT(x) (0x30 + ((x) << 12))
|
||||
#define CDR_PREP_PNTR(x) (0x34 + ((x) << 12))
|
||||
#define CDR_PROC_PNTR(x) (0x38 + ((x) << 12))
|
||||
#define CDR_STAT(x) (0x3C + ((x) << 12))
|
||||
|
||||
/* HIA, Result Descriptor Ring Manager */
|
||||
#define RDR_BASE_ADDR_LO(x) (0x800 + ((x) << 12))
|
||||
#define RDR_BASE_ADDR_HI(x) (0x804 + ((x) << 12))
|
||||
#define RDR_DATA_BASE_ADDR_LO(x) (0x808 + ((x) << 12))
|
||||
#define RDR_DATA_BASE_ADDR_HI(x) (0x80C + ((x) << 12))
|
||||
#define RDR_ACD_BASE_ADDR_LO(x) (0x810 + ((x) << 12))
|
||||
#define RDR_ACD_BASE_ADDR_HI(x) (0x814 + ((x) << 12))
|
||||
#define RDR_RING_SIZE(x) (0x818 + ((x) << 12))
|
||||
#define RDR_DESC_SIZE(x) (0x81C + ((x) << 12))
|
||||
#define RDR_CFG(x) (0x820 + ((x) << 12))
|
||||
#define RDR_DMA_CFG(x) (0x824 + ((x) << 12))
|
||||
#define RDR_THRESH(x) (0x828 + ((x) << 12))
|
||||
#define RDR_PREP_COUNT(x) (0x82C + ((x) << 12))
|
||||
#define RDR_PROC_COUNT(x) (0x830 + ((x) << 12))
|
||||
#define RDR_PREP_PNTR(x) (0x834 + ((x) << 12))
|
||||
#define RDR_PROC_PNTR(x) (0x838 + ((x) << 12))
|
||||
#define RDR_STAT(x) (0x83C + ((x) << 12))
|
||||
|
||||
/* HIA, Ring AIC */
|
||||
#define AIC_POL_CTRL(x) (0xE000 - ((x) << 12))
|
||||
#define AIC_TYPE_CTRL(x) (0xE004 - ((x) << 12))
|
||||
#define AIC_ENABLE_CTRL(x) (0xE008 - ((x) << 12))
|
||||
#define AIC_RAW_STAL(x) (0xE00C - ((x) << 12))
|
||||
#define AIC_ENABLE_SET(x) (0xE00C - ((x) << 12))
|
||||
#define AIC_ENABLED_STAT(x) (0xE010 - ((x) << 12))
|
||||
#define AIC_ACK(x) (0xE010 - ((x) << 12))
|
||||
#define AIC_ENABLE_CLR(x) (0xE014 - ((x) << 12))
|
||||
#define AIC_OPTIONS(x) (0xE018 - ((x) << 12))
|
||||
#define AIC_VERSION(x) (0xE01C - ((x) << 12))
|
||||
|
||||
/* HIA, Global AIC */
|
||||
#define AIC_G_POL_CTRL 0xF800
|
||||
#define AIC_G_TYPE_CTRL 0xF804
|
||||
#define AIC_G_ENABLE_CTRL 0xF808
|
||||
#define AIC_G_RAW_STAT 0xF80C
|
||||
#define AIC_G_ENABLE_SET 0xF80C
|
||||
#define AIC_G_ENABLED_STAT 0xF810
|
||||
#define AIC_G_ACK 0xF810
|
||||
#define AIC_G_ENABLE_CLR 0xF814
|
||||
#define AIC_G_OPTIONS 0xF818
|
||||
#define AIC_G_VERSION 0xF81C
|
||||
|
||||
/* HIA, Data Fetch Engine */
|
||||
#define DFE_CFG 0xF000
|
||||
#define DFE_PRIO_0 0xF010
|
||||
#define DFE_PRIO_1 0xF014
|
||||
#define DFE_PRIO_2 0xF018
|
||||
#define DFE_PRIO_3 0xF01C
|
||||
|
||||
/* HIA, Data Fetch Engine access monitoring for CDR */
|
||||
#define DFE_RING_REGION_LO(x) (0xF080 + ((x) << 3))
|
||||
#define DFE_RING_REGION_HI(x) (0xF084 + ((x) << 3))
|
||||
|
||||
/* HIA, Data Fetch Engine thread control and status for thread */
|
||||
#define DFE_THR_CTRL 0xF200
|
||||
#define DFE_THR_STAT 0xF204
|
||||
#define DFE_THR_DESC_CTRL 0xF208
|
||||
#define DFE_THR_DESC_DPTR_LO 0xF210
|
||||
#define DFE_THR_DESC_DPTR_HI 0xF214
|
||||
#define DFE_THR_DESC_ACDPTR_LO 0xF218
|
||||
#define DFE_THR_DESC_ACDPTR_HI 0xF21C
|
||||
|
||||
/* HIA, Data Store Engine */
|
||||
#define DSE_CFG 0xF400
|
||||
#define DSE_PRIO_0 0xF410
|
||||
#define DSE_PRIO_1 0xF414
|
||||
#define DSE_PRIO_2 0xF418
|
||||
#define DSE_PRIO_3 0xF41C
|
||||
|
||||
/* HIA, Data Store Engine access monitoring for RDR */
|
||||
#define DSE_RING_REGION_LO(x) (0xF480 + ((x) << 3))
|
||||
#define DSE_RING_REGION_HI(x) (0xF484 + ((x) << 3))
|
||||
|
||||
/* HIA, Data Store Engine thread control and status for thread */
|
||||
#define DSE_THR_CTRL 0xF600
|
||||
#define DSE_THR_STAT 0xF604
|
||||
#define DSE_THR_DESC_CTRL 0xF608
|
||||
#define DSE_THR_DESC_DPTR_LO 0xF610
|
||||
#define DSE_THR_DESC_DPTR_HI 0xF614
|
||||
#define DSE_THR_DESC_S_DPTR_LO 0xF618
|
||||
#define DSE_THR_DESC_S_DPTR_HI 0xF61C
|
||||
#define DSE_THR_ERROR_STAT 0xF620
|
||||
|
||||
/* HIA Global */
|
||||
#define HIA_MST_CTRL 0xFFF4
|
||||
#define HIA_OPTIONS 0xFFF8
|
||||
#define HIA_VERSION 0xFFFC
|
||||
|
||||
/* Processing Engine Input Side, Processing Engine */
|
||||
#define PE_IN_DBUF_THRESH 0x10000
|
||||
#define PE_IN_TBUF_THRESH 0x10100
|
||||
|
||||
/* Packet Engine Configuration / Status Registers */
|
||||
#define PE_TOKEN_CTRL_STAT 0x11000
|
||||
#define PE_FUNCTION_EN 0x11004
|
||||
#define PE_CONTEXT_CTRL 0x11008
|
||||
#define PE_INTERRUPT_CTRL_STAT 0x11010
|
||||
#define PE_CONTEXT_STAT 0x1100C
|
||||
#define PE_OUT_TRANS_CTRL_STAT 0x11018
|
||||
#define PE_OUT_BUF_CTRL 0x1101C
|
||||
|
||||
/* Packet Engine PRNG Registers */
|
||||
#define PE_PRNG_STAT 0x11040
|
||||
#define PE_PRNG_CTRL 0x11044
|
||||
#define PE_PRNG_SEED_L 0x11048
|
||||
#define PE_PRNG_SEED_H 0x1104C
|
||||
#define PE_PRNG_KEY_0_L 0x11050
|
||||
#define PE_PRNG_KEY_0_H 0x11054
|
||||
#define PE_PRNG_KEY_1_L 0x11058
|
||||
#define PE_PRNG_KEY_1_H 0x1105C
|
||||
#define PE_PRNG_RES_0 0x11060
|
||||
#define PE_PRNG_RES_1 0x11064
|
||||
#define PE_PRNG_RES_2 0x11068
|
||||
#define PE_PRNG_RES_3 0x1106C
|
||||
#define PE_PRNG_LFSR_L 0x11070
|
||||
#define PE_PRNG_LFSR_H 0x11074
|
||||
|
||||
/* Packet Engine AIC */
|
||||
#define PE_EIP96_AIC_POL_CTRL 0x113C0
|
||||
#define PE_EIP96_AIC_TYPE_CTRL 0x113C4
|
||||
#define PE_EIP96_AIC_ENABLE_CTRL 0x113C8
|
||||
#define PE_EIP96_AIC_RAW_STAT 0x113CC
|
||||
#define PE_EIP96_AIC_ENABLE_SET 0x113CC
|
||||
#define PE_EIP96_AIC_ENABLED_STAT 0x113D0
|
||||
#define PE_EIP96_AIC_ACK 0x113D0
|
||||
#define PE_EIP96_AIC_ENABLE_CLR 0x113D4
|
||||
#define PE_EIP96_AIC_OPTIONS 0x113D8
|
||||
#define PE_EIP96_AIC_VERSION 0x113DC
|
||||
|
||||
/* Packet Engine Options & Version Registers */
|
||||
#define PE_EIP96_OPTIONS 0x113F8
|
||||
#define PE_EIP96_VERSION 0x113FC
|
||||
|
||||
/* Processing Engine Output Side */
|
||||
#define PE_OUT_DBUF_THRESH 0x11C00
|
||||
#define PE_OUT_TBUF_THRESH 0x11D00
|
||||
|
||||
/* Processing Engine Local AIC */
|
||||
#define PE_AIC_POL_CTRL 0x11F00
|
||||
#define PE_AIC_TYPE_CTRL 0x11F04
|
||||
#define PE_AIC_ENABLE_CTRL 0x11F08
|
||||
#define PE_AIC_RAW_STAT 0x11F0C
|
||||
#define PE_AIC_ENABLE_SET 0x11F0C
|
||||
#define PE_AIC_ENABLED_STAT 0x11F10
|
||||
#define PE_AIC_ENABLE_CLR 0x11F14
|
||||
#define PE_AIC_OPTIONS 0x11F18
|
||||
#define PE_AIC_VERSION 0x11F1C
|
||||
|
||||
/* Processing Engine General Configuration and Version */
|
||||
#define PE_IN_FLIGHT 0x11FF0
|
||||
#define PE_OPTIONS 0x11FF8
|
||||
#define PE_VERSION 0x11FFC
|
||||
|
||||
/* EIP-97 - Global */
|
||||
#define EIP97_CLOCK_STATE 0x1FFE4
|
||||
#define EIP97_FORCE_CLOCK_ON 0x1FFE8
|
||||
#define EIP97_FORCE_CLOCK_OFF 0x1FFEC
|
||||
#define EIP97_MST_CTRL 0x1FFF4
|
||||
#define EIP97_OPTIONS 0x1FFF8
|
||||
#define EIP97_VERSION 0x1FFFC
|
||||
#endif /* __MTK_REGS_H__ */
|
||||
1358
target/linux/mediatek/files/drivers/crypto/mediatek/mtk-sha.c
Normal file
1358
target/linux/mediatek/files/drivers/crypto/mediatek/mtk-sha.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user