Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sun8i emac wip #283

Closed
wants to merge 13 commits into from
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
22 changes: 22 additions & 0 deletions Documentation/devicetree/bindings/net/allwinner,sun8i-emac.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
* Allwinner sun8i EMAC ethernet controller

Required properties:
- compatible: should be "allwinner,sun8i-h3-emac"
- reg: address and length of the register set for the device.
- interrupts: interrupt for the device
- phy: see ethernet.txt file in the same directory.
- clocks: A phandle to the reference clock for this device
- resets: TODO
- reset-names: should be "ahb";

Example:

emac: ethernet@01c0b000 {
compatible = "allwinner,sun8i-h3-emac";
reg = <0x01c0b000 0x1000>;
interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
resets = <&ahb_rst 17>;
reset-names = "ahb";
clocks = <&bus_gates 17>;
phy = <&phy0>;
};
44 changes: 44 additions & 0 deletions Documentation/devicetree/bindings/net/allwinner,sun8i-h3-ephy.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
* Allwinner H3 E(thernet) PHY

The Allwinner H3 integrates an MII ethernet PHY. As with external PHYs,
before it can be configured over the MDIO bus and used, certain hardware
features must be configured, such as the PHY address and LED polarity.
The PHY must also be powered on and brought out of reset.

This is accomplished with regulators and pull-up/downs for external PHYs.
For this internal PHY, a hardware register is programmed.

The same hardware register also contains clock and interface controls
for the MAC. This is also present in earlier SoCs, and is covered by
"allwinner,sun7i-a20-gmac-clk". The controls in the H3 are slightly
different due to the inclusion of what appears to be an RMII-MII
bridge.

Required properties:
- compatible: should be "allwinner,sun8i-h3-ephy"
- reg: address and length of the register set for the device
- clocks: A phandle to the reference clock for this device
- resets: A phandle to the reset control for this device

Ethernet PHY related properties:
- allwinner,ephy-addr: the MDIO bus address the PHY should respond to.
If this is not set, the external PHY is used, and
everything else in this section is ignored.
- allwinner,leds-active-low: LEDs are active low. Without this, LEDs are
active high.

Ethernet MAC clock related properties:
- #clock-cells: should be 0
- clock-output-names: "mac_tx"

Example:

ethernet-phy@01c00030 {
compatible = "allwinner,sun8i-h3-ephy";
reg = <0x01c00030 0x4>;
clocks = <&bus_gates 128>;
resets = <&ahb_rst 66>;
allwinner,ephy-addr = <0x1>;
#clock-cells = <0>;
clock-output-names = "mac_tx";
};
6 changes: 6 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,12 @@ S: Maintained
F: Documentation/i2c/busses/i2c-ali1563
F: drivers/i2c/busses/i2c-ali1563.c

ALLWINNER SUN8I-EMAC ETHERNET DRIVER
M: Corentin Labbe <clabbe.montjoie@gmail.com>
L: netdev@vger.kernel.org
S: Maintained
F: drivers/net/ethernet/allwinner/sun8i-emac.c

ALLWINNER SECURITY SYSTEM
M: Corentin Labbe <clabbe.montjoie@gmail.com>
L: linux-crypto@vger.kernel.org
Expand Down
1 change: 1 addition & 0 deletions arch/arm/boot/dts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ dtb-$(CONFIG_MACH_SUN8I) += \
sun8i-a33-sinlinx-sina33.dtb \
sun8i-a83t-allwinner-h8homlet-v2.dtb \
sun8i-a83t-cubietruck-plus.dtb \
sun8i-h3-orangepi-pc.dtb \
sun8i-h3-orangepi-plus.dtb
dtb-$(CONFIG_MACH_SUN9I) += \
sun9i-a80-optimus.dtb \
Expand Down
180 changes: 180 additions & 0 deletions arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/*
* Copyright (C) 2015 Chen-Yu Tsai <wens@csie.org>
*
* This file is dual-licensed: you can use it either under the terms
* of the GPL or the X11 license, at your option. Note that this dual
* licensing only applies to this file, and not this project as a
* whole.
*
* a) This file 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 file 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.
*
* Or, alternatively,
*
* b) Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

/dts-v1/;
#include "sun8i-h3.dtsi"
#include "sunxi-common-regulators.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/pinctrl/sun4i-a10.h>

/ {
model = "Xunlong Orange Pi PC";
compatible = "xunlong,orangepi-pc", "allwinner,sun8i-h3";

aliases {
serial0 = &uart0;
};

chosen {
stdout-path = "serial0:115200n8";
};

leds {
compatible = "gpio-leds";
pinctrl-names = "default";
pinctrl-0 = <&leds_opc>, <&leds_r_opc>;

pwr_led {
label = "orangepi:green:pwr";
gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>;
default-state = "on";
};

status_led {
label = "orangepi:red:status";
gpios = <&pio 0 15 GPIO_ACTIVE_HIGH>;
};
};

r_gpio_keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&sw_r_opc>;

sw4 {
label = "sw4";
linux,code = <BTN_0>;
gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>;
};
};
};

&ehci1 {
status = "okay";
};

&ehci2 {
status = "okay";
};

&ehci3 {
status = "okay";
};

&ir {
pinctrl-names = "default";
pinctrl-0 = <&ir_pins_a>;
status = "okay";
};

&mmc0 {
pinctrl-names = "default";
pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin>;
vmmc-supply = <&reg_vcc3v3>;
bus-width = <4>;
cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 */
cd-inverted;
status = "okay";
};

&ohci1 {
status = "okay";
};

&ohci2 {
status = "okay";
};

&ohci3 {
status = "okay";
};

&pio {
leds_opc: led_pins@0 {
allwinner,pins = "PA15";
allwinner,function = "gpio_out";
allwinner,drive = <SUN4I_PINCTRL_10_MA>;
allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
};
};

&r_pio {
leds_r_opc: led_pins@0 {
allwinner,pins = "PL10";
allwinner,function = "gpio_out";
allwinner,drive = <SUN4I_PINCTRL_10_MA>;
allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
};

sw_r_opc: key_pins@0 {
allwinner,pins = "PL3";
allwinner,function = "gpio_in";
allwinner,drive = <SUN4I_PINCTRL_10_MA>;
allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
};
};

&uart0 {
pinctrl-names = "default";
pinctrl-0 = <&uart0_pins_a>;
status = "okay";
};

&usbphy {
/* USB VBUS is always on */
status = "okay";
};

&ephy {
allwinner,ephy-addr = <0x1>;
};

&emac {
phy = <&phy1>;
phy-mode = "mii";
status = "okay";
phy1: ethernet-phy@1 {
reg = <0>;
};
};
35 changes: 35 additions & 0 deletions arch/arm/boot/dts/sun8i-h3-orangepi-plus.dts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@
gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>;
};
};

reg_gmac_3v3: gmac-3v3 {
compatible = "regulator-fixed";
pinctrl-names = "default";
pinctrl-0 = <&gmac_power_pin_orangepi>;
regulator-name = "gmac-3v3";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
startup-delay-us = <100000>;
enable-active-high;
gpio = <&pio 3 6 GPIO_ACTIVE_HIGH>;
};
};

&pio {
Expand All @@ -99,6 +111,13 @@
allwinner,drive = <SUN4I_PINCTRL_10_MA>;
allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
};

gmac_power_pin_orangepi: gmac_power_pin@0 {
allwinner,pins = "PD6";
allwinner,function = "gpio_out";
allwinner,drive = <SUN4I_PINCTRL_10_MA>;
allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
};
};

&r_pio {
Expand Down Expand Up @@ -132,3 +151,19 @@
pinctrl-0 = <&uart0_pins_a>;
status = "okay";
};

&ephy {
allwinner,ephy-addr = <0x0>;
};

&emac {
pinctrl-names = "default";
pinctrl-0 = <&emac_rgmii_pins>;
phy-supply = <&reg_gmac_3v3>;
phy = <&phy1>;
phy-mode = "rgmii";
status = "okay";
phy1: ethernet-phy@1 {
reg = <0>;
};
};
Loading