Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions Documentation/devicetree/bindings/net/spacemit,k1-emac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/net/spacemit,k1-emac.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: SpacemiT K1 Ethernet MAC

allOf:
- $ref: ethernet-controller.yaml#

maintainers:
- Vivian Wang <wangruikang@iscas.ac.cn>

properties:
compatible:
const: spacemit,k1-emac

reg:
maxItems: 1

clocks:
maxItems: 1

interrupts:
maxItems: 1

mdio-bus:
$ref: mdio.yaml#
unevaluatedProperties: false

resets:
maxItems: 1

spacemit,apmu:
$ref: /schemas/types.yaml#/definitions/phandle-array
items:
- items:
- description: phandle to syscon that controls this MAC
- description: offset of control registers
description:
A phandle to syscon with byte offset to control registers for this MAC

required:
- compatible
- reg
- clocks
- interrupts
- resets
- spacemit,apmu

unevaluatedProperties: false

examples:
- |
#include <dt-bindings/clock/spacemit,k1-syscon.h>

ethernet@cac80000 {
compatible = "spacemit,k1-emac";
reg = <0xcac80000 0x00000420>;
clocks = <&syscon_apmu CLK_EMAC0_BUS>;
interrupts = <131>;
mac-address = [ 00 00 00 00 00 00 ];
phy-handle = <&rgmii0>;
phy-mode = "rgmii-id";
pinctrl-names = "default";
pinctrl-0 = <&gmac0_cfg>;
resets = <&syscon_apmu RESET_EMAC0>;
rx-internal-delay-ps = <0>;
tx-internal-delay-ps = <0>;
spacemit,apmu = <&syscon_apmu 0x3e4>;

mdio-bus {
#address-cells = <0x1>;
#size-cells = <0x0>;

rgmii0: phy@1 {
reg = <0x1>;
};
};
};
46 changes: 46 additions & 0 deletions arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,49 @@
pinctrl-0 = <&uart0_2_cfg>;
status = "okay";
};

&eth0 {
phy-handle = <&rgmii0>;
phy-mode = "rgmii-id";
pinctrl-names = "default";
pinctrl-0 = <&gmac0_cfg>;
rx-internal-delay-ps = <0>;
tx-internal-delay-ps = <0>;
status = "okay";

mdio-bus {
#address-cells = <0x1>;
#size-cells = <0x0>;

reset-gpios = <&gpio K1_GPIO(110) GPIO_ACTIVE_LOW>;
reset-delay-us = <10000>;
reset-post-delay-us = <100000>;

rgmii0: phy@1 {
reg = <0x1>;
};
};
};

&eth1 {
phy-handle = <&rgmii1>;
phy-mode = "rgmii-id";
pinctrl-names = "default";
pinctrl-0 = <&gmac1_cfg>;
rx-internal-delay-ps = <0>;
tx-internal-delay-ps = <250>;
status = "okay";

mdio-bus {
#address-cells = <0x1>;
#size-cells = <0x0>;

reset-gpios = <&gpio K1_GPIO(115) GPIO_ACTIVE_LOW>;
reset-delay-us = <10000>;
reset-post-delay-us = <100000>;

rgmii1: phy@1 {
reg = <0x1>;
};
};
};
48 changes: 48 additions & 0 deletions arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,52 @@
drive-strength = <32>;
};
};

gmac0_cfg: gmac0-cfg {
gmac0-pins {
pinmux = <K1_PADCONF(0, 1)>, /* gmac0_rxdv */
<K1_PADCONF(1, 1)>, /* gmac0_rx_d0 */
<K1_PADCONF(2, 1)>, /* gmac0_rx_d1 */
<K1_PADCONF(3, 1)>, /* gmac0_rx_clk */
<K1_PADCONF(4, 1)>, /* gmac0_rx_d2 */
<K1_PADCONF(5, 1)>, /* gmac0_rx_d3 */
<K1_PADCONF(6, 1)>, /* gmac0_tx_d0 */
<K1_PADCONF(7, 1)>, /* gmac0_tx_d1 */
<K1_PADCONF(8, 1)>, /* gmac0_tx */
<K1_PADCONF(9, 1)>, /* gmac0_tx_d2 */
<K1_PADCONF(10, 1)>, /* gmac0_tx_d3 */
<K1_PADCONF(11, 1)>, /* gmac0_tx_en */
<K1_PADCONF(12, 1)>, /* gmac0_mdc */
<K1_PADCONF(13, 1)>, /* gmac0_mdio */
<K1_PADCONF(14, 1)>, /* gmac0_int_n */
<K1_PADCONF(45, 1)>; /* gmac0_clk_ref */

bias-pull-up = <0>;
drive-strength = <21>;
};
};

gmac1_cfg: gmac1-cfg {
gmac1-pins {
pinmux = <K1_PADCONF(29, 1)>, /* gmac1_rxdv */
<K1_PADCONF(30, 1)>, /* gmac1_rx_d0 */
<K1_PADCONF(31, 1)>, /* gmac1_rx_d1 */
<K1_PADCONF(32, 1)>, /* gmac1_rx_clk */
<K1_PADCONF(33, 1)>, /* gmac1_rx_d2 */
<K1_PADCONF(34, 1)>, /* gmac1_rx_d3 */
<K1_PADCONF(35, 1)>, /* gmac1_tx_d0 */
<K1_PADCONF(36, 1)>, /* gmac1_tx_d1 */
<K1_PADCONF(37, 1)>, /* gmac1_tx */
<K1_PADCONF(38, 1)>, /* gmac1_tx_d2 */
<K1_PADCONF(39, 1)>, /* gmac1_tx_d3 */
<K1_PADCONF(40, 1)>, /* gmac1_tx_en */
<K1_PADCONF(41, 1)>, /* gmac1_mdc */
<K1_PADCONF(42, 1)>, /* gmac1_mdio */
<K1_PADCONF(43, 1)>, /* gmac1_int_n */
<K1_PADCONF(46, 1)>; /* gmac1_clk_ref */

bias-pull-up = <0>;
drive-strength = <21>;
};
};
};
22 changes: 22 additions & 0 deletions arch/riscv/boot/dts/spacemit/k1.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -562,5 +562,27 @@
reg-io-width = <4>;
status = "reserved"; /* for TEE usage */
};

eth0: ethernet@cac80000 {
compatible = "spacemit,k1-emac";
reg = <0x0 0xcac80000 0x0 0x420>;
clocks = <&syscon_apmu CLK_EMAC0_BUS>;
interrupts = <131>;
mac-address = [ 00 00 00 00 00 00 ];
resets = <&syscon_apmu RESET_EMAC0>;
spacemit,apmu = <&syscon_apmu 0x3e4>;
status = "disabled";
};

eth1: ethernet@cac81000 {
compatible = "spacemit,k1-emac";
reg = <0x0 0xcac81000 0x0 0x420>;
clocks = <&syscon_apmu CLK_EMAC1_BUS>;
interrupts = <133>;
mac-address = [ 00 00 00 00 00 00 ];
resets = <&syscon_apmu RESET_EMAC1>;
spacemit,apmu = <&syscon_apmu 0x3ec>;
status = "disabled";
};
};
};
1 change: 1 addition & 0 deletions drivers/net/ethernet/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ source "drivers/net/ethernet/sis/Kconfig"
source "drivers/net/ethernet/sfc/Kconfig"
source "drivers/net/ethernet/smsc/Kconfig"
source "drivers/net/ethernet/socionext/Kconfig"
source "drivers/net/ethernet/spacemit/Kconfig"
source "drivers/net/ethernet/stmicro/Kconfig"
source "drivers/net/ethernet/sun/Kconfig"
source "drivers/net/ethernet/sunplus/Kconfig"
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ obj-$(CONFIG_NET_VENDOR_SOLARFLARE) += sfc/
obj-$(CONFIG_NET_VENDOR_SGI) += sgi/
obj-$(CONFIG_NET_VENDOR_SMSC) += smsc/
obj-$(CONFIG_NET_VENDOR_SOCIONEXT) += socionext/
obj-$(CONFIG_NET_VENDOR_SPACEMIT) += spacemit/
obj-$(CONFIG_NET_VENDOR_STMICRO) += stmicro/
obj-$(CONFIG_NET_VENDOR_SUN) += sun/
obj-$(CONFIG_NET_VENDOR_SUNPLUS) += sunplus/
Expand Down
29 changes: 29 additions & 0 deletions drivers/net/ethernet/spacemit/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
config NET_VENDOR_SPACEMIT
bool "SpacemiT devices"
default y
depends on ARCH_SPACEMIT || COMPILE_TEST
help
If you have a network (Ethernet) device belonging to this class,
say Y.

Note that the answer to this question does not directly affect
the kernel: saying N will just cause the configurator to skip all
the questions regarding SpacemiT devices. If you say Y, you will
be asked for your specific chipset/driver in the following questions.

if NET_VENDOR_SPACEMIT

config SPACEMIT_K1_EMAC
tristate "SpacemiT K1 Ethernet MAC driver"
depends on ARCH_SPACEMIT || COMPILE_TEST
depends on MFD_SYSCON
depends on OF
default m if ARCH_SPACEMIT
select PHYLIB
help
This driver supports the Ethernet MAC in the SpacemiT K1 SoC.

To compile this driver as a module, choose M here: the module
will be called k1_emac.

endif # NET_VENDOR_SPACEMIT
6 changes: 6 additions & 0 deletions drivers/net/ethernet/spacemit/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
#
# Makefile for the SpacemiT network device drivers.
#

obj-$(CONFIG_SPACEMIT_K1_EMAC) += k1_emac.o
Loading
Loading