Discussion:
[OpenWrt-Devel] [PATCH 0/4] ipq806x: Add ethernet support
Mathieu Olivari
2015-02-24 05:01:57 UTC
Permalink
These 4 changes add ethernet support to IPQ806x. It's using the driver
available on codeaurora.org and updates the corresponding DT information.
Same driver has also been posted to LKML:
https://lkml.org/lkml/2015/1/8/534

Its needs rework for kernel.org upstream acceptance.

Mathieu Olivari (4):
ipq806x: enable ar8xxx switch family support
ipq806x: enable GMAC support in DTS
kernel: add qca-nss-gmac as a new module
ipq806x: initialize the network on AP148

package/kernel/qca-nss-gmac/Makefile | 50 ++++++
.../ipq806x/base-files/etc/uci-defaults/network | 32 ++++
target/linux/ipq806x/config-3.18 | 3 +
.../ipq806x/patches/700-add-gmac-dts-suport.patch | 172 +++++++++++++++++++++
4 files changed, 257 insertions(+)
create mode 100644 package/kernel/qca-nss-gmac/Makefile
create mode 100755 target/linux/ipq806x/base-files/etc/uci-defaults/network
create mode 100644 target/linux/ipq806x/patches/700-add-gmac-dts-suport.patch
--
1.9.1
Mathieu Olivari
2015-02-24 05:01:58 UTC
Permalink
Signed-off-by: Mathieu Olivari <***@codeaurora.org>
---
target/linux/ipq806x/config-3.18 | 3 +++
1 file changed, 3 insertions(+)

diff --git a/target/linux/ipq806x/config-3.18 b/target/linux/ipq806x/config-3.18
index 7cda416..51f2de7 100644
--- a/target/linux/ipq806x/config-3.18
+++ b/target/linux/ipq806x/config-3.18
@@ -3,6 +3,7 @@ CONFIG_ALIGNMENT_TRAP=y
# CONFIG_APM_EMULATION is not set
CONFIG_APQ_GCC_8084=y
CONFIG_APQ_MMCC_8084=y
+CONFIG_AR8216_PHY=y
CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE=y
CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y
CONFIG_ARCH_HAS_SG_CHAIN=y
@@ -103,7 +104,9 @@ CONFIG_DTC=y
# CONFIG_DW_DMAC_PCI is not set
CONFIG_DYNAMIC_DEBUG=y
# CONFIG_EMAC_ROCKCHIP is not set
+CONFIG_ETHERNET_PACKET_MANGLE=y
CONFIG_FREEZER=y
+CONFIG_FW_LOADER_USER_HELPER=y
CONFIG_GENERIC_ALLOCATOR=y
CONFIG_GENERIC_BUG=y
CONFIG_GENERIC_CLOCKEVENTS=y
--
1.9.1
Mathieu Olivari
2015-02-24 05:02:01 UTC
Permalink
Signed-off-by: Mathieu Olivari <***@codeaurora.org>
---
.../ipq806x/base-files/etc/uci-defaults/network | 32 ++++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100755 target/linux/ipq806x/base-files/etc/uci-defaults/network

diff --git a/target/linux/ipq806x/base-files/etc/uci-defaults/network b/target/linux/ipq806x/base-files/etc/uci-defaults/network
new file mode 100755
index 0000000..34e9fe4
--- /dev/null
+++ b/target/linux/ipq806x/base-files/etc/uci-defaults/network
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Copyright (c) 2015 The Linux Foundation. All rights reserved.
+# Copyright (C) 2011 OpenWrt.org
+#
+
+[ -e /etc/config/network ] && exit 0
+
+touch /etc/config/network
+
+. /lib/functions/uci-defaults.sh
+. /lib/ipq806x.sh
+
+ucidef_set_interface_loopback
+
+board=$(ipq806x_board_name)
+
+case "$board" in
+ap148)
+ ucidef_set_interfaces_lan_wan "eth1" "eth0"
+ ucidef_add_switch "switch0" "1" "1"
+ ucidef_add_switch_vlan "switch0" "1" "6 1 2 3 4"
+ ucidef_add_switch_vlan "switch0" "2" "0 5"
+ ;;
+*)
+ echo "Unsupported hardware. Network interfaces not intialized"
+ ;;
+esac
+
+uci commit network
+
+exit 0
--
1.9.1
Mathieu Olivari
2015-02-24 05:01:59 UTC
Permalink
This adds the GMAC entries in the ipq806x dtsi file as well as in the
ap148 specific dts file.

This also adds the MDIO change as well.

Signed-off-by: Mathieu Olivari <***@codeaurora.org>
---
.../ipq806x/patches/700-add-gmac-dts-suport.patch | 172 +++++++++++++++++++++
1 file changed, 172 insertions(+)
create mode 100644 target/linux/ipq806x/patches/700-add-gmac-dts-suport.patch

diff --git a/target/linux/ipq806x/patches/700-add-gmac-dts-suport.patch b/target/linux/ipq806x/patches/700-add-gmac-dts-suport.patch
new file mode 100644
index 0000000..89ebe66
--- /dev/null
+++ b/target/linux/ipq806x/patches/700-add-gmac-dts-suport.patch
@@ -0,0 +1,172 @@
+--- a/arch/arm/boot/dts/qcom-ipq8064-ap148.dts
++++ b/arch/arm/boot/dts/qcom-ipq8064-ap148.dts
+@@ -18,8 +18,15 @@
+ bootargs = "console=ttyMSM0,115200 root=/dev/mtdblock12 rootfstype=squashfs,jffs2";
+ };
+
++ aliases {
++ mdio-gpio0 = &mdio0;
++ };
++
+ soc {
+ ***@800000 {
++ pinctrl-0 = <&mdio0_pins &rgmii2_pins>;
++ pinctrl-names = "default";
++
+ i2c4_pins: i2c4_pinmux {
+ pins = "gpio12", "gpio13";
+ function = "gsbi4";
+@@ -34,6 +41,25 @@
+ bias-none;
+ };
+ };
++
++ mdio0_pins: mdio0_pins {
++ mux {
++ pins = "gpio0", "gpio1";
++ function = "gpio";
++ drive-strength = <8>;
++ bias-disable;
++ };
++ };
++
++ rgmii2_pins: rgmii2_pins {
++ mux {
++ pins = "gpio27", "gpio28", "gpio29", "gpio30", "gpio31", "gpio32",
++ "gpio51", "gpio52", "gpio59", "gpio60", "gpio61", "gpio62" ;
++ function = "rgmii2";
++ drive-strength = <8>;
++ bias-disable;
++ };
++ };
+ };
+
+ ***@16300000 {
+@@ -72,6 +98,7 @@
+ #size-cells = <1>;
+ spi-max-frequency = <50000000>;
+ reg = <0>;
++ m25p,fast-read;
+
+ ***@0 {
+ label = "0:SBL1";
+@@ -148,5 +175,66 @@
+ ***@29000000 {
+ status = "ok";
+ };
++
++ mdio0: mdio {
++ compatible = "virtual,mdio-gpio";
++ #address-cells = <1>;
++ #size-cells = <0>;
++ gpios = <&qcom_pinmux 1 0 &qcom_pinmux 0 0>;
++
++ phy0: ethernet-***@0 {
++ device_type = "ethernet-phy";
++ reg = <0>;
++ qca,ar8327-initvals = <
++ 0x00004 0x7600000 /* PAD0_MODE */
++ 0x00008 0x1000000 /* PAD5_MODE */
++ 0x0000c 0x80 /* PAD6_MODE */
++ 0x000e4 0xaa545 /* MAC_POWER_SEL */
++ 0x000e0 0xc74164de /* SGMII_CTRL */
++ 0x0007c 0x4e /* PORT0_STATUS */
++ 0x00094 0x4e /* PORT6_STATUS */
++ >;
++ };
++
++ phy4: ethernet-***@4 {
++ device_type = "ethernet-phy";
++ reg = <4>;
++ };
++ };
++
++ nss-gmac-common {
++ reg = <0x03000000 0x0000FFFF 0x1bb00000 0x0000FFFF 0x00900000 0x00004000>;
++ reg-names = "nss_reg_base" , "qsgmii_reg_base", "clk_ctl_base";
++ };
++
++ gmac1: ***@37200000 {
++ status = "ok";
++ phy-mode = "rgmii";
++ qcom,id = <1>;
++ qcom,phy_mdio_addr = <4>;
++ qcom,poll_required = <1>;
++ qcom,rgmii_delay = <0>;
++ qcom,emulation = <0>;
++ qcom,forced_speed = <1000>;
++ qcom,forced_duplex = <1>;
++ qcom,socver = <0>;
++ local-mac-address = [000000000000];
++ mdiobus = <&mdio0>;
++ };
++
++ gmac2: ***@37400000 {
++ status = "ok";
++ phy-mode = "sgmii";
++ qcom,id = <2>;
++ qcom,phy_mdio_addr = <0>;
++ qcom,poll_required = <0>;
++ qcom,rgmii_delay = <0>;
++ qcom,emulation = <0>;
++ qcom,forced_speed = <1000>;
++ qcom,forced_duplex = <1>;
++ qcom,socver = <0>;
++ local-mac-address = [000000000000];
++ mdiobus = <&mdio0>;
++ };
+ };
+ };
+--- a/arch/arm/boot/dts/qcom-ipq8064.dtsi
++++ b/arch/arm/boot/dts/qcom-ipq8064.dtsi
+@@ -3,6 +3,7 @@
+ #include "skeleton.dtsi"
+ #include <dt-bindings/clock/qcom,gcc-ipq806x.h>
+ #include <dt-bindings/soc/qcom,gsbi.h>
++#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+ / {
+ model = "Qualcomm IPQ8064";
+@@ -279,5 +280,42 @@
+ #clock-cells = <1>;
+ #reset-cells = <1>;
+ };
++
++ nss-gmac-common {
++ reg = <0x03000000 0x0000FFFF 0x1bb00000 0x0000FFFF 0x00900000 0x00004000>;
++ reg-names = "nss_reg_base" , "qsgmii_reg_base", "clk_ctl_base";
++ };
++
++ gmac0: ***@37000000 {
++ device_type = "network";
++ compatible = "qcom,nss-gmac";
++ reg = <0x37000000 0x200000>;
++ interrupts = <GIC_SPI 220 IRQ_TYPE_LEVEL_HIGH>;
++ status = "disabled";
++ };
++
++ gmac1: ***@37200000 {
++ device_type = "network";
++ compatible = "qcom,nss-gmac";
++ reg = <0x37200000 0x200000>;
++ interrupts = <GIC_SPI 223 IRQ_TYPE_LEVEL_HIGH>;
++ status = "disabled";
++ };
++
++ gmac2: ***@37400000 {
++ device_type = "network";
++ compatible = "qcom,nss-gmac";
++ reg = <0x37400000 0x200000>;
++ interrupts = <GIC_SPI 226 IRQ_TYPE_LEVEL_HIGH>;
++ status = "disabled";
++ };
++
++ gmac3: ***@37600000 {
++ device_type = "network";
++ compatible = "qcom,nss-gmac";
++ reg = <0x37600000 0x200000>;
++ interrupts = <GIC_SPI 229 IRQ_TYPE_LEVEL_HIGH>;
++ status = "disabled";
++ };
+ };
+ };
--
1.9.1
Mathieu Olivari
2015-02-24 05:02:00 UTC
Permalink
This driver is used on IPQ806x to instanciate & drive the ethernet
interfaces.

Signed-off-by: Mathieu Olivari <***@codeaurora.org>
---
package/kernel/qca-nss-gmac/Makefile | 50 ++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 package/kernel/qca-nss-gmac/Makefile

diff --git a/package/kernel/qca-nss-gmac/Makefile b/package/kernel/qca-nss-gmac/Makefile
new file mode 100644
index 0000000..d994770
--- /dev/null
+++ b/package/kernel/qca-nss-gmac/Makefile
@@ -0,0 +1,50 @@
+#
+# Copyright (c) 2015 The Linux Foundation. All rights reserved.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=qca-nss-gmac
+PKG_VERSION:=20150210
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=git://codeaurora.org/quic/qsdk/oss/lklm/nss-gmac
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=969aab0aff40a3a5afe70d0f00e783b1c57aaea6
+
+PKG_LICENSE:=ISC
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/qca-nss-gmac
+ SECTION:=kernel
+ CATEGORY:=Kernel modules
+ SUBMENU:=Network Devices
+ DEPENDS:=@TARGET_ipq806x
+ TITLE:=Kernel driver for NSS gmac
+ FILES:=$(PKG_BUILD_DIR)/ipq806x/qca-nss-gmac.ko
+ AUTOLOAD:=$(call AutoProbe,qca-nss-gmac)
+endef
+
+define KernelPackage/qca-nss-gmac/Description
+This package contains a NSS driver for QCA chipset
+endef
+
+EXTRA_CFLAGS+= \
+ -DCONFIG_NSS_DEBUG_LEVEL=4 \
+ -I$(PKG_BUILD_DIR)/nss_hal/include \
+ -I$(PKG_BUILD_DIR)/nss_hal/$(BOARD)
+
+define Build/Compile
+ $(MAKE) -C "$(LINUX_DIR)" \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(LINUX_KARCH)" \
+ SUBDIRS="$(PKG_BUILD_DIR)" \
+ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
+ modules
+endef
+
+$(eval $(call KernelPackage,qca-nss-gmac))
--
1.9.1
Loading...