arm64: mvebu: Rename db-88f7040 files to armada-8k
Subsystems (5)
PATCH 1/15 arm64: mvebu: Rename db-88f7040 files to armada-8k
This moves some of the Armada DB-88F7040 board specific files to a more generic name: armada-8k. This is in preparation for the Armada-8k support which will be added soon. And since both platforms share most devices, lets also share most source files to not duplicate the code here.
---
arch/arm/mach-mvebu/Kconfig | 10 +++++-----
board/Marvell/mvebu_armada-8k/MAINTAINERS | 6 ++++++
board/Marvell/{mvebu_db-88f7040 => mvebu_armada-8k}/Makefile | 0
board/Marvell/{mvebu_db-88f7040 => mvebu_armada-8k}/board.c | 0
board/Marvell/mvebu_db-88f7040/MAINTAINERS | 6 ------
configs/mvebu_db-88f7040_defconfig | 4 +++-
include/configs/{mvebu_db-88f7040.h => mvebu_armada-8k.h} | 6 +++---
7 files changed, 17 insertions(+), 15 deletions(-)
create mode 100644 board/Marvell/mvebu_armada-8k/MAINTAINERS
rename board/Marvell/{mvebu_db-88f7040 => mvebu_armada-8k}/Makefile (100%)
rename board/Marvell/{mvebu_db-88f7040 => mvebu_armada-8k}/board.c (100%)
delete mode 100644 board/Marvell/mvebu_db-88f7040/MAINTAINERS
rename include/configs/{mvebu_db-88f7040.h => mvebu_armada-8k.h} (97%)arch/arm/mach-mvebu/Kconfig +5 -5
@@ -77,8 +77,8 @@ config TARGET_DB_88F6820_AMC bool "Support DB-88F6820-AMC" select 88F6820 -config TARGET_MVEBU_DB_88F7040 - bool "Support DB-88F7040 Armada 7040" +config TARGET_MVEBU_ARMADA_8K + bool "Support Armada 7k/8k platforms" select ARMADA_8K config TARGET_DB_MV784MP_GP
@@ -105,7 +105,7 @@ config SYS_BOARD default "db-88f6720" if TARGET_DB_88F6720 default "db-88f6820-gp" if TARGET_DB_88F6820_GP default "db-88f6820-amc" if TARGET_DB_88F6820_AMC - default "mvebu_db-88f7040" if TARGET_MVEBU_DB_88F7040 + default "mvebu_armada-8k" if TARGET_MVEBU_ARMADA_8K default "db-mv784mp-gp" if TARGET_DB_MV784MP_GP default "ds414" if TARGET_DS414 default "maxbcm" if TARGET_MAXBCM
@@ -117,7 +117,7 @@ config SYS_CONFIG_NAME default "db-88f6720" if TARGET_DB_88F6720 default "db-88f6820-gp" if TARGET_DB_88F6820_GP default "db-88f6820-amc" if TARGET_DB_88F6820_AMC - default "mvebu_db-88f7040" if TARGET_MVEBU_DB_88F7040 + default "mvebu_armada-8k" if TARGET_MVEBU_ARMADA_8K default "db-mv784mp-gp" if TARGET_DB_MV784MP_GP default "ds414" if TARGET_DS414 default "maxbcm" if TARGET_MAXBCM
@@ -129,7 +129,7 @@ config SYS_VENDOR default "Marvell" if TARGET_DB_88F6720 default "Marvell" if TARGET_DB_88F6820_GP default "Marvell" if TARGET_DB_88F6820_AMC - default "Marvell" if TARGET_MVEBU_DB_88F7040 + default "Marvell" if TARGET_MVEBU_ARMADA_8K default "solidrun" if TARGET_CLEARFOG default "Synology" if TARGET_DS414
board/Marvell/mvebu_armada-8k/MAINTAINERS new file +6 -0
@@ -0,0 +1,6 @@ +MVEBU_ARMADA_8K BOARD +M: Stefan Roese <[email protected]> +S: Maintained +F: board/Marvell/mvebu_armada-8k/ +F: include/configs/mvebu_armada-8k.h +F: configs/mvebu_db-88f7040_defconfig
board/Marvell/mvebu_armada-8k/Makefile renamed from board/Marvell/mvebu_db-88f7040/Makefile +0 -0
board/Marvell/mvebu_armada-8k/board.c renamed from board/Marvell/mvebu_db-88f7040/board.c +0 -0
board/Marvell/mvebu_db-88f7040/MAINTAINERS deleted +0 -6
@@ -1,6 +0,0 @@ -MVEBU_DB_88F7040 BOARD -M: Stefan Roese <[email protected]> -S: Maintained -F: board/Marvell/mvebu_db-88f7040/ -F: include/configs/mvebu_db-88f7040.h -F: configs/mvebu_db-88f7040_defconfig
configs/mvebu_db-88f7040_defconfig +3 -1
@@ -1,8 +1,9 @@ CONFIG_ARM=y CONFIG_ARCH_MVEBU=y CONFIG_SYS_MALLOC_F_LEN=0x2000 -CONFIG_TARGET_MVEBU_DB_88F7040=y +CONFIG_TARGET_MVEBU_ARMADA_8K=y CONFIG_DEFAULT_DEVICE_TREE="armada-7040-db" +CONFIG_SMBIOS_PRODUCT_NAME="" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set CONFIG_SYS_CONSOLE_INFO_QUIET=y
@@ -48,3 +49,4 @@ CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_STORAGE=y +CONFIG_SMBIOS_MANUFACTURER=""
include/configs/mvebu_armada-8k.h renamed from include/configs/mvebu_db-88f7040.h +3 -3
@@ -4,8 +4,8 @@* SPDX-License-Identifier: GPL-2.0+ */ -#ifndef _CONFIG_MVEBU_DB_88F7040_H -#define _CONFIG_MVEBU_DB_88F7040_H +#ifndef _CONFIG_MVEBU_ARMADA_8K_H +#define _CONFIG_MVEBU_ARMADA_8K_H/* * High Level Configuration Options (easy to change)
@@ -128,4 +128,4 @@#define CONFIG_CMD_PART #define CONFIG_PARTITION_UUIDS -#endif /* _CONFIG_MVEBU_DB_88F7040_H */ +#endif /* _CONFIG_MVEBU_ARMADA_8K_H */
Signature · 1 line
2.10.2
PATCH 2/15 arm64: mvebu: Add Armada-80x0 dts/dtsi files
Add the latest version of the DT files from the Linux kernel.
--- arch/arm/dts/armada-8020.dtsi | 56 ++++++++ arch/arm/dts/armada-8040-db.dts | 150 +++++++++++++++++++++ arch/arm/dts/armada-8040.dtsi | 56 ++++++++ arch/arm/dts/armada-cp110-slave.dtsi | 249 +++++++++++++++++++++++++++++++++++ 4 files changed, 511 insertions(+) create mode 100644 arch/arm/dts/armada-8020.dtsi create mode 100644 arch/arm/dts/armada-8040-db.dts create mode 100644 arch/arm/dts/armada-8040.dtsi create mode 100644 arch/arm/dts/armada-cp110-slave.dtsi
arch/arm/dts/armada-8020.dtsi new file +56 -0
@@ -0,0 +1,56 @@ +/* + * Copyright (C) 2016 Marvell Technology Group Ltd. + * + * This file is dual-licensed: you can use it either under the terms + * of the GPLv2 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 library 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 library 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. + */ + +/* + * Device Tree file for the Armada 8020 SoC, made of an AP806 Dual and + * two CP110. + */ + +#include "armada-ap806-dual.dtsi" +#include "armada-cp110-master.dtsi" +#include "armada-cp110-slave.dtsi" + +/ { + model = "Marvell Armada 8020"; + compatible = "marvell,armada8020", "marvell,armada-ap806-dual", + "marvell,armada-ap806"; +};
arch/arm/dts/armada-8040-db.dts new file +150 -0
150 lines not on this page · raw message
arch/arm/dts/armada-8040.dtsi new file +56 -0
56 lines not on this page · raw message
arch/arm/dts/armada-cp110-slave.dtsi new file +249 -0
249 lines not on this page · raw message
Signature · 1 line
2.10.2
PATCH 3/15 arm64: mvebu: armada-8k: Only configure xHCI power on DB-88F7040 board
In reply to Stefan RoeseThis patch uses of_machine_is_compatible() to detect the board at runtime and only configured the I2C IO expander for the xHCI power / reset on the DB-88F7040 board. As this code will be used by other Armada-7k/8k ports, its necessary to use this runtime detection here.
--- board/Marvell/mvebu_armada-8k/board.c | 146 ++++++++++++++++++---------------- 1 file changed, 78 insertions(+), 68 deletions(-)
board/Marvell/mvebu_armada-8k/board.c +78 -68
@@ -5,6 +5,7 @@*/ #include <common.h> +#include <dm.h> #include <i2c.h> #include <asm/io.h> #include <asm/arch/cpu.h>
@@ -12,6 +13,11 @@DECLARE_GLOBAL_DATA_PTR ; +/* +* Information specific to the DB-88F7040 eval board. We strive to use +* DT for such platform specfic configurations. At some point, this +* might be removed here and implemented via DT. +*/ /* IO expander I2C device */ #define I2C_IO_EXP_ADDR 0x21#define I2C_IO_CFG_REG_0 0x6
@@ -44,45 +50,47 @@ int board_xhci_config(void)int ret;u8 buf[8 ]; -/* Configure IO exander PCA9555: 7bit address 0x21 */ - ret =i2c_get_chip_for_busnum (0 ,I2C_IO_EXP_ADDR ,1 , &dev); -if (ret) { -printf ("Cannot find PCA9555: %d\n" , ret); -return 0 ; - } - -/* -* Read configuration (direction) and set VBUS pin as output -* (reset pin = output) -*/ - ret =dm_i2c_read (dev,I2C_IO_CFG_REG_0 , buf,1 ); -if (ret) { -printf ("Failed to read IO expander value via I2C\n" ); -return -EIO ; - } - buf[0 ] &= ~I2C_IO_REG_VBUS ; - buf[0 ] &= ~I2C_IO_REG_CL ; - ret =dm_i2c_write (dev,I2C_IO_CFG_REG_0 , buf,1 ); -if (ret) { -printf ("Failed to set IO expander via I2C\n" ); -return -EIO ; - } - -/* Read output value and configure it */ - ret =dm_i2c_read (dev,I2C_IO_DATA_OUT_REG_0 , buf,1 ); -if (ret) { -printf ("Failed to read IO expander value via I2C\n" ); -return -EIO ; +if (of_machine_is_compatible ("marvell,armada7040-db" )) { +/* Configure IO exander PCA9555: 7bit address 0x21 */ + ret =i2c_get_chip_for_busnum (0 ,I2C_IO_EXP_ADDR ,1 , &dev); +if (ret) { +printf ("Cannot find PCA9555: %d\n" , ret); +return 0 ; + } + +/* +* Read configuration (direction) and set VBUS pin as output +* (reset pin = output) +*/ + ret =dm_i2c_read (dev,I2C_IO_CFG_REG_0 , buf,1 ); +if (ret) { +printf ("Failed to read IO expander value via I2C\n" ); +return -EIO ; + } + buf[0 ] &= ~I2C_IO_REG_VBUS ; + buf[0 ] &= ~I2C_IO_REG_CL ; + ret =dm_i2c_write (dev,I2C_IO_CFG_REG_0 , buf,1 ); +if (ret) { +printf ("Failed to set IO expander via I2C\n" ); +return -EIO ; + } + +/* Read output value and configure it */ + ret =dm_i2c_read (dev,I2C_IO_DATA_OUT_REG_0 , buf,1 ); +if (ret) { +printf ("Failed to read IO expander value via I2C\n" ); +return -EIO ; + } + buf[0 ] &= ~I2C_IO_REG_VBUS ; + buf[0 ] |=I2C_IO_REG_CL ; + ret =dm_i2c_write (dev,I2C_IO_DATA_OUT_REG_0 , buf,1 ); +if (ret) { +printf ("Failed to set IO expander via I2C\n" ); +return -EIO ; + } + +mdelay (500 );/* required delay to let output value settle */ } - buf[0 ] &= ~I2C_IO_REG_VBUS ; - buf[0 ] |=I2C_IO_REG_CL ; - ret =dm_i2c_write (dev,I2C_IO_DATA_OUT_REG_0 , buf,1 ); -if (ret) { -printf ("Failed to set IO expander via I2C\n" ); -return -EIO ; - } - -mdelay (500 );/* required delay to let output value settle */ return 0 ; }
@@ -93,38 +101,40 @@ int board_xhci_enable(void)int ret;u8 buf[8 ]; -/* -* This function enables all USB ports simultaniously, -* it only needs to get called once -*/ -if (usb_enabled) -return 0 ; - -/* Configure IO exander PCA9555: 7bit address 0x21 */ - ret =i2c_get_chip_for_busnum (0 ,I2C_IO_EXP_ADDR ,1 , &dev); -if (ret) { -printf ("Cannot find PCA9555: %d\n" , ret); -return 0 ; - } - -/* Read VBUS output value */ - ret =dm_i2c_read (dev,I2C_IO_DATA_OUT_REG_0 , buf,1 ); -if (ret) { -printf ("Failed to read IO expander value via I2C\n" ); -return -EIO ; +if (of_machine_is_compatible ("marvell,armada7040-db" )) { +/* +* This function enables all USB ports simultaniously, +* it only needs to get called once +*/ +if (usb_enabled) +return 0 ; + +/* Configure IO exander PCA9555: 7bit address 0x21 */ + ret =i2c_get_chip_for_busnum (0 ,I2C_IO_EXP_ADDR ,1 , &dev); +if (ret) { +printf ("Cannot find PCA9555: %d\n" , ret); +return 0 ; + } + +/* Read VBUS output value */ + ret =dm_i2c_read (dev,I2C_IO_DATA_OUT_REG_0 , buf,1 ); +if (ret) { +printf ("Failed to read IO expander value via I2C\n" ); +return -EIO ; + } + +/* Enable VBUS power: Set output value of VBUS pin as enabled */ + buf[0 ] |=I2C_IO_REG_VBUS ; + ret =dm_i2c_write (dev,I2C_IO_DATA_OUT_REG_0 , buf,1 ); +if (ret) { +printf ("Failed to set IO expander via I2C\n" ); +return -EIO ; + } + +mdelay (500 );/* required delay to let output value settle */ + usb_enabled =1 ; } -/* Enable VBUS power: Set output value of VBUS pin as enabled */ - buf[0 ] |=I2C_IO_REG_VBUS ; - ret =dm_i2c_write (dev,I2C_IO_DATA_OUT_REG_0 , buf,1 ); -if (ret) { -printf ("Failed to set IO expander via I2C\n" ); -return -EIO ; - } - -mdelay (500 );/* required delay to let output value settle */ - usb_enabled =1 ; -return 0 ; }
Signature · 1 line
2.10.2
PATCH 4/15 arm64: mvebu: Add slave CP area to the memory map
In reply to Stefan RoeseTo enable access to the slave CP its memory needs to be added to the MMU memory map.
--- arch/arm/mach-mvebu/armada8k/cpu.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
arch/arm/mach-mvebu/armada8k/cpu.c +9 -1
@@ -39,7 +39,7 @@ static struct mm_region mvebu_mem_map[] = {PTE_BLOCK_NON_SHARE }, { -/* SRAM, MMIO regions - CP110 region */ +/* SRAM, MMIO regions - CP110 master region */ .phys = 0xf2000000UL, .virt = 0xf2000000UL, .size = 0x02000000UL, /* 32MiB internal registers */
@@ -47,6 +47,14 @@ static struct mm_region mvebu_mem_map[] = {PTE_BLOCK_NON_SHARE }, { +/* SRAM, MMIO regions - CP110 slave region */ + .phys = 0xf4000000UL, + .virt = 0xf4000000UL, + .size = 0x02000000UL, /* 32MiB internal registers */ + .attrs =PTE_BLOCK_MEMTYPE (MT_DEVICE_NGNRNE ) | +PTE_BLOCK_NON_SHARE + }, + {/* List terminator */ 0, }
Signature · 1 line
2.10.2
PATCH 5/15 arm64: mvebu: Add support for the DB-88F8040 Armada 8k devel board
In reply to Stefan RoeseThis patch adds the necessary files to support the Marvell Armada 8k devel board. Most board specfic files are shared with the Armada 7k boards under the name "armada-8k*". So only minimal changes are necessary to add this basic board support (except the DT files of course).
--- arch/arm/dts/Makefile | 1 + board/Marvell/mvebu_armada-8k/MAINTAINERS | 1 + configs/mvebu_db-88f8040_defconfig | 52 +++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 configs/mvebu_db-88f8040_defconfig
arch/arm/dts/Makefile +1 -0
@@ -73,6 +73,7 @@ dtb-$(CONFIG_ARCH_MVEBU) += \ armada-388-gp.dtb \ armada-385-amc.dtb \ armada-7040-db.dtb \ + armada-8040-db.dtb \ armada-xp-gp.dtb \ armada-xp-maxbcm.dtb \ armada-xp-synology-ds414.dtb \
board/Marvell/mvebu_armada-8k/MAINTAINERS +1 -0
@@ -4,3 +4,4 @@ S: Maintained F: board/Marvell/mvebu_armada-8k/ F: include/configs/mvebu_armada-8k.h F: configs/mvebu_db-88f7040_defconfig +F: configs/mvebu_db-88f8040_defconfig
configs/mvebu_db-88f8040_defconfig new file +52 -0
52 lines not on this page · raw message
Signature · 1 line
2.10.2
PATCH 6/15 arm64: mvebu: armada-cp110-master.dtsi: Rename comphy DT node names
In reply to Stefan RoeseSince the cp110 slave also has comphy DT nodes, the names need to be renamed to avoid a name clash. Lets use the common naming scheme:
"cpm_xxx" for master and "cps_xxx" for slave.
--- arch/arm/dts/armada-7040-db.dts | 6 +++--- arch/arm/dts/armada-cp110-master.dtsi | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
arch/arm/dts/armada-7040-db.dts +3 -3
@@ -152,7 +152,7 @@ status = "okay"; }; -&comphy_cp110 { +&cpm_comphy { phy0 { phy-type = <PHY_TYPE_SGMII2>; phy-speed = <PHY_SPEED_3_125G>;
@@ -184,10 +184,10 @@ }; }; -&utmi0 { +&cpm_utmi0 { status = "okay"; }; -&utmi1 { +&cpm_utmi1 { status = "okay"; };
arch/arm/dts/armada-cp110-master.dtsi +3 -3
@@ -149,7 +149,7 @@ status = "disabled"; }; - comphy_cp110: comphy at 441000 { + cpm_comphy: comphy at 441000 { compatible = "marvell,mvebu-comphy", "marvell,comphy-cp110"; reg = <0x441000 0x8>, <0x120000 0x8>;
@@ -157,7 +157,7 @@ max-lanes = <6>; }; - utmi0: utmi at 580000 { + cpm_utmi0: utmi at 580000 { compatible = "marvell,mvebu-utmi-2.6.0"; reg = <0x580000 0x1000>, /* utmi-unit */ <0x440420 0x4>, /* usb-cfg */
@@ -166,7 +166,7 @@ status = "disabled"; }; - utmi1: utmi at 581000 { + cpm_utmi1: utmi at 581000 { compatible = "marvell,mvebu-utmi-2.6.0"; reg = <0x581000 0x1000>, /* utmi-unit */ <0x440420 0x4>, /* usb-cfg */
Signature · 1 line
2.10.2
PATCH 7/15 arm64: mvebu: armada-cp110-slave.dtsi: Add COMPHY / UTMI device tree nodes
In reply to Stefan RoeseThis patch adds the COMPHY and UTMI device tree nodes to the cp110-slave dtsi file for the Armada 8K.
--- arch/arm/dts/armada-cp110-slave.dtsi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/arm/dts/armada-cp110-slave.dtsi +19 -0
@@ -44,6 +44,8 @@ * Device Tree file for Marvell Armada CP110 Slave. */ +#include <dt-bindings/comphy/comphy_data.h> + / { cp110-slave { #address-cells = <2>;
@@ -164,6 +166,23 @@ clocks = <&cps_syscon0 1 21>; status = "disabled"; }; + + cps_comphy: comphy at 441000 { + compatible = "marvell,mvebu-comphy", "marvell,comphy-cp110"; + reg = <0x441000 0x8>, + <0x120000 0x8>; + mux-bitcount = <4>; + max-lanes = <6>; + }; + + cps_utmi0: utmi at 580000 { + compatible = "marvell,mvebu-utmi-2.6.0"; + reg = <0x580000 0x1000>, /* utmi-unit */ + <0x440420 0x4>, /* usb-cfg */ + <0x440440 0x4>; /* utmi-cfg */ + utmi-port = <UTMI_PHY_TO_USB_HOST0>; + status = "disabled"; + }; }; cps_pcie0: pcie at f4600000 {
Signature · 1 line
2.10.2
PATCH 8/15 arm64: mvebu: armada-8040-db.dts: Add COMPHY configuration
In reply to Stefan RoeseThis patch adds the COMPHY device tree configuration to the DT file for the Marvell DB-88F8040 devel board.
--- arch/arm/dts/armada-8040-db.dts | 84 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+)
arch/arm/dts/armada-8040-db.dts +84 -0
@@ -148,3 +148,87 @@ &cps_usb3_1 { status = "okay"; }; + +&cpm_comphy { + /* + * Serdes Configuration: + * Lane 0: SGMII2 + * Lane 1: USB3_HOST0 + * Lane 2: KR (10G) + * Lane 3: SATA1 + * Lane 4: USB3_HOST1 + * Lane 5: PEX2x1 + */ + phy0 { + phy-type = <PHY_TYPE_SGMII2>; + phy-speed = <PHY_SPEED_3_125G>; + }; + + phy1 { + phy-type = <PHY_TYPE_USB3_HOST0>; + }; + + phy2 { + phy-type = <PHY_TYPE_KR>; + }; + + phy3 { + phy-type = <PHY_TYPE_SATA1>; + }; + + phy4 { + phy-type = <PHY_TYPE_USB3_HOST1>; + }; + + phy5 { + phy-type = <PHY_TYPE_PEX2>; + }; +}; + +&cps_comphy { + /* + * Serdes Configuration: + * Lane 0: SGMII2 + * Lane 1: USB3_HOST0 + * Lane 2: KR (10G) + * Lane 3: SATA1 + * Lane 4: Unconnected + * Lane 5: PEX2x1 + */ + phy0 { + phy-type = <PHY_TYPE_SGMII2>; + phy-speed = <PHY_SPEED_3_125G>; + }; + + phy1 { + phy-type = <PHY_TYPE_USB3_HOST0>; + }; + + phy2 { + phy-type = <PHY_TYPE_KR>; + }; + + phy3 { + phy-type = <PHY_TYPE_SATA1>; + }; + + phy4 { + phy-type = <PHY_TYPE_UNCONNECTED>; + }; + + phy5 { + phy-type = <PHY_TYPE_PEX2>; + }; +}; + +&cpm_utmi0 { + status = "okay"; +}; + +&cpm_utmi1 { + status = "okay"; +}; + +&cps_utmi0 { + status = "okay"; +};
Signature · 1 line
2.10.2
PATCH 9/15 arm64: mvebu: armada-8040-db.dts: Add I2C and SPI aliases
In reply to Stefan RoeseAdd I2C and SPI aliases to enable usage in U-Boot. Otherwise U-Boot will not be able to use the SPI NOR chip for environment storage and use "i2c dev 0" to select this I2C bus.
--- arch/arm/dts/armada-8040-db.dts | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm/dts/armada-8040-db.dts +5 -0
@@ -55,6 +55,11 @@ stdout-path = "serial0:115200n8"; }; + aliases { + i2c0 = &cpm_i2c0; + spi0 = &spi0; + }; + memory at 00000000 { device_type = "memory"; reg = <0x0 0x0 0x0 0x80000000>;
Signature · 1 line
2.10.2
PATCH 10/15 arm64: mvebu: Init COMPHY from the slave-CP on the A8k
In reply to Stefan RoeseThe Armada8k implements 2 CPs (communication processors) and the 2nd CP also is equipped with a COMPHY controller. This patch now loops over all enabled MISC devices (CP110) enabled in the DT to initialize all CPs.
--- arch/arm/mach-mvebu/arm64-common.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
arch/arm/mach-mvebu/arm64-common.c +14 -6
@@ -109,12 +109,20 @@ int arch_early_init_r(void) {struct udevice *dev;int ret; - -/* Call the comphy code via the MISC uclass driver */ - ret =uclass_get_device (UCLASS_MISC ,0 , &dev); -if (ret) { -debug ("COMPHY init failed: %d\n" , ret); -return -ENODEV ; +int i; + +/* +* Loop over all MISC uclass drivers to call the comphy code +* and init all CP110 devices enabled in the DT +*/ + i =0 ; +while (1 ) { +/* Call the comphy code via the MISC uclass driver */ + ret =uclass_get_device (UCLASS_MISC , i++, &dev); + +/* We're done, once no further CP110 device is found */ +if (ret) +break ; }/* Cause the SATA device to do its early init */
Signature · 1 line
2.10.2
PATCH 11/15 drivers/phy: marvell: Add support for the slave CP COMPHY device
In reply to Stefan RoeseWith the support for the Armada 8k, a 2nd COMPHY controller now needs to get supported from the CP110 slave controller. This patch adds support for this 2nd contoller in the COMPHY driver.
--- drivers/phy/marvell/comphy.h | 2 +- drivers/phy/marvell/comphy_core.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/phy/marvell/comphy.h +1 -1
@@ -69,7 +69,7 @@ (0x3 << DFX_DEV_GEN_PCIE_CLK_SRC_OFFSET)#define MAX_LANE_OPTIONS 10 -#define MAX_UTMI_PHY_COUNT 2 +#define MAX_UTMI_PHY_COUNT 3struct comphy_mux_options {u32 type;
drivers/phy/marvell/comphy_core.c +13 -2
@@ -112,6 +112,7 @@ static int comphy_probe(struct udevice *dev)struct comphy_map comphy_map_data[MAX_LANE_OPTIONS ];int subnode;int lane; +int last_idx =0 ;/* Save base addresses for later use */ chip_cfg->comphy_base_addr = (void *)dev_get_addr_index (dev,0 );
@@ -178,10 +179,20 @@ static int comphy_probe(struct udevice *dev)/* PHY power UP sequence */ chip_cfg->ptr_comphy_chip_init (chip_cfg, comphy_map_data);/* PHY print SerDes status */ +if (of_machine_is_compatible ("marvell,armada8040" )) +printf ("Comphy chip #%d:\n" , chip_cfg->comphy_index);comphy_print (chip_cfg, comphy_map_data); -/* Initialize dedicated PHYs (not muxed SerDes lanes) */ -comphy_dedicated_phys_init (); +/* +* Only run the dedicated PHY init code once, in the last PHY init call +*/ +if (of_machine_is_compatible ("marvell,armada8040" )) + last_idx =1 ; + +if (chip_cfg->comphy_index == last_idx) { +/* Initialize dedicated PHYs (not muxed SerDes lanes) */ +comphy_dedicated_phys_init (); + }return 0 ; }
Signature · 1 line
2.10.2
PATCH 12/15 pci: mvebu: Add PCIe driver for Armada-8K
In reply to Stefan RoeseFrom: Shadi Ammouri <[email protected]>
This patch adds a driver for the PCIe controller integrated in the Marvell Armada-8K SoC. This controller is based on the DesignWare IP core.
The original version was written by Shadi and Yehuda. I ported this driver to the latest mainline U-Boot version with DM support.
Tested on the Marvell DB-88F8040 Armada-8K eval board.
--- drivers/pci/Kconfig | 10 ++ drivers/pci/Makefile | 1 + drivers/pci/pcie_dw_mvebu.c | 415 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 426 insertions(+) create mode 100644 drivers/pci/pcie_dw_mvebu.c
drivers/pci/Kconfig +10 -0
@@ -33,6 +33,16 @@ config PCI_PNP help Enable PCI memory and I/O space resource allocation and assignment. +config PCIE_DW_MVEBU + bool "Enable Armada-8K PCIe driver (DesignWare core)" + default n + depends on DM_PCI + depends on ARMADA_8K + help + Say Y here if you want to enable PCIe controller support on + Armada-8K SoCs. The PCIe controller on Armada-8K is based on + DesignWare hardware. + config PCI_SANDBOX bool "Sandbox PCI support" depends on SANDBOX && DM_PCI
drivers/pci/Makefile +1 -0
@@ -30,5 +30,6 @@ obj-$(CONFIG_SH7780_PCI) +=pci_sh7780.o obj-$(CONFIG_PCI_TEGRA) += pci_tegra.o obj-$(CONFIG_TSI108_PCI) += tsi108_pci.o obj-$(CONFIG_WINBOND_83C553) += w83c553f.o +obj-$(CONFIG_PCIE_DW_MVEBU) += pcie_dw_mvebu.o obj-$(CONFIG_PCIE_LAYERSCAPE) += pcie_layerscape.o obj-$(CONFIG_PCI_XILINX) += pcie_xilinx.o
drivers/pci/pcie_dw_mvebu.c new file +415 -0
415 lines not on this page · raw message
Signature · 1 line
2.10.2
PATCH 12/15 pci: mvebu: Add PCIe driver for Armada-8K
Hi,
Quoted 154 lines · Stefan Roese
From: Shadi Ammouri <[email protected]>
This patch adds a driver for the PCIe controller integrated in the Marvell Armada-8K SoC. This controller is based on the DesignWare IP core.
The original version was written by Shadi and Yehuda. I ported this driver to the latest mainline U-Boot version with DM support.
Tested on the Marvell DB-88F8040 Armada-8K eval board.
Signed-off-by Shadi Ammouri <[email protected]>Signed-off-by Yehuda Yitschak <[email protected]>Signed-off-by Stefan Roese <[email protected]>Cc Simon Glass <[email protected]>Cc Nadav Haklai <[email protected]>Cc Neta Zur Hershkovits <[email protected]>Cc Kostya Porotchkin <[email protected]>Cc Omri Itach <[email protected]>Cc Igal Liberman <[email protected]>Cc Haim Boot <[email protected]>Cc Hanna Hawa <[email protected]>--- drivers/pci/Kconfig | 10 ++ drivers/pci/Makefile | 1 + drivers/pci/pcie_dw_mvebu.c | 415 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 426 insertions(+) create mode 100644 drivers/pci/pcie_dw_mvebu.cdrivers/pci/Kconfig +10
-0@@ -33,6 +33,16 @@ config PCI_PNP help Enable PCI memory and I/O space resource allocation and assignment. +config PCIE_DW_MVEBU + bool "Enable Armada-8K PCIe driver (DesignWare core)" + default n + depends on DM_PCI + depends on ARMADA_8K + help + Say Y here if you want to enable PCIe controller support on + Armada-8K SoCs. The PCIe controller on Armada-8K is based on + DesignWare hardware. + config PCI_SANDBOX bool "Sandbox PCI support" depends on SANDBOX && DM_PCIdrivers/pci/Makefile +1
-0@@ -30,5 +30,6 @@ obj-$(CONFIG_SH7780_PCI) +=pci_sh7780.o obj-$(CONFIG_PCI_TEGRA) += pci_tegra.o obj-$(CONFIG_TSI108_PCI) += tsi108_pci.o obj-$(CONFIG_WINBOND_83C553) += w83c553f.o +obj-$(CONFIG_PCIE_DW_MVEBU) += pcie_dw_mvebu.o obj-$(CONFIG_PCIE_LAYERSCAPE) += pcie_layerscape.o obj-$(CONFIG_PCI_XILINX) += pcie_xilinx.odrivers/pci/pcie_dw_mvebu.c new file +87
-0@@ -0,0 +1,415 @@ +/* +* Copyright (C) 2015 Marvell International Ltd. +* +* Copyright (C) 2016 Stefan Roese <[email protected]> +* +* Based on: +* - drivers/pci/pcie_imx.c +* - drivers/pci/pci_mvebu.c +* - drivers/pci/pcie_xilinx.c +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <pci.h> +#include <asm/io.h> + +DECLARE_GLOBAL_DATA_PTR ; + +/* PCI Config space registers */ +#define PCIE_CONFIG_BAR0 0x10 +#define PCIE_LINK_STATUS_REG 0x80 +#define PCIE_LINK_STATUS_SPEED_OFF 16 +#define PCIE_LINK_STATUS_SPEED_MASK 0xf +#define PCIE_LINK_STATUS_WIDTH_OFF 20 +#define PCIE_LINK_STATUS_WIDTH_MASK 0xf + +/* Resizable bar capability registers */ +#define RESIZABLE_BAR_CAP 0x250 +#define RESIZABLE_BAR_CTL0 0x254 +#define RESIZABLE_BAR_CTL1 0x258 + +/* iATU registers */ +#define PCIE_ATU_VIEWPORT 0x900 +#define PCIE_ATU_REGION_INBOUND (0x1 << 31) +#define PCIE_ATU_REGION_OUTBOUND (0x0 << 31) +#define PCIE_ATU_REGION_INDEX1 (0x1 << 0) +#define PCIE_ATU_REGION_INDEX0 (0x0 << 0) +#define PCIE_ATU_CR1 0x904 +#define PCIE_ATU_TYPE_MEM (0x0 << 0) +#define PCIE_ATU_TYPE_IO (0x2 << 0) +#define PCIE_ATU_TYPE_CFG0 (0x4 << 0) +#define PCIE_ATU_TYPE_CFG1 (0x5 << 0) +#define PCIE_ATU_CR2 0x908 +#define PCIE_ATU_ENABLE (0x1 << 31) +#define PCIE_ATU_BAR_MODE_ENABLE (0x1 << 30) +#define PCIE_ATU_LOWER_BASE 0x90C +#define PCIE_ATU_UPPER_BASE 0x910 +#define PCIE_ATU_LIMIT 0x914 +#define PCIE_ATU_LOWER_TARGET 0x918 +#define PCIE_ATU_BUS (x) (((x) & 0xff) << 24) +#define PCIE_ATU_DEV (x) (((x) & 0x1f) << 19) +#define PCIE_ATU_FUNC (x) (((x) & 0x7) << 16) +#define PCIE_ATU_UPPER_TARGET 0x91C + +#define PCIE_LINK_CAPABILITY 0x7C +#define PCIE_LINK_CTL_2 0xA0 +#define TARGET_LINK_SPEED_MASK 0xF +#define LINK_SPEED_GEN_1 0x1 +#define LINK_SPEED_GEN_2 0x2 +#define LINK_SPEED_GEN_3 0x3 + +#define PCIE_GEN3_RELATED 0x890 +#define GEN3_EQU_DISABLE (1 << 16) +#define GEN3_ZRXDC_NON_COMP (1 << 0) + +#define PCIE_GEN3_EQU_CTRL 0x8A8 +#define GEN3_EQU_EVAL_2MS_DISABLE (1 << 5) + +#define PCIE_ROOT_COMPLEX_MODE_MASK (0xF << 4) + +#define PCIE_LINK_UP_TIMEOUT_MS 100 + +#define PCIE_GLOBAL_CONTROL 0x8000 +#define PCIE_APP_LTSSM_EN (1 << 2) +#define PCIE_DEVICE_TYPE_OFFSET (4) +#define PCIE_DEVICE_TYPE_MASK (0xF) +#define PCIE_DEVICE_TYPE_EP (0x0)/* Endpoint */ +#define PCIE_DEVICE_TYPE_LEP (0x1)/* Legacy endpoint */ +#define PCIE_DEVICE_TYPE_RC (0x4)/* Root complex */ + +#define PCIE_GLOBAL_STATUS 0x8008 +#define PCIE_GLB_STS_RDLH_LINK_UP (1 << 1) +#define PCIE_GLB_STS_PHY_LINK_UP (1 << 9) + +#define PCIE_ARCACHE_TRC 0x8050
drivers/pci/pcie_dw_mvebu.c line 97
Quoted 10 lines
drivers/pci/pcie_dw_mvebu.c new file +10
-0+#define PCIE_AWCACHE_TRC 0x8054 +#define ARCACHE_SHAREABLE_CACHEABLE 0x3511 +#define AWCACHE_SHAREABLE_CACHEABLE 0x5311 + +#define LINK_SPEED_GEN_1 0x1 +#define LINK_SPEED_GEN_2 0x2 +#define LINK_SPEED_GEN_3 0x3 + +struct pcie_dw_mvebu { +struct pci_controller hose;
Why is this here? It should be accessible with dev_get_uclass_priv(bus).
drivers/pci/pcie_dw_mvebu.c line 98
Quoted 1 line
drivers/pci/pcie_dw_mvebu.c new file +1
-0+void *ctrl_base;
It would be nice if this were a C struct rather than offsets.
drivers/pci/pcie_dw_mvebu.c line 101
Quoted 3 lines
drivers/pci/pcie_dw_mvebu.c new file +3
-0+void *cfg_base; +fdt_size_t cfg_size; +int first_busno;
What are these two for? Needs comments.
drivers/pci/pcie_dw_mvebu.c line 107
Quoted 6 lines
drivers/pci/pcie_dw_mvebu.c new file +6
-0+}; + +static int pcie_dw_get_link_speed (void *regs_base) +{ +return ((readl (regs_base +PCIE_LINK_STATUS_REG )) >> +PCIE_LINK_STATUS_SPEED_OFF ) &PCIE_LINK_STATUS_SPEED_MASK ;
I suggest making the MASK a shifted value, so that you mask and then shift.
drivers/pci/pcie_dw_mvebu.c line 117
Quoted 10 lines
drivers/pci/pcie_dw_mvebu.c new file +10
-0+} + +static int pcie_dw_get_link_width (void *regs_base) +{ +return ((readl (regs_base +PCIE_LINK_STATUS_REG )) >> +PCIE_LINK_STATUS_WIDTH_OFF ) &PCIE_LINK_STATUS_WIDTH_MASK ; +} + +static uintptr_t set_cfg_address (struct pcie_dw_mvebu *pcie, +pci_dev_t d,int where)
Function comment? Much of this file could do with function comments.
Quoted 89 lines
drivers/pci/pcie_dw_mvebu.c new file +89
-0+{ +uintptr_t va_address; + +/* +* Region #0 is used for Outbound CFG space access. +* Direction = Outbound +* Region Index = 0 +*/ +writel (0 , pcie->ctrl_base +PCIE_ATU_VIEWPORT ); + +if (PCI_BUS (d) == (pcie->first_busno +1 )) +/* For local bus, change TLP Type field to 4. */ +writel (PCIE_ATU_TYPE_CFG0 , pcie->ctrl_base +PCIE_ATU_CR1 ); +else +/* Otherwise, change TLP Type field to 5. */ +writel (PCIE_ATU_TYPE_CFG1 , pcie->ctrl_base +PCIE_ATU_CR1 ); + +if (PCI_BUS (d) == pcie->first_busno) { +/* Accessing root port configuration space. */ + va_address = (uintptr_t )pcie->ctrl_base; + }else { +writel (d <<8 , pcie->ctrl_base +PCIE_ATU_LOWER_TARGET ); + va_address = (uintptr_t )pcie->cfg_base; + } + + va_address += (where & ~0x3 ); + +return va_address; +} + +static int pcie_dw_addr_valid (pci_dev_t d,int first_busno) +{ +if ((PCI_BUS (d) == first_busno) && (PCI_DEV (d) >0 )) +return 0 ; +if ((PCI_BUS (d) == first_busno +1 ) && (PCI_DEV (d) >0 )) +return 0 ; + +return 1 ; +} + +static int pcie_dw_mvebu_read_config (struct udevice *bus,pci_dev_t bdf, +uint offset,ulong *valuep, +enum pci_size_t size) +{ +struct pcie_dw_mvebu *pcie =dev_get_priv (bus); +uintptr_t va_address; +ulong value; + +debug ("PCIE CFG read: (b,d,f)=(%2d,%2d,%2d) " , +PCI_BUS (bdf),PCI_DEV (bdf),PCI_FUNC (bdf)); + +if (!pcie_dw_addr_valid (bdf, pcie->first_busno)) { +debug ("- out of range\n" ); + *valuep =pci_get_ff (size); +return 0 ; + } + + va_address =set_cfg_address (pcie, bdf, offset); + + value =readl (va_address); + +debug ("(addr,val)=(0x%04x, 0x%08lx)\n" , offset, value); + *valuep =pci_conv_32_to_size (value, offset, size); + +return 0 ; +} + +static int pcie_dw_mvebu_write_config (struct udevice *bus,pci_dev_t bdf, +uint offset,ulong value, +enum pci_size_t size) +{ +struct pcie_dw_mvebu *pcie =dev_get_priv (bus); +uintptr_t va_address; +ulong old; + +debug ("PCIE CFG write: (b,d,f)=(%2d,%2d,%2d) " , +PCI_BUS (bdf),PCI_DEV (bdf),PCI_FUNC (bdf)); +debug ("(addr,val)=(0x%04x, 0x%08lx)\n" , offset, value); + +if (!pcie_dw_addr_valid (bdf, pcie->first_busno)) { +debug ("- out of range\n" ); +return 0 ; + } + + va_address =set_cfg_address (pcie, bdf, offset); + + old =readl (va_address); + value =pci_conv_size_to_32 (old, value, offset, size); +writel (value, va_address);
drivers/pci/pcie_dw_mvebu.c line 216
Quoted 10 lines
drivers/pci/pcie_dw_mvebu.c new file +10
-0+ +return 0 ; +} + +static void pcie_dw_configure (void *regs_base,u32 cap_speed) +{ +u32 reg; + +/* TODO: need to read the serdes speed from the dts +and according to it configure the PCIe gen */
/*
* TODO(email): ..
* ...
*/
drivers/pci/pcie_dw_mvebu.c line 222
Quoted 6 lines
drivers/pci/pcie_dw_mvebu.c new file +6
-0+ +/* Set link to GEN 3 */ + reg =readl (regs_base +PCIE_LINK_CTL_2 ); + reg &= ~TARGET_LINK_SPEED_MASK ; + reg |= cap_speed; +writel (reg, regs_base +PCIE_LINK_CTL_2 );
clrsetbits_le32()
drivers/pci/pcie_dw_mvebu.c line 231
Quoted 9 lines
drivers/pci/pcie_dw_mvebu.c new file +9
-0+ + reg =readl (regs_base +PCIE_LINK_CAPABILITY ); + reg &= ~TARGET_LINK_SPEED_MASK ; + reg |= cap_speed; +writel (reg, regs_base +PCIE_LINK_CAPABILITY ); + + reg =readl (regs_base +PCIE_GEN3_EQU_CTRL ); + reg |=GEN3_EQU_EVAL_2MS_DISABLE ; +writel (reg, regs_base +PCIE_GEN3_EQU_CTRL );
setbits_le32()
drivers/pci/pcie_dw_mvebu.c line 234
Quoted 3 lines
drivers/pci/pcie_dw_mvebu.c new file +3
-0+} + +static int is_link_up (void *regs_base)
const void? It would be better as a struct though
drivers/pci/pcie_dw_mvebu.c line 246
Quoted 12 lines
drivers/pci/pcie_dw_mvebu.c new file +12
-0+{ +u32 mask =PCIE_GLB_STS_RDLH_LINK_UP |PCIE_GLB_STS_PHY_LINK_UP ; +u32 reg; + + reg =readl (regs_base +PCIE_GLOBAL_STATUS ); +if ((reg & mask) == mask) +return 1 ; + +return 0 ; +} + +static int wait_link_up (void *regs_base)
Better to return 0 if OK, -ETIMEDOUT if not.
drivers/pci/pcie_dw_mvebu.c line 259
Quoted 13 lines
drivers/pci/pcie_dw_mvebu.c new file +13
-0+{ +unsigned long timeout; + + timeout =get_timer (0 ) +PCIE_LINK_UP_TIMEOUT_MS ; +while (!is_link_up (regs_base)) { +if (get_timer (0 ) > timeout) +return 0 ; + }; + +return 1 ; +} + +static int pcie_dw_mvebu_pcie_link_up (void *regs_base,u32 cap_speed)
Better to return 0 if OK, -ve error if not
Quoted 11 lines
drivers/pci/pcie_dw_mvebu.c new file +11
-0+{ +u32 reg; + +if (!is_link_up (regs_base)) { +/* Disable LTSSM state machine to enable configuration */ + reg =readl (regs_base +PCIE_GLOBAL_CONTROL ); + reg &= ~(PCIE_APP_LTSSM_EN ); +writel (reg, regs_base +PCIE_GLOBAL_CONTROL ); + } + + reg =readl (regs_base +PCIE_GLOBAL_CONTROL );
drivers/pci/pcie_dw_mvebu.c line 281
Quoted 10 lines
drivers/pci/pcie_dw_mvebu.c new file +10
-0+ reg &= ~(PCIE_DEVICE_TYPE_MASK <<PCIE_DEVICE_TYPE_OFFSET ); + reg |= (PCIE_DEVICE_TYPE_RC <<PCIE_DEVICE_TYPE_OFFSET ); +writel (reg, regs_base +PCIE_GLOBAL_CONTROL ); + +/* Set the PCIe master AXI attributes */ +writel (ARCACHE_SHAREABLE_CACHEABLE , regs_base +PCIE_ARCACHE_TRC ); +writel (AWCACHE_SHAREABLE_CACHEABLE , regs_base +PCIE_AWCACHE_TRC ); + +/* DW pre link configurations */ +
(regs_base, cap_speed);
Quoted 51 lines
drivers/pci/pcie_dw_mvebu.c new file +51
-0+ +if (!is_link_up (regs_base)) { +/* Configuration done. Start LTSSM */ + reg =readl (regs_base +PCIE_GLOBAL_CONTROL ); + reg |=PCIE_APP_LTSSM_EN ; +writel (reg, regs_base +PCIE_GLOBAL_CONTROL ); + } + +/* Check that link was established */ +if (!wait_link_up (regs_base)) +return 0 ; + +/* +* Link can be established in Gen 1. still need to wait +* till MAC nagaotiation is completed +*/ +udelay (100 ); + +return 1 ; +} + +/* +* iATU region setup +*/ +static int pcie_dw_regions_setup (struct pcie_dw_mvebu *pcie) +{ +/* +* Region #0 is used for Outbound CFG space access. +* Direction = Outbound +* Region Index = 0 +*/ +writel (0 , pcie->ctrl_base +PCIE_ATU_VIEWPORT ); + +writel ((u32 )(uintptr_t )pcie->cfg_base, pcie->ctrl_base + +PCIE_ATU_LOWER_BASE ); +writel (0 , pcie->ctrl_base +PCIE_ATU_UPPER_BASE ); +writel ((u32 )(uintptr_t )pcie->cfg_base + pcie->cfg_size, + pcie->ctrl_base +PCIE_ATU_LIMIT ); + +writel (0 , pcie->ctrl_base +PCIE_ATU_LOWER_TARGET ); +writel (0 , pcie->ctrl_base +PCIE_ATU_UPPER_TARGET ); +writel (PCIE_ATU_TYPE_CFG0 , pcie->ctrl_base +PCIE_ATU_CR1 ); +writel (PCIE_ATU_ENABLE , pcie->ctrl_base +PCIE_ATU_CR2 ); + +return 0 ; +} + +static void pcie_dw_set_host_bars (void *regs_base) +{ +u32 size = gd->ram_size; +u64 max_size;
drivers/pci/pcie_dw_mvebu.c line 341
Quoted 10 lines
drivers/pci/pcie_dw_mvebu.c new file +10
-0+u32 reg; +u32 bar0; + +/* Verify the maximal BAR size */ + reg =readl (regs_base +RESIZABLE_BAR_CAP ); + max_size =1ULL << (5 + (reg + (1 <<4 ))); + +if (size > max_size) { + size = max_size; +printf ("Warning: PCIe BARs can't map all DRAM space\n" );
Isn't this an error? If so I suggest returning it.
Quoted 6 lines
drivers/pci/pcie_dw_mvebu.c new file +6
-0+ } + +/* Set the BAR base and size towards DDR */ + bar0 =CONFIG_SYS_SDRAM_BASE & ~0xf ; + bar0 |=PCI_BASE_ADDRESS_MEM_TYPE_32 ; +writel (CONFIG_SYS_SDRAM_BASE , regs_base +PCIE_CONFIG_BAR0 );
drivers/pci/pcie_dw_mvebu.c line 357
Quoted 10 lines
drivers/pci/pcie_dw_mvebu.c new file +10
-0+ + reg = ((size >>20 ) -1 ) <<12 ; +writel (size, regs_base +RESIZABLE_BAR_CTL0 ); +} + +static int pcie_dw_mvebu_probe (struct udevice *dev) +{ +struct pcie_dw_mvebu *pcie =dev_get_priv (dev); + + pcie->first_busno = dev->seq;
OK I see what that variable is now. But please comment it at the top.
Quoted 23 lines
drivers/pci/pcie_dw_mvebu.c new file +23
-0+ +/* Don't register host if link is down */ +if (!pcie_dw_mvebu_pcie_link_up (pcie->ctrl_base,LINK_SPEED_GEN_3 )) { +printf ("PCIE-%d: Link down\n" , dev->seq); +return -ENODEV ; + } + +printf ("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n" , dev->seq, +pcie_dw_get_link_speed (pcie->ctrl_base), +pcie_dw_get_link_width (pcie->ctrl_base), pcie->hose.first_busno); + +pcie_dw_regions_setup (pcie); +pcie_dw_set_host_bars (pcie->ctrl_base); + +return 0 ; +} + +static int pcie_dw_mvebu_ofdata_to_platdata (struct udevice *dev) +{ +struct pcie_dw_mvebu *pcie =dev_get_priv (dev); + + pcie->ctrl_base = (void *)dev_get_addr_index (dev,0 ); +if (IS_ERR (pcie->ctrl_base))
drivers/pci/pcie_dw_mvebu.c line 390
Quoted 10 lines
drivers/pci/pcie_dw_mvebu.c new file +10
-0+return PTR_ERR (pcie->ctrl_base); + +/* +* We need to know the size for the cfg space as well from the +* DT "reg" property. dev_get_addr_index() doesn't provide this +* size, so we need to use a different method to acquire the +* address and size here. +*/ + pcie->cfg_base = (void *)fdtdec_get_addr_size_auto_noparent ( + gd->fdt_blob, dev->of_offset,"reg" ,1 , &pcie->cfg_size, true);
This function returns FDT_ADDR_T_NONE on failure. Do we need to add a dev_get_addr_size()?
Quoted 26 lines
drivers/pci/pcie_dw_mvebu.c new file +25
-1+if (pcie->cfg_base ==NULL ) +return -ENODEV ; + +return 0 ; +} + +static const struct dm_pci_ops pcie_dw_mvebu_ops = { + .read_config = pcie_dw_mvebu_read_config, + .write_config = pcie_dw_mvebu_write_config, +}; + +static const struct udevice_id pcie_dw_mvebu_ids[] = { + { .compatible ="marvell,armada8k-pcie" }, + { } +}; + +U_BOOT_DRIVER (pcie_dw_mvebu) = { + .name ="pcie_dw_mvebu" , + .id =UCLASS_PCI , + .of_match = pcie_dw_mvebu_ids, + .ops = &pcie_dw_mvebu_ops, + .ofdata_to_platdata = pcie_dw_mvebu_ofdata_to_platdata, + .probe = pcie_dw_mvebu_probe, + .priv_auto_alloc_size =sizeof (struct pcie_dw_mvebu ), +}; --
Quoted 2 lines
2.10.2
Regards,
Simon
PATCH 12/15 pci: mvebu: Add PCIe driver for Armada-8K
Hi Simon,
Quoted 159 lines · Simon Glass
Quoted 158 lines · Stefan Roese
From: Shadi Ammouri <[email protected]>
This patch adds a driver for the PCIe controller integrated in the Marvell Armada-8K SoC. This controller is based on the DesignWare IP core.
The original version was written by Shadi and Yehuda. I ported this driver to the latest mainline U-Boot version with DM support.
Tested on the Marvell DB-88F8040 Armada-8K eval board.
Signed-off-by Shadi Ammouri <[email protected]>Signed-off-by Yehuda Yitschak <[email protected]>Signed-off-by Stefan Roese <[email protected]>Cc Simon Glass <[email protected]>Cc Nadav Haklai <[email protected]>Cc Neta Zur Hershkovits <[email protected]>Cc Kostya Porotchkin <[email protected]>Cc Omri Itach <[email protected]>Cc Igal Liberman <[email protected]>Cc Haim Boot <[email protected]>Cc Hanna Hawa <[email protected]>--- drivers/pci/Kconfig | 10 ++ drivers/pci/Makefile | 1 + drivers/pci/pcie_dw_mvebu.c | 415 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 426 insertions(+) create mode 100644 drivers/pci/pcie_dw_mvebu.cdrivers/pci/Kconfig +10
-0@@ -33,6 +33,16 @@ config PCI_PNP help Enable PCI memory and I/O space resource allocation and assignment. +config PCIE_DW_MVEBU + bool "Enable Armada-8K PCIe driver (DesignWare core)" + default n + depends on DM_PCI + depends on ARMADA_8K + help + Say Y here if you want to enable PCIe controller support on + Armada-8K SoCs. The PCIe controller on Armada-8K is based on + DesignWare hardware. + config PCI_SANDBOX bool "Sandbox PCI support" depends on SANDBOX && DM_PCIdrivers/pci/Makefile +1
-0@@ -30,5 +30,6 @@ obj-$(CONFIG_SH7780_PCI) +=pci_sh7780.o obj-$(CONFIG_PCI_TEGRA) += pci_tegra.o obj-$(CONFIG_TSI108_PCI) += tsi108_pci.o obj-$(CONFIG_WINBOND_83C553) += w83c553f.o +obj-$(CONFIG_PCIE_DW_MVEBU) += pcie_dw_mvebu.o obj-$(CONFIG_PCIE_LAYERSCAPE) += pcie_layerscape.o obj-$(CONFIG_PCI_XILINX) += pcie_xilinx.odrivers/pci/pcie_dw_mvebu.c new file +91
-0@@ -0,0 +1,415 @@ +/* +* Copyright (C) 2015 Marvell International Ltd. +* +* Copyright (C) 2016 Stefan Roese <[email protected]> +* +* Based on: +* - drivers/pci/pcie_imx.c +* - drivers/pci/pci_mvebu.c +* - drivers/pci/pcie_xilinx.c +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <dm.h> +#include <pci.h> +#include <asm/io.h> + +DECLARE_GLOBAL_DATA_PTR ; + +/* PCI Config space registers */ +#define PCIE_CONFIG_BAR0 0x10 +#define PCIE_LINK_STATUS_REG 0x80 +#define PCIE_LINK_STATUS_SPEED_OFF 16 +#define PCIE_LINK_STATUS_SPEED_MASK 0xf +#define PCIE_LINK_STATUS_WIDTH_OFF 20 +#define PCIE_LINK_STATUS_WIDTH_MASK 0xf + +/* Resizable bar capability registers */ +#define RESIZABLE_BAR_CAP 0x250 +#define RESIZABLE_BAR_CTL0 0x254 +#define RESIZABLE_BAR_CTL1 0x258 + +/* iATU registers */ +#define PCIE_ATU_VIEWPORT 0x900 +#define PCIE_ATU_REGION_INBOUND (0x1 << 31) +#define PCIE_ATU_REGION_OUTBOUND (0x0 << 31) +#define PCIE_ATU_REGION_INDEX1 (0x1 << 0) +#define PCIE_ATU_REGION_INDEX0 (0x0 << 0) +#define PCIE_ATU_CR1 0x904 +#define PCIE_ATU_TYPE_MEM (0x0 << 0) +#define PCIE_ATU_TYPE_IO (0x2 << 0) +#define PCIE_ATU_TYPE_CFG0 (0x4 << 0) +#define PCIE_ATU_TYPE_CFG1 (0x5 << 0) +#define PCIE_ATU_CR2 0x908 +#define PCIE_ATU_ENABLE (0x1 << 31) +#define PCIE_ATU_BAR_MODE_ENABLE (0x1 << 30) +#define PCIE_ATU_LOWER_BASE 0x90C +#define PCIE_ATU_UPPER_BASE 0x910 +#define PCIE_ATU_LIMIT 0x914 +#define PCIE_ATU_LOWER_TARGET 0x918 +#define PCIE_ATU_BUS (x) (((x) & 0xff) << 24) +#define PCIE_ATU_DEV (x) (((x) & 0x1f) << 19) +#define PCIE_ATU_FUNC (x) (((x) & 0x7) << 16) +#define PCIE_ATU_UPPER_TARGET 0x91C + +#define PCIE_LINK_CAPABILITY 0x7C +#define PCIE_LINK_CTL_2 0xA0 +#define TARGET_LINK_SPEED_MASK 0xF +#define LINK_SPEED_GEN_1 0x1 +#define LINK_SPEED_GEN_2 0x2 +#define LINK_SPEED_GEN_3 0x3 + +#define PCIE_GEN3_RELATED 0x890 +#define GEN3_EQU_DISABLE (1 << 16) +#define GEN3_ZRXDC_NON_COMP (1 << 0) + +#define PCIE_GEN3_EQU_CTRL 0x8A8 +#define GEN3_EQU_EVAL_2MS_DISABLE (1 << 5) + +#define PCIE_ROOT_COMPLEX_MODE_MASK (0xF << 4) + +#define PCIE_LINK_UP_TIMEOUT_MS 100 + +#define PCIE_GLOBAL_CONTROL 0x8000 +#define PCIE_APP_LTSSM_EN (1 << 2) +#define PCIE_DEVICE_TYPE_OFFSET (4) +#define PCIE_DEVICE_TYPE_MASK (0xF) +#define PCIE_DEVICE_TYPE_EP (0x0)/* Endpoint */ +#define PCIE_DEVICE_TYPE_LEP (0x1)/* Legacy endpoint */ +#define PCIE_DEVICE_TYPE_RC (0x4)/* Root complex */ + +#define PCIE_GLOBAL_STATUS 0x8008 +#define PCIE_GLB_STS_RDLH_LINK_UP (1 << 1) +#define PCIE_GLB_STS_PHY_LINK_UP (1 << 9) + +#define PCIE_ARCACHE_TRC 0x8050 +#define PCIE_AWCACHE_TRC 0x8054 +#define ARCACHE_SHAREABLE_CACHEABLE 0x3511 +#define AWCACHE_SHAREABLE_CACHEABLE 0x5311 +
Quoted 8 lines
drivers/pci/pcie_dw_mvebu.c line 97
Quoted 6 lines
drivers/pci/pcie_dw_mvebu.c new file +6
-0+#define LINK_SPEED_GEN_1 0x1 +#define LINK_SPEED_GEN_2 0x2 +#define LINK_SPEED_GEN_3 0x3 + +struct pcie_dw_mvebu { +struct pci_controller hose;Why is this here? It should be accessible with
dev_get_uclass_priv(bus).
Changed for v2.
Quoted 3 lines
drivers/pci/pcie_dw_mvebu.c line 98
Quoted 1 line
drivers/pci/pcie_dw_mvebu.c new file +1
-0+void *ctrl_base;It would be nice if this were a C struct rather than offsets.
If I'm not mistaken, we're moving away from using C structs in U-Boot as its done in Linux as well.
Quoted 5 lines
drivers/pci/pcie_dw_mvebu.c line 101
Quoted 3 lines
drivers/pci/pcie_dw_mvebu.c new file +3
-0+void *cfg_base; +fdt_size_t cfg_size; +int first_busno;What are these two for? Needs comments.
Will add in v2.
Quoted 8 lines
drivers/pci/pcie_dw_mvebu.c line 107
Quoted 6 lines
drivers/pci/pcie_dw_mvebu.c new file +6
-0+}; + +static int pcie_dw_get_link_speed (void *regs_base) +{ +return ((readl (regs_base +PCIE_LINK_STATUS_REG )) >> +PCIE_LINK_STATUS_SPEED_OFF ) &PCIE_LINK_STATUS_SPEED_MASK ;I suggest making the MASK a shifted value, so that you mask and then shift.
Yes, thats cleaner. Will change in v2.
Quoted 4 lines
Quoted 4 lines
drivers/pci/pcie_dw_mvebu.c new file +4
-0+} + +static int pcie_dw_get_link_width (void *regs_base) +{
Quoted 8 lines
drivers/pci/pcie_dw_mvebu.c line 117
Quoted 6 lines
drivers/pci/pcie_dw_mvebu.c new file +6
-0+return ((readl (regs_base +PCIE_LINK_STATUS_REG )) >> +PCIE_LINK_STATUS_WIDTH_OFF ) &PCIE_LINK_STATUS_WIDTH_MASK ; +} + +static uintptr_t set_cfg_address (struct pcie_dw_mvebu *pcie, +pci_dev_t d,int where)Function comment? Much of this file could do with function comments.
Sure. Let me see, what I can come up with in v2.
Quoted 96 lines
Quoted 96 lines
drivers/pci/pcie_dw_mvebu.c new file +96
-0+{ +uintptr_t va_address; + +/* +* Region #0 is used for Outbound CFG space access. +* Direction = Outbound +* Region Index = 0 +*/ +writel (0 , pcie->ctrl_base +PCIE_ATU_VIEWPORT ); + +if (PCI_BUS (d) == (pcie->first_busno +1 )) +/* For local bus, change TLP Type field to 4. */ +writel (PCIE_ATU_TYPE_CFG0 , pcie->ctrl_base +PCIE_ATU_CR1 ); +else +/* Otherwise, change TLP Type field to 5. */ +writel (PCIE_ATU_TYPE_CFG1 , pcie->ctrl_base +PCIE_ATU_CR1 ); + +if (PCI_BUS (d) == pcie->first_busno) { +/* Accessing root port configuration space. */ + va_address = (uintptr_t )pcie->ctrl_base; + }else { +writel (d <<8 , pcie->ctrl_base +PCIE_ATU_LOWER_TARGET ); + va_address = (uintptr_t )pcie->cfg_base; + } + + va_address += (where & ~0x3 ); + +return va_address; +} + +static int pcie_dw_addr_valid (pci_dev_t d,int first_busno) +{ +if ((PCI_BUS (d) == first_busno) && (PCI_DEV (d) >0 )) +return 0 ; +if ((PCI_BUS (d) == first_busno +1 ) && (PCI_DEV (d) >0 )) +return 0 ; + +return 1 ; +} + +static int pcie_dw_mvebu_read_config (struct udevice *bus,pci_dev_t bdf, +uint offset,ulong *valuep, +enum pci_size_t size) +{ +struct pcie_dw_mvebu *pcie =dev_get_priv (bus); +uintptr_t va_address; +ulong value; + +debug ("PCIE CFG read: (b,d,f)=(%2d,%2d,%2d) " , +PCI_BUS (bdf),PCI_DEV (bdf),PCI_FUNC (bdf)); + +if (!pcie_dw_addr_valid (bdf, pcie->first_busno)) { +debug ("- out of range\n" ); + *valuep =pci_get_ff (size); +return 0 ; + } + + va_address =set_cfg_address (pcie, bdf, offset); + + value =readl (va_address); + +debug ("(addr,val)=(0x%04x, 0x%08lx)\n" , offset, value); + *valuep =pci_conv_32_to_size (value, offset, size); + +return 0 ; +} + +static int pcie_dw_mvebu_write_config (struct udevice *bus,pci_dev_t bdf, +uint offset,ulong value, +enum pci_size_t size) +{ +struct pcie_dw_mvebu *pcie =dev_get_priv (bus); +uintptr_t va_address; +ulong old; + +debug ("PCIE CFG write: (b,d,f)=(%2d,%2d,%2d) " , +PCI_BUS (bdf),PCI_DEV (bdf),PCI_FUNC (bdf)); +debug ("(addr,val)=(0x%04x, 0x%08lx)\n" , offset, value); + +if (!pcie_dw_addr_valid (bdf, pcie->first_busno)) { +debug ("- out of range\n" ); +return 0 ; + } + + va_address =set_cfg_address (pcie, bdf, offset); + + old =readl (va_address); + value =pci_conv_size_to_32 (old, value, offset, size); +writel (value, va_address); + +return 0 ; +} + +static void pcie_dw_configure (void *regs_base,u32 cap_speed) +{ +u32 reg;
Quoted 8 lines
drivers/pci/pcie_dw_mvebu.c line 216
Quoted 3 lines
drivers/pci/pcie_dw_mvebu.c new file +3
-0+ +/* TODO: need to read the serdes speed from the dts +and according to it configure the PCIe gen */ /*
* TODO(email): ..
* ...
*/
Okay.
Quoted 8 lines
drivers/pci/pcie_dw_mvebu.c line 222
Quoted 6 lines
drivers/pci/pcie_dw_mvebu.c new file +6
-0+ +/* Set link to GEN 3 */ + reg =readl (regs_base +PCIE_LINK_CTL_2 ); + reg &= ~TARGET_LINK_SPEED_MASK ; + reg |= cap_speed; +writel (reg, regs_base +PCIE_LINK_CTL_2 );
clrsetbits_le32()
Okay.
Quoted 11 lines
drivers/pci/pcie_dw_mvebu.c line 231
Quoted 9 lines
drivers/pci/pcie_dw_mvebu.c new file +9
-0+ + reg =readl (regs_base +PCIE_LINK_CAPABILITY ); + reg &= ~TARGET_LINK_SPEED_MASK ; + reg |= cap_speed; +writel (reg, regs_base +PCIE_LINK_CAPABILITY ); + + reg =readl (regs_base +PCIE_GEN3_EQU_CTRL ); + reg |=GEN3_EQU_EVAL_2MS_DISABLE ; +writel (reg, regs_base +PCIE_GEN3_EQU_CTRL );
setbits_le32()
Okay.
Quoted 5 lines
drivers/pci/pcie_dw_mvebu.c line 234
Quoted 3 lines
drivers/pci/pcie_dw_mvebu.c new file +3
-0+} + +static int is_link_up (void *regs_base)const void? It would be better as a struct though
Again, I really think that we are moving away from the "old" U-Boot rule to use structs and are more and more going with offsets as macros - exactly what the kernel promotes.
Quoted 6 lines
Quoted 6 lines
drivers/pci/pcie_dw_mvebu.c new file +6
-0+{ +u32 mask =PCIE_GLB_STS_RDLH_LINK_UP |PCIE_GLB_STS_PHY_LINK_UP ; +u32 reg; + + reg =readl (regs_base +PCIE_GLOBAL_STATUS ); +if ((reg & mask) == mask)
Quoted 8 lines
drivers/pci/pcie_dw_mvebu.c line 246
Quoted 6 lines
drivers/pci/pcie_dw_mvebu.c new file +6
-0+return 1 ; + +return 0 ; +} + +static int wait_link_up (void *regs_base)Better to return 0 if OK,
-ETIMEDOUTif not.
The function is named "is_link_up()", so returning "1" for "true" makes the calling code clearer for my taste. I can change the function to use "bool" instead of "int" and use "false / true" as well if you prefer this.
Quoted 7 lines
Quoted 7 lines
drivers/pci/pcie_dw_mvebu.c new file +7
-0+{ +unsigned long timeout; + + timeout =get_timer (0 ) +PCIE_LINK_UP_TIMEOUT_MS ; +while (!is_link_up (regs_base)) { +if (get_timer (0 ) > timeout) +return 0 ;
Quoted 8 lines
drivers/pci/pcie_dw_mvebu.c line 259
Quoted 6 lines
drivers/pci/pcie_dw_mvebu.c new file +6
-0+ }; + +return 1 ; +} + +static int pcie_dw_mvebu_pcie_link_up (void *regs_base,u32 cap_speed)Better to return 0 if OK, -ve error if not
Changing this function to 0 / -ETIMEDOUT makes more sense in this function in contrast to the one above, IMHO. But this makes the use of these functions inconsistant.
Quoted 77 lines
Quoted 11 lines
drivers/pci/pcie_dw_mvebu.c new file +11
-0+{ +u32 reg; + +if (!is_link_up (regs_base)) { +/* Disable LTSSM state machine to enable configuration */ + reg =readl (regs_base +PCIE_GLOBAL_CONTROL ); + reg &= ~(PCIE_APP_LTSSM_EN ); +writel (reg, regs_base +PCIE_GLOBAL_CONTROL ); + } + + reg =readl (regs_base +PCIE_GLOBAL_CONTROL );drivers/pci/pcie_dw_mvebu.c line 281
Quoted 10 lines
drivers/pci/pcie_dw_mvebu.c new file +10
-0+ reg &= ~(PCIE_DEVICE_TYPE_MASK <<PCIE_DEVICE_TYPE_OFFSET ); + reg |= (PCIE_DEVICE_TYPE_RC <<PCIE_DEVICE_TYPE_OFFSET ); +writel (reg, regs_base +PCIE_GLOBAL_CONTROL ); + +/* Set the PCIe master AXI attributes */ +writel (ARCACHE_SHAREABLE_CACHEABLE , regs_base +PCIE_ARCACHE_TRC ); +writel (AWCACHE_SHAREABLE_CACHEABLE , regs_base +PCIE_AWCACHE_TRC ); + +/* DW pre link configurations */ +(
regs_base,cap_speed);Quoted 55 lines
drivers/pci/pcie_dw_mvebu.c new file +55
-0+ +if (!is_link_up (regs_base)) { +/* Configuration done. Start LTSSM */ + reg =readl (regs_base +PCIE_GLOBAL_CONTROL ); + reg |=PCIE_APP_LTSSM_EN ; +writel (reg, regs_base +PCIE_GLOBAL_CONTROL ); + } + +/* Check that link was established */ +if (!wait_link_up (regs_base)) +return 0 ; + +/* +* Link can be established in Gen 1. still need to wait +* till MAC nagaotiation is completed +*/ +udelay (100 ); + +return 1 ; +} + +/* +* iATU region setup +*/ +static int pcie_dw_regions_setup (struct pcie_dw_mvebu *pcie) +{ +/* +* Region #0 is used for Outbound CFG space access. +* Direction = Outbound +* Region Index = 0 +*/ +writel (0 , pcie->ctrl_base +PCIE_ATU_VIEWPORT ); + +writel ((u32 )(uintptr_t )pcie->cfg_base, pcie->ctrl_base + +PCIE_ATU_LOWER_BASE ); +writel (0 , pcie->ctrl_base +PCIE_ATU_UPPER_BASE ); +writel ((u32 )(uintptr_t )pcie->cfg_base + pcie->cfg_size, + pcie->ctrl_base +PCIE_ATU_LIMIT ); + +writel (0 , pcie->ctrl_base +PCIE_ATU_LOWER_TARGET ); +writel (0 , pcie->ctrl_base +PCIE_ATU_UPPER_TARGET ); +writel (PCIE_ATU_TYPE_CFG0 , pcie->ctrl_base +PCIE_ATU_CR1 ); +writel (PCIE_ATU_ENABLE , pcie->ctrl_base +PCIE_ATU_CR2 ); + +return 0 ; +} + +static void pcie_dw_set_host_bars (void *regs_base) +{ +u32 size = gd->ram_size; +u64 max_size; +u32 reg; +u32 bar0; + +/* Verify the maximal BAR size */
Quoted 8 lines
drivers/pci/pcie_dw_mvebu.c line 341
Quoted 6 lines
drivers/pci/pcie_dw_mvebu.c new file +6
-0+ reg =readl (regs_base +RESIZABLE_BAR_CAP ); + max_size =1ULL << (5 + (reg + (1 <<4 ))); + +if (size > max_size) { + size = max_size; +printf ("Warning: PCIe BARs can't map all DRAM space\n" );Isn't this an error? If so I suggest returning it.
No, its a warning as the message explains. The PCIe drivers should still be able to work correctly, AFAICTO. If later tests show that this is a problem which needs to get addresses, I'll come back and will either return with error here or add the missing fixes.
Quoted 10 lines
Quoted 10 lines
drivers/pci/pcie_dw_mvebu.c new file +10
-0+ } + +/* Set the BAR base and size towards DDR */ + bar0 =CONFIG_SYS_SDRAM_BASE & ~0xf ; + bar0 |=PCI_BASE_ADDRESS_MEM_TYPE_32 ; +writel (CONFIG_SYS_SDRAM_BASE , regs_base +PCIE_CONFIG_BAR0 ); + + reg = ((size >>20 ) -1 ) <<12 ; +writel (size, regs_base +RESIZABLE_BAR_CTL0 ); +}
Quoted 8 lines
drivers/pci/pcie_dw_mvebu.c line 357
Quoted 6 lines
drivers/pci/pcie_dw_mvebu.c new file +6
-0+ +static int pcie_dw_mvebu_probe (struct udevice *dev) +{ +struct pcie_dw_mvebu *pcie =dev_get_priv (dev); + + pcie->first_busno = dev->seq;OK I see what that variable is now. But please comment it at the top.
Will do.
Quoted 28 lines
Quoted 28 lines
drivers/pci/pcie_dw_mvebu.c new file +28
-0+ +/* Don't register host if link is down */ +if (!pcie_dw_mvebu_pcie_link_up (pcie->ctrl_base,LINK_SPEED_GEN_3 )) { +printf ("PCIE-%d: Link down\n" , dev->seq); +return -ENODEV ; + } + +printf ("PCIE-%d: Link up (Gen%d-x%d, Bus%d)\n" , dev->seq, +pcie_dw_get_link_speed (pcie->ctrl_base), +pcie_dw_get_link_width (pcie->ctrl_base), pcie->hose.first_busno); + +pcie_dw_regions_setup (pcie); +pcie_dw_set_host_bars (pcie->ctrl_base); + +return 0 ; +} + +static int pcie_dw_mvebu_ofdata_to_platdata (struct udevice *dev) +{ +struct pcie_dw_mvebu *pcie =dev_get_priv (dev); + + pcie->ctrl_base = (void *)dev_get_addr_index (dev,0 ); +if (IS_ERR (pcie->ctrl_base)) +return PTR_ERR (pcie->ctrl_base); + +/* +* We need to know the size for the cfg space as well from the +* DT "reg" property. dev_get_addr_index() doesn't provide this
Quoted 8 lines
drivers/pci/pcie_dw_mvebu.c line 390
Quoted 5 lines
drivers/pci/pcie_dw_mvebu.c new file +5
-0+* size, so we need to use a different method to acquire the +* address and size here. +*/ + pcie->cfg_base = (void *)fdtdec_get_addr_size_auto_noparent ( + gd->fdt_blob, dev->of_offset,"reg" ,1 , &pcie->cfg_size, true);This function returns
FDT_ADDR_T_NONEon failure. Do we need to add adev_get_addr_size()?
Yes, this might be better. Let me see if I can cook up a patch for such a new function.
Thanks for your review,
Stefan
PATCH v2 12/15 pci: mvebu: Add PCIe driver for Armada-8K
In reply to Stefan RoeseFrom: Shadi Ammouri <[email protected]>
This patch adds a driver for the PCIe controller integrated in the Marvell Armada-8K SoC. This controller is based on the DesignWare IP core.
The original version was written by Shadi and Yehuda. I ported this driver to the latest mainline U-Boot version with DM support.
Tested on the Marvell DB-88F8040 Armada-8K eval board.
---
v2:
- Removed host struct from private data struct
- Added comments to structs and functions
- Moved shift into the macro for PCIE_LINK_STATUS_SPEED_MASK and PCIE_LINK_STATUS_WIDTH_MASK
- Added Email addresses to ToDo statement
- Used clrsetbits_le32(9 where applicable
- Added const to register base pointer
- Used new core function dev_get_addr_size_index() to retrieve addr and size
- Added code to configure the PCIe root complex device as PCI bridge device
drivers/pci/Kconfig | 10 + drivers/pci/Makefile | 1 + drivers/pci/pcie_dw_mvebu.c | 535 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 546 insertions(+) create mode 100644 drivers/pci/pcie_dw_mvebu.c
drivers/pci/Kconfig +10 -0
@@ -33,6 +33,16 @@ config PCI_PNP help Enable PCI memory and I/O space resource allocation and assignment. +config PCIE_DW_MVEBU + bool "Enable Armada-8K PCIe driver (DesignWare core)" + default n + depends on DM_PCI + depends on ARMADA_8K + help + Say Y here if you want to enable PCIe controller support on + Armada-8K SoCs. The PCIe controller on Armada-8K is based on + DesignWare hardware. + config PCI_SANDBOX bool "Sandbox PCI support" depends on SANDBOX && DM_PCI
drivers/pci/Makefile +1 -0
@@ -30,5 +30,6 @@ obj-$(CONFIG_SH7780_PCI) +=pci_sh7780.o obj-$(CONFIG_PCI_TEGRA) += pci_tegra.o obj-$(CONFIG_TSI108_PCI) += tsi108_pci.o obj-$(CONFIG_WINBOND_83C553) += w83c553f.o +obj-$(CONFIG_PCIE_DW_MVEBU) += pcie_dw_mvebu.o obj-$(CONFIG_PCIE_LAYERSCAPE) += pcie_layerscape.o obj-$(CONFIG_PCI_XILINX) += pcie_xilinx.o
drivers/pci/pcie_dw_mvebu.c new file +535 -0
535 lines not on this page · raw message
Signature · 1 line
2.10.2
PATCH v2 12/15 pci: mvebu: Add PCIe driver for Armada-8K
Quoted 36 lines · Stefan Roese
From: Shadi Ammouri <[email protected]>
This patch adds a driver for the PCIe controller integrated in the Marvell Armada-8K SoC. This controller is based on the DesignWare IP core.
The original version was written by Shadi and Yehuda. I ported this driver to the latest mainline U-Boot version with DM support.
Tested on the Marvell DB-88F8040 Armada-8K eval board.
Signed-off-by Shadi Ammouri <[email protected]>Signed-off-by Yehuda Yitschak <[email protected]>Signed-off-by Stefan Roese <[email protected]>Cc Simon Glass <[email protected]>Cc Nadav Haklai <[email protected]>Cc Neta Zur Hershkovits <[email protected]>Cc Kostya Porotchkin <[email protected]>Cc Omri Itach <[email protected]>Cc Igal Liberman <[email protected]>Cc Haim Boot <[email protected]>Cc Hanna Hawa <[email protected]>---
v2:
- Removed host struct from private data struct
- Added comments to structs and functions
- Moved shift into the macro forPCIE_LINK_STATUS_SPEED_MASKandPCIE_LINK_STATUS_WIDTH_MASK
- Added Email addresses to ToDo statement
- Used clrsetbits_le32(9 where applicable
- Added const to register base pointer
- Used new core functiondev_get_addr_size_index()to retrieve addr and size
- Added code to configure the PCIe root complex device as PCI bridge device
Quoted 4 lines
drivers/pci/Kconfig | 10 + drivers/pci/Makefile | 1 + drivers/pci/pcie_dw_mvebu.c | 535 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 546 insertions(+)
PATCH v2 12/15 pci: mvebu: Add PCIe driver for Armada-8K
Hi Simon,
Quoted 37 lines · Simon Glass
Quoted 36 lines · Stefan Roese
From: Shadi Ammouri <[email protected]>
This patch adds a driver for the PCIe controller integrated in the Marvell Armada-8K SoC. This controller is based on the DesignWare IP core.
The original version was written by Shadi and Yehuda. I ported this driver to the latest mainline U-Boot version with DM support.
Tested on the Marvell DB-88F8040 Armada-8K eval board.
Signed-off-by Shadi Ammouri <[email protected]>Signed-off-by Yehuda Yitschak <[email protected]>Signed-off-by Stefan Roese <[email protected]>Cc Simon Glass <[email protected]>Cc Nadav Haklai <[email protected]>Cc Neta Zur Hershkovits <[email protected]>Cc Kostya Porotchkin <[email protected]>Cc Omri Itach <[email protected]>Cc Igal Liberman <[email protected]>Cc Haim Boot <[email protected]>Cc Hanna Hawa <[email protected]>---
v2:
- Removed host struct from private data struct
- Added comments to structs and functions
- Moved shift into the macro forPCIE_LINK_STATUS_SPEED_MASKandPCIE_LINK_STATUS_WIDTH_MASK
- Added Email addresses to ToDo statement
- Used clrsetbits_le32(9 where applicable
- Added const to register base pointer
- Used new core functiondev_get_addr_size_index()to retrieve addr and size
- Added code to configure the PCIe root complex device as PCI bridge device
Quoted 6 lines
Quoted 4 lines
drivers/pci/Kconfig | 10 + drivers/pci/Makefile | 1 + drivers/pci/pcie_dw_mvebu.c | 535 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 546 insertions(+)Reviewed-by Simon Glass <[email protected]>
Thanks.
I would like to integrate this PCIE driver in my next mvebu pull request, introducing the Armada 8K support. But it depends on the DM patch
"dm: core: Add dev_get_addr_size_index() to retrieve addr and size". What is your plan with this one? Will you pull this patch soon? Or should I pull it with my mvebu patch series?
Thanks,
Stefan
PATCH v2 12/15 pci: mvebu: Add PCIe driver for Armada-8K
Hi Stefan,
Quoted 53 lines · Stefan Roese
Hi Simon,
Quoted 39 lines · Simon Glass
Quoted 37 lines · Stefan Roese
From: Shadi Ammouri <[email protected]>
This patch adds a driver for the PCIe controller integrated in the Marvell Armada-8K SoC. This controller is based on the DesignWare IP core.
The original version was written by Shadi and Yehuda. I ported this driver to the latest mainline U-Boot version with DM support.
Tested on the Marvell DB-88F8040 Armada-8K eval board.
Signed-off-by Shadi Ammouri <[email protected]>Signed-off-by Yehuda Yitschak <[email protected]>Signed-off-by Stefan Roese <[email protected]>Cc Simon Glass <[email protected]>Cc Nadav Haklai <[email protected]>Cc Neta Zur Hershkovits <[email protected]>Cc Kostya Porotchkin <[email protected]>Cc Omri Itach <[email protected]>Cc Igal Liberman <[email protected]>Cc Haim Boot <[email protected]>Cc Hanna Hawa <[email protected]>---
v2:
- Removed host struct from private data struct
- Added comments to structs and functions
- Moved shift into the macro forPCIE_LINK_STATUS_SPEED_MASKandPCIE_LINK_STATUS_WIDTH_MASK
- Added Email addresses to ToDo statement
- Used clrsetbits_le32(9 where applicable
- Added const to register base pointer
- Used new core functiondev_get_addr_size_index()to retrieve addr and size
- Added code to configure the PCIe root complex device as PCI bridge deviceQuoted 8 lines
Quoted 5 lines
drivers/pci/Kconfig | 10 + drivers/pci/Makefile | 1 + drivers/pci/pcie_dw_mvebu.c | 535 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 546 insertions(+)Reviewed-by Simon Glass <[email protected]>
Quoted 8 lines
Thanks.
I would like to integrate this PCIE driver in my next mvebu pull request, introducing the Armada 8K support. But it depends on the DM patch
"dm: core: Adddev_get_addr_size_index()to retrieve addr and size". What is your plan with this one? Will you pull this patch soon? Or should I pull it with my mvebu patch series?
I did have a second set of patches including this. So I've pushed it into dm/master and sent an updated pull request.
Regards,
Simon
PATCH v2 12/15 pci: mvebu: Add PCIe driver for Armada-8K
Quoted 59 lines · Simon Glass
Quoted 50 lines · Simon Glass
Quoted 39 lines · Stefan Roese
Quoted 37 lines
From: Shadi Ammouri <[email protected]>
This patch adds a driver for the PCIe controller integrated in the Marvell Armada-8K SoC. This controller is based on the DesignWare IP core.
The original version was written by Shadi and Yehuda. I ported this driver to the latest mainline U-Boot version with DM support.
Tested on the Marvell DB-88F8040 Armada-8K eval board.
Signed-off-by Shadi Ammouri <[email protected]>Signed-off-by Yehuda Yitschak <[email protected]>Signed-off-by Stefan Roese <[email protected]>Cc Simon Glass <[email protected]>Cc Nadav Haklai <[email protected]>Cc Neta Zur Hershkovits <[email protected]>Cc Kostya Porotchkin <[email protected]>Cc Omri Itach <[email protected]>Cc Igal Liberman <[email protected]>Cc Haim Boot <[email protected]>Cc Hanna Hawa <[email protected]>---
v2:
- Removed host struct from private data struct
- Added comments to structs and functions
- Moved shift into the macro forPCIE_LINK_STATUS_SPEED_MASKandPCIE_LINK_STATUS_WIDTH_MASK
- Added Email addresses to ToDo statement
- Used clrsetbits_le32(9 where applicable
- Added const to register base pointer
- Used new core functiondev_get_addr_size_index()to retrieve addr and size
- Added code to configure the PCIe root complex device as PCI bridge deviceQuoted 8 lines
Quoted 5 lines
drivers/pci/Kconfig | 10 + drivers/pci/Makefile | 1 + drivers/pci/pcie_dw_mvebu.c | 535 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 546 insertions(+)Reviewed-by Simon Glass <[email protected]>Quoted 8 lines
Thanks.
I would like to integrate this PCIE driver in my next mvebu pull request, introducing the Armada 8K support. But it depends on the DM patch
"dm: core: Adddev_get_addr_size_index()to retrieve addr and size". What is your plan with this one? Will you pull this patch soon? Or should I pull it with my mvebu patch series?
Quoted 2 lines
I did have a second set of patches including this. So I've pushed it into dm/master and sent an updated pull request.
Thanks Simon!
PATCH 13/15 arm64: mvebu: Add regions for PCI spaces to the memory map
In reply to Stefan RoeseTo use the PCIe driver, its controller memory and the PCIe regions need to get mapped in the MMU. Otherwise these areas can't be accessed.
--- arch/arm/mach-mvebu/armada8k/cpu.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/mach-mvebu/armada8k/cpu.c +8 -0
@@ -55,6 +55,14 @@ static struct mm_region mvebu_mem_map[] = {PTE_BLOCK_NON_SHARE }, { +/* PCI regions */ + .phys = 0xf8000000UL, + .virt = 0xf8000000UL, + .size = 0x08000000UL, /* 128MiB PCI space (master & slave) */ + .attrs =PTE_BLOCK_MEMTYPE (MT_DEVICE_NGNRNE ) | +PTE_BLOCK_NON_SHARE + }, + {/* List terminator */ 0, }
Signature · 1 line
2.10.2
PATCH 14/15 arm64: mvebu: Add PCI support to DB-88F8040 board
In reply to Stefan RoeseThis patch adds PCI support to the Marvell Armada-8K devel board. Additionally the Intel E1000 ethernet driver is enabled so that network support is available on this board, even without the internal network interfaces being supported (yet).
--- configs/mvebu_db-88f8040_defconfig | 3 +++ include/configs/mvebu_armada-8k.h | 8 ++++++++ 2 files changed, 11 insertions(+)
configs/mvebu_db-88f8040_defconfig +3 -0
@@ -36,6 +36,9 @@ CONFIG_SPI_FLASH_MACRONIX=y CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y CONFIG_PHYLIB=y +CONFIG_PCI=y +CONFIG_DM_PCI=y +CONFIG_PCIE_DW_MVEBU=y CONFIG_MVEBU_COMPHY_SUPPORT=y # CONFIG_SPL_SERIAL_PRESENT is not set CONFIG_DEBUG_UART=y
include/configs/mvebu_armada-8k.h +8 -0
@@ -128,4 +128,12 @@#define CONFIG_CMD_PART #define CONFIG_PARTITION_UUIDS +/* +* PCI configuration +*/ +#ifdef CONFIG_PCIE_DW_MVEBU +#define CONFIG_E1000 +#define CONFIG_CMD_PCI +#endif +#endif /* _CONFIG_MVEBU_ARMADA_8K_H */
Signature · 1 line
2.10.2
PATCH 15/15 arm64: mvebu: Restrict memory size to a usable maximum
In reply to Stefan RoeseNot all memory is mapped in the MMU. So we need to restrict the memory size so that U-Boot does not try to access it. Also, the internal registers are located at 0xf000.0000 - 0xffff.ffff. Currently only 2GiB are mapped for system memory. This is what we pass to the U-Boot subsystem here.
--- arch/arm/mach-mvebu/arm64-common.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
arch/arm/mach-mvebu/arm64-common.c +17 -0
@@ -17,6 +17,23 @@DECLARE_GLOBAL_DATA_PTR ;/* +* Not all memory is mapped in the MMU. So we need to restrict the +* memory size so that U-Boot does not try to access it. Also, the +* internal registers are located at 0xf000.0000 - 0xffff.ffff. +* Currently only 2GiB are mapped for system memory. This is what +* we pass to the U-Boot subsystem here. +*/ +#define USABLE_RAM_SIZE 0x80000000 + +ulong board_get_usable_ram_top (ulong total_size) +{ +if (gd->ram_size >USABLE_RAM_SIZE ) +return USABLE_RAM_SIZE ; + +return gd->ram_size; +} + +/* * On ARMv8, MBus is not configured in U-Boot. To enable compilation * of the already implemented drivers, lets add a dummy version of * this function so that linking does not fail.
Signature · 1 line
2.10.2
PATCH 1/15 arm64: mvebu: Rename db-88f7040 files to armada-8k
In reply to Stefan RoeseQuoted 6 lines · Stefan Roese
This moves some of the Armada DB-88F7040 board specific files to a more generic name: armada-8k. This is in preparation for the Armada-8k support which will be added soon. And since both platforms share most devices, lets also share most source files to not duplicate the code here.
Quoted 8 lines
Signed-off-by Stefan Roese <[email protected]>Cc Nadav Haklai <[email protected]>Cc Neta Zur Hershkovits <[email protected]>Cc Kostya Porotchkin <[email protected]>Cc Omri Itach <[email protected]>Cc Igal Liberman <[email protected]>Cc Haim Boot <[email protected]>Cc Hanna Hawa <[email protected]>
The whole patchset is:
Applied to u-boot-marvell/master.
Thanks,
Stefan