mirror of
https://github.com/Ysurac/openmptcprouter.git
synced 2025-03-09 15:40:20 +00:00
Fix for BPI-R64
This commit is contained in:
parent
eab67d3811
commit
78cbf848f8
195 changed files with 116008 additions and 80 deletions
|
@ -0,0 +1,38 @@
|
|||
From 671c3bf50ae498dc12aef6c70abe5cfa066b1348 Mon Sep 17 00:00:00 2001
|
||||
From: Chuanhong Guo <gch981213@gmail.com>
|
||||
Date: Fri, 6 Mar 2020 16:50:49 +0800
|
||||
Subject: [PATCH 1/2] spi: make spi-max-frequency optional
|
||||
|
||||
We only need a spi-max-frequency when we specifically request a
|
||||
spi frequency lower than the max speed of spi host.
|
||||
This property is already documented as optional property and current
|
||||
host drivers are implemented to operate at highest speed possible
|
||||
when spi->max_speed_hz is 0.
|
||||
This patch makes spi-max-frequency an optional property so that
|
||||
we could just omit it to use max controller speed.
|
||||
|
||||
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
|
||||
Link: https://lore.kernel.org/r/20200306085052.28258-2-gch981213@gmail.com
|
||||
Signed-off-by: Mark Brown <broonie@kernel.org>
|
||||
---
|
||||
drivers/spi/spi.c | 9 ++-------
|
||||
1 file changed, 2 insertions(+), 7 deletions(-)
|
||||
|
||||
--- a/drivers/spi/spi.c
|
||||
+++ b/drivers/spi/spi.c
|
||||
@@ -1809,13 +1809,8 @@ static int of_spi_parse_dt(struct spi_co
|
||||
spi->mode |= SPI_CS_HIGH;
|
||||
|
||||
/* Device speed */
|
||||
- rc = of_property_read_u32(nc, "spi-max-frequency", &value);
|
||||
- if (rc) {
|
||||
- dev_err(&ctlr->dev,
|
||||
- "%pOF has no valid 'spi-max-frequency' property (%d)\n", nc, rc);
|
||||
- return rc;
|
||||
- }
|
||||
- spi->max_speed_hz = value;
|
||||
+ if (!of_property_read_u32(nc, "spi-max-frequency", &value))
|
||||
+ spi->max_speed_hz = value;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,761 @@
|
|||
From 881d1ee9fe81ff2be1b90809a07621be97404a57 Mon Sep 17 00:00:00 2001
|
||||
From: Chuanhong Guo <gch981213@gmail.com>
|
||||
Date: Fri, 6 Mar 2020 16:50:50 +0800
|
||||
Subject: [PATCH 2/2] spi: add support for mediatek spi-nor controller
|
||||
|
||||
This is a driver for mtk spi-nor controller using spi-mem interface.
|
||||
The same controller already has limited support provided by mtk-quadspi
|
||||
driver under spi-nor framework and this new driver is a replacement
|
||||
for the old one.
|
||||
|
||||
Comparing to the old driver, this driver has following advantages:
|
||||
1. It can handle any full-duplex spi transfer up to 6 bytes, and
|
||||
this is implemented using generic spi interface.
|
||||
2. It take account into command opcode properly. The reading routine
|
||||
in this controller can only use 0x03 or 0x0b as opcode on 1-1-1
|
||||
transfers, but old driver doesn't implement this properly. This
|
||||
driver checks supported opcode explicitly and use (1) to perform
|
||||
unmatched operations.
|
||||
3. It properly handles SFDP reading. Old driver can't read SFDP
|
||||
due to the bug mentioned in (2).
|
||||
4. It can do 1-2-2 and 1-4-4 fast reading on spi-nor. These two ops
|
||||
requires parsing SFDP, which isn't possible in old driver. And
|
||||
the old driver is only flagged to support 1-1-2 mode.
|
||||
5. It takes advantage of the DMA feature in this controller for
|
||||
long reads and supports IRQ on DMA requests to free cpu cycles
|
||||
from polling status registers on long DMA reading. It achieves
|
||||
up to 17.5MB/s reading speed (1-4-4 mode) which is way faster
|
||||
than the old one. IRQ is implemented as optional to maintain
|
||||
backward compatibility.
|
||||
|
||||
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
|
||||
Link: https://lore.kernel.org/r/20200306085052.28258-3-gch981213@gmail.com
|
||||
Signed-off-by: Mark Brown <broonie@kernel.org>
|
||||
---
|
||||
drivers/spi/Kconfig | 10 +
|
||||
drivers/spi/Makefile | 1 +
|
||||
drivers/spi/spi-mtk-nor.c | 689 ++++++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 700 insertions(+)
|
||||
create mode 100644 drivers/spi/spi-mtk-nor.c
|
||||
|
||||
--- a/drivers/spi/Kconfig
|
||||
+++ b/drivers/spi/Kconfig
|
||||
@@ -433,6 +433,16 @@ config SPI_MT7621
|
||||
help
|
||||
This selects a driver for the MediaTek MT7621 SPI Controller.
|
||||
|
||||
+config SPI_MTK_NOR
|
||||
+ tristate "MediaTek SPI NOR controller"
|
||||
+ depends on ARCH_MEDIATEK || COMPILE_TEST
|
||||
+ help
|
||||
+ This enables support for SPI NOR controller found on MediaTek
|
||||
+ ARM SoCs. This is a controller specifically for SPI-NOR flash.
|
||||
+ It can perform generic SPI transfers up to 6 bytes via generic
|
||||
+ SPI interface as well as several SPI-NOR specific instructions
|
||||
+ via SPI MEM interface.
|
||||
+
|
||||
config SPI_NPCM_FIU
|
||||
tristate "Nuvoton NPCM FLASH Interface Unit"
|
||||
depends on ARCH_NPCM || COMPILE_TEST
|
||||
--- a/drivers/spi/Makefile
|
||||
+++ b/drivers/spi/Makefile
|
||||
@@ -61,6 +61,7 @@ obj-$(CONFIG_SPI_MPC52xx_PSC) += spi-mp
|
||||
obj-$(CONFIG_SPI_MPC52xx) += spi-mpc52xx.o
|
||||
obj-$(CONFIG_SPI_MT65XX) += spi-mt65xx.o
|
||||
obj-$(CONFIG_SPI_MT7621) += spi-mt7621.o
|
||||
+obj-$(CONFIG_SPI_MTK_NOR) += spi-mtk-nor.o
|
||||
obj-$(CONFIG_SPI_MXIC) += spi-mxic.o
|
||||
obj-$(CONFIG_SPI_MXS) += spi-mxs.o
|
||||
obj-$(CONFIG_SPI_NPCM_FIU) += spi-npcm-fiu.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/spi/spi-mtk-nor.c
|
||||
@@ -0,0 +1,689 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+//
|
||||
+// Mediatek SPI NOR controller driver
|
||||
+//
|
||||
+// Copyright (C) 2020 Chuanhong Guo <gch981213@gmail.com>
|
||||
+
|
||||
+#include <linux/bits.h>
|
||||
+#include <linux/clk.h>
|
||||
+#include <linux/completion.h>
|
||||
+#include <linux/dma-mapping.h>
|
||||
+#include <linux/interrupt.h>
|
||||
+#include <linux/io.h>
|
||||
+#include <linux/iopoll.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/of_device.h>
|
||||
+#include <linux/spi/spi.h>
|
||||
+#include <linux/spi/spi-mem.h>
|
||||
+#include <linux/string.h>
|
||||
+
|
||||
+#define DRIVER_NAME "mtk-spi-nor"
|
||||
+
|
||||
+#define MTK_NOR_REG_CMD 0x00
|
||||
+#define MTK_NOR_CMD_WRITE BIT(4)
|
||||
+#define MTK_NOR_CMD_PROGRAM BIT(2)
|
||||
+#define MTK_NOR_CMD_READ BIT(0)
|
||||
+#define MTK_NOR_CMD_MASK GENMASK(5, 0)
|
||||
+
|
||||
+#define MTK_NOR_REG_PRG_CNT 0x04
|
||||
+#define MTK_NOR_REG_RDATA 0x0c
|
||||
+
|
||||
+#define MTK_NOR_REG_RADR0 0x10
|
||||
+#define MTK_NOR_REG_RADR(n) (MTK_NOR_REG_RADR0 + 4 * (n))
|
||||
+#define MTK_NOR_REG_RADR3 0xc8
|
||||
+
|
||||
+#define MTK_NOR_REG_WDATA 0x1c
|
||||
+
|
||||
+#define MTK_NOR_REG_PRGDATA0 0x20
|
||||
+#define MTK_NOR_REG_PRGDATA(n) (MTK_NOR_REG_PRGDATA0 + 4 * (n))
|
||||
+#define MTK_NOR_REG_PRGDATA_MAX 5
|
||||
+
|
||||
+#define MTK_NOR_REG_SHIFT0 0x38
|
||||
+#define MTK_NOR_REG_SHIFT(n) (MTK_NOR_REG_SHIFT0 + 4 * (n))
|
||||
+#define MTK_NOR_REG_SHIFT_MAX 9
|
||||
+
|
||||
+#define MTK_NOR_REG_CFG1 0x60
|
||||
+#define MTK_NOR_FAST_READ BIT(0)
|
||||
+
|
||||
+#define MTK_NOR_REG_CFG2 0x64
|
||||
+#define MTK_NOR_WR_CUSTOM_OP_EN BIT(4)
|
||||
+#define MTK_NOR_WR_BUF_EN BIT(0)
|
||||
+
|
||||
+#define MTK_NOR_REG_PP_DATA 0x98
|
||||
+
|
||||
+#define MTK_NOR_REG_IRQ_STAT 0xa8
|
||||
+#define MTK_NOR_REG_IRQ_EN 0xac
|
||||
+#define MTK_NOR_IRQ_DMA BIT(7)
|
||||
+#define MTK_NOR_IRQ_MASK GENMASK(7, 0)
|
||||
+
|
||||
+#define MTK_NOR_REG_CFG3 0xb4
|
||||
+#define MTK_NOR_DISABLE_WREN BIT(7)
|
||||
+#define MTK_NOR_DISABLE_SR_POLL BIT(5)
|
||||
+
|
||||
+#define MTK_NOR_REG_WP 0xc4
|
||||
+#define MTK_NOR_ENABLE_SF_CMD 0x30
|
||||
+
|
||||
+#define MTK_NOR_REG_BUSCFG 0xcc
|
||||
+#define MTK_NOR_4B_ADDR BIT(4)
|
||||
+#define MTK_NOR_QUAD_ADDR BIT(3)
|
||||
+#define MTK_NOR_QUAD_READ BIT(2)
|
||||
+#define MTK_NOR_DUAL_ADDR BIT(1)
|
||||
+#define MTK_NOR_DUAL_READ BIT(0)
|
||||
+#define MTK_NOR_BUS_MODE_MASK GENMASK(4, 0)
|
||||
+
|
||||
+#define MTK_NOR_REG_DMA_CTL 0x718
|
||||
+#define MTK_NOR_DMA_START BIT(0)
|
||||
+
|
||||
+#define MTK_NOR_REG_DMA_FADR 0x71c
|
||||
+#define MTK_NOR_REG_DMA_DADR 0x720
|
||||
+#define MTK_NOR_REG_DMA_END_DADR 0x724
|
||||
+
|
||||
+#define MTK_NOR_PRG_MAX_SIZE 6
|
||||
+// Reading DMA src/dst addresses have to be 16-byte aligned
|
||||
+#define MTK_NOR_DMA_ALIGN 16
|
||||
+#define MTK_NOR_DMA_ALIGN_MASK (MTK_NOR_DMA_ALIGN - 1)
|
||||
+// and we allocate a bounce buffer if destination address isn't aligned.
|
||||
+#define MTK_NOR_BOUNCE_BUF_SIZE PAGE_SIZE
|
||||
+
|
||||
+// Buffered page program can do one 128-byte transfer
|
||||
+#define MTK_NOR_PP_SIZE 128
|
||||
+
|
||||
+#define CLK_TO_US(sp, clkcnt) ((clkcnt) * 1000000 / sp->spi_freq)
|
||||
+
|
||||
+struct mtk_nor {
|
||||
+ struct spi_controller *ctlr;
|
||||
+ struct device *dev;
|
||||
+ void __iomem *base;
|
||||
+ u8 *buffer;
|
||||
+ struct clk *spi_clk;
|
||||
+ struct clk *ctlr_clk;
|
||||
+ unsigned int spi_freq;
|
||||
+ bool wbuf_en;
|
||||
+ bool has_irq;
|
||||
+ struct completion op_done;
|
||||
+};
|
||||
+
|
||||
+static inline void mtk_nor_rmw(struct mtk_nor *sp, u32 reg, u32 set, u32 clr)
|
||||
+{
|
||||
+ u32 val = readl(sp->base + reg);
|
||||
+
|
||||
+ val &= ~clr;
|
||||
+ val |= set;
|
||||
+ writel(val, sp->base + reg);
|
||||
+}
|
||||
+
|
||||
+static inline int mtk_nor_cmd_exec(struct mtk_nor *sp, u32 cmd, ulong clk)
|
||||
+{
|
||||
+ ulong delay = CLK_TO_US(sp, clk);
|
||||
+ u32 reg;
|
||||
+ int ret;
|
||||
+
|
||||
+ writel(cmd, sp->base + MTK_NOR_REG_CMD);
|
||||
+ ret = readl_poll_timeout(sp->base + MTK_NOR_REG_CMD, reg, !(reg & cmd),
|
||||
+ delay / 3, (delay + 1) * 200);
|
||||
+ if (ret < 0)
|
||||
+ dev_err(sp->dev, "command %u timeout.\n", cmd);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void mtk_nor_set_addr(struct mtk_nor *sp, const struct spi_mem_op *op)
|
||||
+{
|
||||
+ u32 addr = op->addr.val;
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < 3; i++) {
|
||||
+ writeb(addr & 0xff, sp->base + MTK_NOR_REG_RADR(i));
|
||||
+ addr >>= 8;
|
||||
+ }
|
||||
+ if (op->addr.nbytes == 4) {
|
||||
+ writeb(addr & 0xff, sp->base + MTK_NOR_REG_RADR3);
|
||||
+ mtk_nor_rmw(sp, MTK_NOR_REG_BUSCFG, MTK_NOR_4B_ADDR, 0);
|
||||
+ } else {
|
||||
+ mtk_nor_rmw(sp, MTK_NOR_REG_BUSCFG, 0, MTK_NOR_4B_ADDR);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static bool mtk_nor_match_read(const struct spi_mem_op *op)
|
||||
+{
|
||||
+ int dummy = 0;
|
||||
+
|
||||
+ if (op->dummy.buswidth)
|
||||
+ dummy = op->dummy.nbytes * BITS_PER_BYTE / op->dummy.buswidth;
|
||||
+
|
||||
+ if ((op->data.buswidth == 2) || (op->data.buswidth == 4)) {
|
||||
+ if (op->addr.buswidth == 1)
|
||||
+ return dummy == 8;
|
||||
+ else if (op->addr.buswidth == 2)
|
||||
+ return dummy == 4;
|
||||
+ else if (op->addr.buswidth == 4)
|
||||
+ return dummy == 6;
|
||||
+ } else if ((op->addr.buswidth == 1) && (op->data.buswidth == 1)) {
|
||||
+ if (op->cmd.opcode == 0x03)
|
||||
+ return dummy == 0;
|
||||
+ else if (op->cmd.opcode == 0x0b)
|
||||
+ return dummy == 8;
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static int mtk_nor_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
|
||||
+{
|
||||
+ size_t len;
|
||||
+
|
||||
+ if (!op->data.nbytes)
|
||||
+ return 0;
|
||||
+
|
||||
+ if ((op->addr.nbytes == 3) || (op->addr.nbytes == 4)) {
|
||||
+ if ((op->data.dir == SPI_MEM_DATA_IN) &&
|
||||
+ mtk_nor_match_read(op)) {
|
||||
+ if ((op->addr.val & MTK_NOR_DMA_ALIGN_MASK) ||
|
||||
+ (op->data.nbytes < MTK_NOR_DMA_ALIGN))
|
||||
+ op->data.nbytes = 1;
|
||||
+ else if (!((ulong)(op->data.buf.in) &
|
||||
+ MTK_NOR_DMA_ALIGN_MASK))
|
||||
+ op->data.nbytes &= ~MTK_NOR_DMA_ALIGN_MASK;
|
||||
+ else if (op->data.nbytes > MTK_NOR_BOUNCE_BUF_SIZE)
|
||||
+ op->data.nbytes = MTK_NOR_BOUNCE_BUF_SIZE;
|
||||
+ return 0;
|
||||
+ } else if (op->data.dir == SPI_MEM_DATA_OUT) {
|
||||
+ if (op->data.nbytes >= MTK_NOR_PP_SIZE)
|
||||
+ op->data.nbytes = MTK_NOR_PP_SIZE;
|
||||
+ else
|
||||
+ op->data.nbytes = 1;
|
||||
+ return 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ len = MTK_NOR_PRG_MAX_SIZE - sizeof(op->cmd.opcode) - op->addr.nbytes -
|
||||
+ op->dummy.nbytes;
|
||||
+ if (op->data.nbytes > len)
|
||||
+ op->data.nbytes = len;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static bool mtk_nor_supports_op(struct spi_mem *mem,
|
||||
+ const struct spi_mem_op *op)
|
||||
+{
|
||||
+ size_t len;
|
||||
+
|
||||
+ if (op->cmd.buswidth != 1)
|
||||
+ return false;
|
||||
+
|
||||
+ if ((op->addr.nbytes == 3) || (op->addr.nbytes == 4)) {
|
||||
+ if ((op->data.dir == SPI_MEM_DATA_IN) && mtk_nor_match_read(op))
|
||||
+ return true;
|
||||
+ else if (op->data.dir == SPI_MEM_DATA_OUT)
|
||||
+ return (op->addr.buswidth == 1) &&
|
||||
+ (op->dummy.buswidth == 0) &&
|
||||
+ (op->data.buswidth == 1);
|
||||
+ }
|
||||
+ len = sizeof(op->cmd.opcode) + op->addr.nbytes + op->dummy.nbytes;
|
||||
+ if ((len > MTK_NOR_PRG_MAX_SIZE) ||
|
||||
+ ((op->data.nbytes) && (len == MTK_NOR_PRG_MAX_SIZE)))
|
||||
+ return false;
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+static void mtk_nor_setup_bus(struct mtk_nor *sp, const struct spi_mem_op *op)
|
||||
+{
|
||||
+ u32 reg = 0;
|
||||
+
|
||||
+ if (op->addr.nbytes == 4)
|
||||
+ reg |= MTK_NOR_4B_ADDR;
|
||||
+
|
||||
+ if (op->data.buswidth == 4) {
|
||||
+ reg |= MTK_NOR_QUAD_READ;
|
||||
+ writeb(op->cmd.opcode, sp->base + MTK_NOR_REG_PRGDATA(4));
|
||||
+ if (op->addr.buswidth == 4)
|
||||
+ reg |= MTK_NOR_QUAD_ADDR;
|
||||
+ } else if (op->data.buswidth == 2) {
|
||||
+ reg |= MTK_NOR_DUAL_READ;
|
||||
+ writeb(op->cmd.opcode, sp->base + MTK_NOR_REG_PRGDATA(3));
|
||||
+ if (op->addr.buswidth == 2)
|
||||
+ reg |= MTK_NOR_DUAL_ADDR;
|
||||
+ } else {
|
||||
+ if (op->cmd.opcode == 0x0b)
|
||||
+ mtk_nor_rmw(sp, MTK_NOR_REG_CFG1, MTK_NOR_FAST_READ, 0);
|
||||
+ else
|
||||
+ mtk_nor_rmw(sp, MTK_NOR_REG_CFG1, 0, MTK_NOR_FAST_READ);
|
||||
+ }
|
||||
+ mtk_nor_rmw(sp, MTK_NOR_REG_BUSCFG, reg, MTK_NOR_BUS_MODE_MASK);
|
||||
+}
|
||||
+
|
||||
+static int mtk_nor_read_dma(struct mtk_nor *sp, u32 from, unsigned int length,
|
||||
+ u8 *buffer)
|
||||
+{
|
||||
+ int ret = 0;
|
||||
+ ulong delay;
|
||||
+ u32 reg;
|
||||
+ dma_addr_t dma_addr;
|
||||
+
|
||||
+ dma_addr = dma_map_single(sp->dev, buffer, length, DMA_FROM_DEVICE);
|
||||
+ if (dma_mapping_error(sp->dev, dma_addr)) {
|
||||
+ dev_err(sp->dev, "failed to map dma buffer.\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ writel(from, sp->base + MTK_NOR_REG_DMA_FADR);
|
||||
+ writel(dma_addr, sp->base + MTK_NOR_REG_DMA_DADR);
|
||||
+ writel(dma_addr + length, sp->base + MTK_NOR_REG_DMA_END_DADR);
|
||||
+
|
||||
+ if (sp->has_irq) {
|
||||
+ reinit_completion(&sp->op_done);
|
||||
+ mtk_nor_rmw(sp, MTK_NOR_REG_IRQ_EN, MTK_NOR_IRQ_DMA, 0);
|
||||
+ }
|
||||
+
|
||||
+ mtk_nor_rmw(sp, MTK_NOR_REG_DMA_CTL, MTK_NOR_DMA_START, 0);
|
||||
+
|
||||
+ delay = CLK_TO_US(sp, (length + 5) * BITS_PER_BYTE);
|
||||
+
|
||||
+ if (sp->has_irq) {
|
||||
+ if (!wait_for_completion_timeout(&sp->op_done,
|
||||
+ (delay + 1) * 100))
|
||||
+ ret = -ETIMEDOUT;
|
||||
+ } else {
|
||||
+ ret = readl_poll_timeout(sp->base + MTK_NOR_REG_DMA_CTL, reg,
|
||||
+ !(reg & MTK_NOR_DMA_START), delay / 3,
|
||||
+ (delay + 1) * 100);
|
||||
+ }
|
||||
+
|
||||
+ dma_unmap_single(sp->dev, dma_addr, length, DMA_FROM_DEVICE);
|
||||
+ if (ret < 0)
|
||||
+ dev_err(sp->dev, "dma read timeout.\n");
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int mtk_nor_read_bounce(struct mtk_nor *sp, u32 from,
|
||||
+ unsigned int length, u8 *buffer)
|
||||
+{
|
||||
+ unsigned int rdlen;
|
||||
+ int ret;
|
||||
+
|
||||
+ if (length & MTK_NOR_DMA_ALIGN_MASK)
|
||||
+ rdlen = (length + MTK_NOR_DMA_ALIGN) & ~MTK_NOR_DMA_ALIGN_MASK;
|
||||
+ else
|
||||
+ rdlen = length;
|
||||
+
|
||||
+ ret = mtk_nor_read_dma(sp, from, rdlen, sp->buffer);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ memcpy(buffer, sp->buffer, length);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int mtk_nor_read_pio(struct mtk_nor *sp, const struct spi_mem_op *op)
|
||||
+{
|
||||
+ u8 *buf = op->data.buf.in;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = mtk_nor_cmd_exec(sp, MTK_NOR_CMD_READ, 6 * BITS_PER_BYTE);
|
||||
+ if (!ret)
|
||||
+ buf[0] = readb(sp->base + MTK_NOR_REG_RDATA);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int mtk_nor_write_buffer_enable(struct mtk_nor *sp)
|
||||
+{
|
||||
+ int ret;
|
||||
+ u32 val;
|
||||
+
|
||||
+ if (sp->wbuf_en)
|
||||
+ return 0;
|
||||
+
|
||||
+ val = readl(sp->base + MTK_NOR_REG_CFG2);
|
||||
+ writel(val | MTK_NOR_WR_BUF_EN, sp->base + MTK_NOR_REG_CFG2);
|
||||
+ ret = readl_poll_timeout(sp->base + MTK_NOR_REG_CFG2, val,
|
||||
+ val & MTK_NOR_WR_BUF_EN, 0, 10000);
|
||||
+ if (!ret)
|
||||
+ sp->wbuf_en = true;
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int mtk_nor_write_buffer_disable(struct mtk_nor *sp)
|
||||
+{
|
||||
+ int ret;
|
||||
+ u32 val;
|
||||
+
|
||||
+ if (!sp->wbuf_en)
|
||||
+ return 0;
|
||||
+ val = readl(sp->base + MTK_NOR_REG_CFG2);
|
||||
+ writel(val & ~MTK_NOR_WR_BUF_EN, sp->base + MTK_NOR_REG_CFG2);
|
||||
+ ret = readl_poll_timeout(sp->base + MTK_NOR_REG_CFG2, val,
|
||||
+ !(val & MTK_NOR_WR_BUF_EN), 0, 10000);
|
||||
+ if (!ret)
|
||||
+ sp->wbuf_en = false;
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static int mtk_nor_pp_buffered(struct mtk_nor *sp, const struct spi_mem_op *op)
|
||||
+{
|
||||
+ const u8 *buf = op->data.buf.out;
|
||||
+ u32 val;
|
||||
+ int ret, i;
|
||||
+
|
||||
+ ret = mtk_nor_write_buffer_enable(sp);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ for (i = 0; i < op->data.nbytes; i += 4) {
|
||||
+ val = buf[i + 3] << 24 | buf[i + 2] << 16 | buf[i + 1] << 8 |
|
||||
+ buf[i];
|
||||
+ writel(val, sp->base + MTK_NOR_REG_PP_DATA);
|
||||
+ }
|
||||
+ return mtk_nor_cmd_exec(sp, MTK_NOR_CMD_WRITE,
|
||||
+ (op->data.nbytes + 5) * BITS_PER_BYTE);
|
||||
+}
|
||||
+
|
||||
+static int mtk_nor_pp_unbuffered(struct mtk_nor *sp,
|
||||
+ const struct spi_mem_op *op)
|
||||
+{
|
||||
+ const u8 *buf = op->data.buf.out;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = mtk_nor_write_buffer_disable(sp);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ writeb(buf[0], sp->base + MTK_NOR_REG_WDATA);
|
||||
+ return mtk_nor_cmd_exec(sp, MTK_NOR_CMD_WRITE, 6 * BITS_PER_BYTE);
|
||||
+}
|
||||
+
|
||||
+int mtk_nor_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
|
||||
+{
|
||||
+ struct mtk_nor *sp = spi_controller_get_devdata(mem->spi->master);
|
||||
+ int ret;
|
||||
+
|
||||
+ if ((op->data.nbytes == 0) ||
|
||||
+ ((op->addr.nbytes != 3) && (op->addr.nbytes != 4)))
|
||||
+ return -ENOTSUPP;
|
||||
+
|
||||
+ if (op->data.dir == SPI_MEM_DATA_OUT) {
|
||||
+ mtk_nor_set_addr(sp, op);
|
||||
+ writeb(op->cmd.opcode, sp->base + MTK_NOR_REG_PRGDATA0);
|
||||
+ if (op->data.nbytes == MTK_NOR_PP_SIZE)
|
||||
+ return mtk_nor_pp_buffered(sp, op);
|
||||
+ return mtk_nor_pp_unbuffered(sp, op);
|
||||
+ }
|
||||
+
|
||||
+ if ((op->data.dir == SPI_MEM_DATA_IN) && mtk_nor_match_read(op)) {
|
||||
+ ret = mtk_nor_write_buffer_disable(sp);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ mtk_nor_setup_bus(sp, op);
|
||||
+ if (op->data.nbytes == 1) {
|
||||
+ mtk_nor_set_addr(sp, op);
|
||||
+ return mtk_nor_read_pio(sp, op);
|
||||
+ } else if (((ulong)(op->data.buf.in) &
|
||||
+ MTK_NOR_DMA_ALIGN_MASK)) {
|
||||
+ return mtk_nor_read_bounce(sp, op->addr.val,
|
||||
+ op->data.nbytes,
|
||||
+ op->data.buf.in);
|
||||
+ } else {
|
||||
+ return mtk_nor_read_dma(sp, op->addr.val,
|
||||
+ op->data.nbytes,
|
||||
+ op->data.buf.in);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return -ENOTSUPP;
|
||||
+}
|
||||
+
|
||||
+static int mtk_nor_setup(struct spi_device *spi)
|
||||
+{
|
||||
+ struct mtk_nor *sp = spi_controller_get_devdata(spi->master);
|
||||
+
|
||||
+ if (spi->max_speed_hz && (spi->max_speed_hz < sp->spi_freq)) {
|
||||
+ dev_err(&spi->dev, "spi clock should be %u Hz.\n",
|
||||
+ sp->spi_freq);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ spi->max_speed_hz = sp->spi_freq;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int mtk_nor_transfer_one_message(struct spi_controller *master,
|
||||
+ struct spi_message *m)
|
||||
+{
|
||||
+ struct mtk_nor *sp = spi_controller_get_devdata(master);
|
||||
+ struct spi_transfer *t = NULL;
|
||||
+ unsigned long trx_len = 0;
|
||||
+ int stat = 0;
|
||||
+ int reg_offset = MTK_NOR_REG_PRGDATA_MAX;
|
||||
+ void __iomem *reg;
|
||||
+ const u8 *txbuf;
|
||||
+ u8 *rxbuf;
|
||||
+ int i;
|
||||
+
|
||||
+ list_for_each_entry(t, &m->transfers, transfer_list) {
|
||||
+ txbuf = t->tx_buf;
|
||||
+ for (i = 0; i < t->len; i++, reg_offset--) {
|
||||
+ reg = sp->base + MTK_NOR_REG_PRGDATA(reg_offset);
|
||||
+ if (txbuf)
|
||||
+ writeb(txbuf[i], reg);
|
||||
+ else
|
||||
+ writeb(0, reg);
|
||||
+ }
|
||||
+ trx_len += t->len;
|
||||
+ }
|
||||
+
|
||||
+ writel(trx_len * BITS_PER_BYTE, sp->base + MTK_NOR_REG_PRG_CNT);
|
||||
+
|
||||
+ stat = mtk_nor_cmd_exec(sp, MTK_NOR_CMD_PROGRAM,
|
||||
+ trx_len * BITS_PER_BYTE);
|
||||
+ if (stat < 0)
|
||||
+ goto msg_done;
|
||||
+
|
||||
+ reg_offset = trx_len - 1;
|
||||
+ list_for_each_entry(t, &m->transfers, transfer_list) {
|
||||
+ rxbuf = t->rx_buf;
|
||||
+ for (i = 0; i < t->len; i++, reg_offset--) {
|
||||
+ reg = sp->base + MTK_NOR_REG_SHIFT(reg_offset);
|
||||
+ if (rxbuf)
|
||||
+ rxbuf[i] = readb(reg);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ m->actual_length = trx_len;
|
||||
+msg_done:
|
||||
+ m->status = stat;
|
||||
+ spi_finalize_current_message(master);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void mtk_nor_disable_clk(struct mtk_nor *sp)
|
||||
+{
|
||||
+ clk_disable_unprepare(sp->spi_clk);
|
||||
+ clk_disable_unprepare(sp->ctlr_clk);
|
||||
+}
|
||||
+
|
||||
+static int mtk_nor_enable_clk(struct mtk_nor *sp)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = clk_prepare_enable(sp->spi_clk);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = clk_prepare_enable(sp->ctlr_clk);
|
||||
+ if (ret) {
|
||||
+ clk_disable_unprepare(sp->spi_clk);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int mtk_nor_init(struct mtk_nor *sp)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = mtk_nor_enable_clk(sp);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ sp->spi_freq = clk_get_rate(sp->spi_clk);
|
||||
+
|
||||
+ writel(MTK_NOR_ENABLE_SF_CMD, sp->base + MTK_NOR_REG_WP);
|
||||
+ mtk_nor_rmw(sp, MTK_NOR_REG_CFG2, MTK_NOR_WR_CUSTOM_OP_EN, 0);
|
||||
+ mtk_nor_rmw(sp, MTK_NOR_REG_CFG3,
|
||||
+ MTK_NOR_DISABLE_WREN | MTK_NOR_DISABLE_SR_POLL, 0);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static irqreturn_t mtk_nor_irq_handler(int irq, void *data)
|
||||
+{
|
||||
+ struct mtk_nor *sp = data;
|
||||
+ u32 irq_status, irq_enabled;
|
||||
+
|
||||
+ irq_status = readl(sp->base + MTK_NOR_REG_IRQ_STAT);
|
||||
+ irq_enabled = readl(sp->base + MTK_NOR_REG_IRQ_EN);
|
||||
+ // write status back to clear interrupt
|
||||
+ writel(irq_status, sp->base + MTK_NOR_REG_IRQ_STAT);
|
||||
+
|
||||
+ if (!(irq_status & irq_enabled))
|
||||
+ return IRQ_NONE;
|
||||
+
|
||||
+ if (irq_status & MTK_NOR_IRQ_DMA) {
|
||||
+ complete(&sp->op_done);
|
||||
+ writel(0, sp->base + MTK_NOR_REG_IRQ_EN);
|
||||
+ }
|
||||
+
|
||||
+ return IRQ_HANDLED;
|
||||
+}
|
||||
+
|
||||
+static size_t mtk_max_msg_size(struct spi_device *spi)
|
||||
+{
|
||||
+ return MTK_NOR_PRG_MAX_SIZE;
|
||||
+}
|
||||
+
|
||||
+static const struct spi_controller_mem_ops mtk_nor_mem_ops = {
|
||||
+ .adjust_op_size = mtk_nor_adjust_op_size,
|
||||
+ .supports_op = mtk_nor_supports_op,
|
||||
+ .exec_op = mtk_nor_exec_op
|
||||
+};
|
||||
+
|
||||
+static const struct of_device_id mtk_nor_match[] = {
|
||||
+ { .compatible = "mediatek,mt8173-nor" },
|
||||
+ { /* sentinel */ }
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, mtk_nor_match);
|
||||
+
|
||||
+static int mtk_nor_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct spi_controller *ctlr;
|
||||
+ struct mtk_nor *sp;
|
||||
+ void __iomem *base;
|
||||
+ u8 *buffer;
|
||||
+ struct clk *spi_clk, *ctlr_clk;
|
||||
+ int ret, irq;
|
||||
+
|
||||
+ base = devm_platform_ioremap_resource(pdev, 0);
|
||||
+ if (IS_ERR(base))
|
||||
+ return PTR_ERR(base);
|
||||
+
|
||||
+ spi_clk = devm_clk_get(&pdev->dev, "spi");
|
||||
+ if (IS_ERR(spi_clk))
|
||||
+ return PTR_ERR(spi_clk);
|
||||
+
|
||||
+ ctlr_clk = devm_clk_get(&pdev->dev, "sf");
|
||||
+ if (IS_ERR(ctlr_clk))
|
||||
+ return PTR_ERR(ctlr_clk);
|
||||
+
|
||||
+ buffer = devm_kmalloc(&pdev->dev,
|
||||
+ MTK_NOR_BOUNCE_BUF_SIZE + MTK_NOR_DMA_ALIGN,
|
||||
+ GFP_KERNEL);
|
||||
+ if (!buffer)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ if ((ulong)buffer & MTK_NOR_DMA_ALIGN_MASK)
|
||||
+ buffer = (u8 *)(((ulong)buffer + MTK_NOR_DMA_ALIGN) &
|
||||
+ ~MTK_NOR_DMA_ALIGN_MASK);
|
||||
+
|
||||
+ ctlr = spi_alloc_master(&pdev->dev, sizeof(*sp));
|
||||
+ if (!ctlr) {
|
||||
+ dev_err(&pdev->dev, "failed to allocate spi controller\n");
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ ctlr->bits_per_word_mask = SPI_BPW_MASK(8);
|
||||
+ ctlr->dev.of_node = pdev->dev.of_node;
|
||||
+ ctlr->max_message_size = mtk_max_msg_size;
|
||||
+ ctlr->mem_ops = &mtk_nor_mem_ops;
|
||||
+ ctlr->mode_bits = SPI_RX_DUAL | SPI_RX_QUAD | SPI_TX_DUAL | SPI_TX_QUAD;
|
||||
+ ctlr->num_chipselect = 1;
|
||||
+ ctlr->setup = mtk_nor_setup;
|
||||
+ ctlr->transfer_one_message = mtk_nor_transfer_one_message;
|
||||
+
|
||||
+ dev_set_drvdata(&pdev->dev, ctlr);
|
||||
+
|
||||
+ sp = spi_controller_get_devdata(ctlr);
|
||||
+ sp->base = base;
|
||||
+ sp->buffer = buffer;
|
||||
+ sp->has_irq = false;
|
||||
+ sp->wbuf_en = false;
|
||||
+ sp->ctlr = ctlr;
|
||||
+ sp->dev = &pdev->dev;
|
||||
+ sp->spi_clk = spi_clk;
|
||||
+ sp->ctlr_clk = ctlr_clk;
|
||||
+
|
||||
+ irq = platform_get_irq_optional(pdev, 0);
|
||||
+ if (irq < 0) {
|
||||
+ dev_warn(sp->dev, "IRQ not available.");
|
||||
+ } else {
|
||||
+ writel(MTK_NOR_IRQ_MASK, base + MTK_NOR_REG_IRQ_STAT);
|
||||
+ writel(0, base + MTK_NOR_REG_IRQ_EN);
|
||||
+ ret = devm_request_irq(sp->dev, irq, mtk_nor_irq_handler, 0,
|
||||
+ pdev->name, sp);
|
||||
+ if (ret < 0) {
|
||||
+ dev_warn(sp->dev, "failed to request IRQ.");
|
||||
+ } else {
|
||||
+ init_completion(&sp->op_done);
|
||||
+ sp->has_irq = true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ ret = mtk_nor_init(sp);
|
||||
+ if (ret < 0) {
|
||||
+ kfree(ctlr);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ dev_info(&pdev->dev, "spi frequency: %d Hz\n", sp->spi_freq);
|
||||
+
|
||||
+ return devm_spi_register_controller(&pdev->dev, ctlr);
|
||||
+}
|
||||
+
|
||||
+static int mtk_nor_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct spi_controller *ctlr;
|
||||
+ struct mtk_nor *sp;
|
||||
+
|
||||
+ ctlr = dev_get_drvdata(&pdev->dev);
|
||||
+ sp = spi_controller_get_devdata(ctlr);
|
||||
+
|
||||
+ mtk_nor_disable_clk(sp);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static struct platform_driver mtk_nor_driver = {
|
||||
+ .driver = {
|
||||
+ .name = DRIVER_NAME,
|
||||
+ .of_match_table = mtk_nor_match,
|
||||
+ },
|
||||
+ .probe = mtk_nor_probe,
|
||||
+ .remove = mtk_nor_remove,
|
||||
+};
|
||||
+
|
||||
+module_platform_driver(mtk_nor_driver);
|
||||
+
|
||||
+MODULE_DESCRIPTION("Mediatek SPI NOR controller driver");
|
||||
+MODULE_AUTHOR("Chuanhong Guo <gch981213@gmail.com>");
|
||||
+MODULE_LICENSE("GPL v2");
|
||||
+MODULE_ALIAS("platform:" DRIVER_NAME);
|
|
@ -0,0 +1,19 @@
|
|||
--- a/drivers/net/phy/Kconfig
|
||||
+++ b/drivers/net/phy/Kconfig
|
||||
@@ -329,6 +329,8 @@ config RTL8367B_PHY
|
||||
|
||||
endif # RTL8366_SMI
|
||||
|
||||
+source "drivers/net/phy/mtk/mt753x/Kconfig"
|
||||
+
|
||||
comment "MII PHY device drivers"
|
||||
|
||||
config SFP
|
||||
--- a/drivers/net/phy/Makefile
|
||||
+++ b/drivers/net/phy/Makefile
|
||||
@@ -109,3 +109,5 @@ obj-$(CONFIG_STE10XP) += ste10Xp.o
|
||||
obj-$(CONFIG_TERANETICS_PHY) += teranetics.o
|
||||
obj-$(CONFIG_VITESSE_PHY) += vitesse.o
|
||||
obj-$(CONFIG_XILINX_GMII2RGMII) += xilinx_gmii2rgmii.o
|
||||
+obj-$(CONFIG_MT753X_GSW) += mtk/mt753x/
|
||||
+
|
|
@ -0,0 +1,67 @@
|
|||
--- a/arch/arm/boot/dts/mt7629-rfb.dts
|
||||
+++ b/arch/arm/boot/dts/mt7629-rfb.dts
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
chosen {
|
||||
stdout-path = "serial0:115200n8";
|
||||
+ bootargs = "earlycon=uart8250,mmio32,0x11002000 console=ttyS0,115200n8";
|
||||
};
|
||||
|
||||
gpio-keys {
|
||||
@@ -36,6 +37,13 @@
|
||||
};
|
||||
};
|
||||
|
||||
+ gsw: gsw@0 {
|
||||
+ compatible = "mediatek,mt753x";
|
||||
+ mediatek,ethsys = <ðsys>;
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ };
|
||||
+
|
||||
memory@40000000 {
|
||||
device_type = "memory";
|
||||
reg = <0x40000000 0x10000000>;
|
||||
@@ -69,6 +77,7 @@
|
||||
gmac0: mac@0 {
|
||||
compatible = "mediatek,eth-mac";
|
||||
reg = <0>;
|
||||
+ mtd-mac-address = <&factory 0x2a>;
|
||||
phy-mode = "2500base-x";
|
||||
fixed-link {
|
||||
speed = <2500>;
|
||||
@@ -80,6 +89,7 @@
|
||||
gmac1: mac@1 {
|
||||
compatible = "mediatek,eth-mac";
|
||||
reg = <1>;
|
||||
+ mtd-mac-address = <&factory 0x24>;
|
||||
phy-mode = "gmii";
|
||||
phy-handle = <&phy0>;
|
||||
};
|
||||
@@ -93,6 +103,26 @@
|
||||
};
|
||||
};
|
||||
};
|
||||
+
|
||||
+&gsw {
|
||||
+ mediatek,mdio = <&mdio>;
|
||||
+ mediatek,portmap = "llllw";
|
||||
+ mediatek,mdio_master_pinmux = <0>;
|
||||
+ reset-gpios = <&pio 28 0>;
|
||||
+ interrupt-parent = <&pio>;
|
||||
+ interrupts = <6 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ status = "okay";
|
||||
+
|
||||
+ port6: port@6 {
|
||||
+ compatible = "mediatek,mt753x-port";
|
||||
+ reg = <6>;
|
||||
+ phy-mode = "sgmii";
|
||||
+ fixed-link {
|
||||
+ speed = <2500>;
|
||||
+ full-duplex;
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
|
||||
&i2c {
|
||||
pinctrl-names = "default";
|
|
@ -0,0 +1,11 @@
|
|||
--- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
chosen {
|
||||
stdout-path = "serial0:115200n8";
|
||||
- bootargs = "earlycon=uart8250,mmio32,0x11002000 swiotlb=512";
|
||||
+ bootargs = "earlycon=uart8250,mmio32,0x11002000 console=ttyS0,115200n1 swiotlb=512";
|
||||
};
|
||||
|
||||
cpus {
|
|
@ -0,0 +1,13 @@
|
|||
--- a/arch/arm/boot/dts/mt7629-rfb.dts
|
||||
+++ b/arch/arm/boot/dts/mt7629-rfb.dts
|
||||
@@ -163,8 +163,9 @@
|
||||
};
|
||||
|
||||
partition@b0000 {
|
||||
- label = "kernel";
|
||||
+ label = "firmware";
|
||||
reg = <0xb0000 0xb50000>;
|
||||
+ compatible = "denx,fit";
|
||||
};
|
||||
};
|
||||
};
|
|
@ -0,0 +1,66 @@
|
|||
From 28f9a5e2a3f5441ab5594669ed82da11e32277a9 Mon Sep 17 00:00:00 2001
|
||||
From: Kristian Evensen <kristian.evensen@gmail.com>
|
||||
Date: Mon, 30 Apr 2018 14:38:01 +0200
|
||||
Subject: [PATCH] phy: phy-mtk-tphy: Add hifsys-support
|
||||
|
||||
---
|
||||
drivers/phy/mediatek/phy-mtk-tphy.c | 20 ++++++++++++++++++++
|
||||
1 file changed, 20 insertions(+)
|
||||
|
||||
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
|
||||
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
|
||||
@@ -15,6 +15,8 @@
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/phy/phy.h>
|
||||
#include <linux/platform_device.h>
|
||||
+#include <linux/mfd/syscon.h>
|
||||
+#include <linux/regmap.h>
|
||||
|
||||
/* version V1 sub-banks offset base address */
|
||||
/* banks shared by multiple phys */
|
||||
@@ -263,6 +265,9 @@
|
||||
#define RG_CDR_BIRLTD0_GEN3_MSK GENMASK(4, 0)
|
||||
#define RG_CDR_BIRLTD0_GEN3_VAL(x) (0x1f & (x))
|
||||
|
||||
+#define HIF_SYSCFG1 0x14
|
||||
+#define HIF_SYSCFG1_PHY2_MASK (0x3 << 20)
|
||||
+
|
||||
enum mtk_phy_version {
|
||||
MTK_PHY_V1 = 1,
|
||||
MTK_PHY_V2,
|
||||
@@ -310,6 +315,7 @@ struct mtk_tphy {
|
||||
struct clk *u3phya_ref; /* reference clock of usb3 anolog phy */
|
||||
const struct mtk_phy_pdata *pdata;
|
||||
struct mtk_phy_instance **phys;
|
||||
+ struct regmap *hif;
|
||||
int nphys;
|
||||
int src_ref_clk; /* MHZ, reference clock for slew rate calibrate */
|
||||
int src_coef; /* coefficient for slew rate calibrate */
|
||||
@@ -629,6 +635,10 @@ static void pcie_phy_instance_init(struc
|
||||
if (tphy->pdata->version != MTK_PHY_V1)
|
||||
return;
|
||||
|
||||
+ if (tphy->hif)
|
||||
+ regmap_update_bits(tphy->hif, HIF_SYSCFG1,
|
||||
+ HIF_SYSCFG1_PHY2_MASK, 0);
|
||||
+
|
||||
tmp = readl(u3_banks->phya + U3P_U3_PHYA_DA_REG0);
|
||||
tmp &= ~(P3A_RG_XTAL_EXT_PE1H | P3A_RG_XTAL_EXT_PE2H);
|
||||
tmp |= P3A_RG_XTAL_EXT_PE1H_VAL(0x2) | P3A_RG_XTAL_EXT_PE2H_VAL(0x2);
|
||||
@@ -1114,6 +1124,16 @@ static int mtk_tphy_probe(struct platfor
|
||||
&tphy->src_ref_clk);
|
||||
device_property_read_u32(dev, "mediatek,src-coef", &tphy->src_coef);
|
||||
|
||||
+ if (of_find_property(np, "mediatek,phy-switch", NULL)) {
|
||||
+ tphy->hif = syscon_regmap_lookup_by_phandle(np,
|
||||
+ "mediatek,phy-switch");
|
||||
+ if (IS_ERR(tphy->hif)) {
|
||||
+ dev_err(&pdev->dev,
|
||||
+ "missing \"mediatek,phy-switch\" phandle\n");
|
||||
+ return PTR_ERR(tphy->hif);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
port = 0;
|
||||
for_each_child_of_node(np, child_np) {
|
||||
struct mtk_phy_instance *instance;
|
|
@ -0,0 +1,387 @@
|
|||
From 004eb24e939b5b31f828333f37fb5cb2a877d6f2 Mon Sep 17 00:00:00 2001
|
||||
From: Kristian Evensen <kristian.evensen@gmail.com>
|
||||
Date: Sun, 17 Jun 2018 14:41:47 +0200
|
||||
Subject: [PATCH] arm: dts: Add Unielec U7623 DTS
|
||||
|
||||
---
|
||||
arch/arm/boot/dts/Makefile | 1 +
|
||||
.../dts/mt7623a-unielec-u7623-02-emmc-512m.dts | 18 +
|
||||
.../boot/dts/mt7623a-unielec-u7623-02-emmc.dtsi | 366 +++++++++++++++++++++
|
||||
3 files changed, 385 insertions(+)
|
||||
create mode 100644 arch/arm/boot/dts/mt7623a-unielec-u7623-02-emmc-512m.dts
|
||||
create mode 100644 arch/arm/boot/dts/mt7623a-unielec-u7623-02-emmc.dtsi
|
||||
|
||||
--- a/arch/arm/boot/dts/Makefile
|
||||
+++ b/arch/arm/boot/dts/Makefile
|
||||
@@ -1272,6 +1272,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \
|
||||
mt7623a-rfb-nand.dtb \
|
||||
mt7623n-rfb-emmc.dtb \
|
||||
mt7623n-bananapi-bpi-r2.dtb \
|
||||
+ mt7623a-unielec-u7623-02-emmc-512m.dtb \
|
||||
mt7629-rfb.dtb \
|
||||
mt8127-moose.dtb \
|
||||
mt8135-evbp1.dtb
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/boot/dts/mt7623a-unielec-u7623-02-emmc-512m.dts
|
||||
@@ -0,0 +1,18 @@
|
||||
+/*
|
||||
+ * Copyright 2018 Kristian Evensen <kristian.evensen@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
|
||||
+ */
|
||||
+
|
||||
+/dts-v1/;
|
||||
+#include "mt7623a-unielec-u7623-02-emmc.dtsi"
|
||||
+
|
||||
+/ {
|
||||
+ model = "UniElec U7623-02 eMMC (512M RAM)";
|
||||
+ compatible = "unielec,u7623-02-emmc-512m", "unielec,u7623-02-emmc", "mediatek,mt7623";
|
||||
+
|
||||
+ memory@80000000 {
|
||||
+ device_type = "memory";
|
||||
+ reg = <0 0x80000000 0 0x20000000>;
|
||||
+ };
|
||||
+};
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/boot/dts/mt7623a-unielec-u7623-02-emmc.dtsi
|
||||
@@ -0,0 +1,340 @@
|
||||
+/*
|
||||
+ * Copyright 2018 Kristian Evensen <kristian.evensen@gmail.com>
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
|
||||
+ */
|
||||
+
|
||||
+#include <dt-bindings/input/input.h>
|
||||
+#include "mt7623.dtsi"
|
||||
+#include "mt6323.dtsi"
|
||||
+
|
||||
+/ {
|
||||
+ compatible = "unielec,u7623-02-emmc", "mediatek,mt7623";
|
||||
+
|
||||
+ aliases {
|
||||
+ serial2 = &uart2;
|
||||
+ };
|
||||
+
|
||||
+ chosen {
|
||||
+ bootargs = "root=/dev/mmcblk0p2 rootfstype=squashfs,f2fs console=ttyS0,115200 blkdevparts=mmcblk0:3M@6M(recovery),256M@9M(root)";
|
||||
+ stdout-path = "serial2:115200n8";
|
||||
+ };
|
||||
+
|
||||
+ cpus {
|
||||
+ cpu@0 {
|
||||
+ proc-supply = <&mt6323_vproc_reg>;
|
||||
+ };
|
||||
+
|
||||
+ cpu@1 {
|
||||
+ proc-supply = <&mt6323_vproc_reg>;
|
||||
+ };
|
||||
+
|
||||
+ cpu@2 {
|
||||
+ proc-supply = <&mt6323_vproc_reg>;
|
||||
+ };
|
||||
+
|
||||
+ cpu@3 {
|
||||
+ proc-supply = <&mt6323_vproc_reg>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ reg_1p8v: regulator-1p8v {
|
||||
+ compatible = "regulator-fixed";
|
||||
+ regulator-name = "fixed-1.8V";
|
||||
+ regulator-min-microvolt = <1800000>;
|
||||
+ regulator-max-microvolt = <1800000>;
|
||||
+ regulator-boot-on;
|
||||
+ regulator-always-on;
|
||||
+ };
|
||||
+
|
||||
+ reg_3p3v: regulator-3p3v {
|
||||
+ compatible = "regulator-fixed";
|
||||
+ regulator-name = "fixed-3.3V";
|
||||
+ regulator-min-microvolt = <3300000>;
|
||||
+ regulator-max-microvolt = <3300000>;
|
||||
+ regulator-boot-on;
|
||||
+ regulator-always-on;
|
||||
+ };
|
||||
+
|
||||
+ reg_5v: regulator-5v {
|
||||
+ compatible = "regulator-fixed";
|
||||
+ regulator-name = "fixed-5V";
|
||||
+ regulator-min-microvolt = <5000000>;
|
||||
+ regulator-max-microvolt = <5000000>;
|
||||
+ regulator-boot-on;
|
||||
+ regulator-always-on;
|
||||
+ };
|
||||
+
|
||||
+ gpio-keys {
|
||||
+ compatible = "gpio-keys";
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&key_pins_a>;
|
||||
+
|
||||
+ factory {
|
||||
+ label = "factory";
|
||||
+ linux,code = <KEY_RESTART>;
|
||||
+ gpios = <&pio 256 GPIO_ACTIVE_LOW>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ leds {
|
||||
+ compatible = "gpio-leds";
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&led_pins_unielec>;
|
||||
+
|
||||
+ led3 {
|
||||
+ label = "u7623-01:green:led3";
|
||||
+ gpios = <&pio 14 GPIO_ACTIVE_LOW>;
|
||||
+ };
|
||||
+
|
||||
+ led4 {
|
||||
+ label = "u7623-01:green:led4";
|
||||
+ gpios = <&pio 15 GPIO_ACTIVE_LOW>;
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&crypto {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+ð {
|
||||
+ status = "okay";
|
||||
+
|
||||
+ gmac0: mac@0 {
|
||||
+ compatible = "mediatek,eth-mac";
|
||||
+ reg = <0>;
|
||||
+ phy-mode = "trgmii";
|
||||
+
|
||||
+ fixed-link {
|
||||
+ speed = <1000>;
|
||||
+ full-duplex;
|
||||
+ pause;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ mdio: mdio-bus {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+
|
||||
+ mt7530: switch@0 {
|
||||
+ compatible = "mediatek,mt7530";
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&mt7530 {
|
||||
+ compatible = "mediatek,mt7530";
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ reg = <0>;
|
||||
+ pinctrl-names = "default";
|
||||
+ mediatek,mcm;
|
||||
+ resets = <ðsys 2>;
|
||||
+ reset-names = "mcm";
|
||||
+ core-supply = <&mt6323_vpa_reg>;
|
||||
+ io-supply = <&mt6323_vemc3v3_reg>;
|
||||
+
|
||||
+ dsa,mii-bus = <&mdio>;
|
||||
+
|
||||
+ ports {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ reg = <0>;
|
||||
+
|
||||
+ port@0 {
|
||||
+ reg = <0>;
|
||||
+ label = "lan0";
|
||||
+ cpu = <&cpu_port0>;
|
||||
+ };
|
||||
+
|
||||
+ port@1 {
|
||||
+ reg = <1>;
|
||||
+ label = "lan1";
|
||||
+ cpu = <&cpu_port0>;
|
||||
+ };
|
||||
+
|
||||
+ port@2 {
|
||||
+ reg = <2>;
|
||||
+ label = "lan2";
|
||||
+ cpu = <&cpu_port0>;
|
||||
+ };
|
||||
+
|
||||
+ port@3 {
|
||||
+ reg = <3>;
|
||||
+ label = "lan3";
|
||||
+ cpu = <&cpu_port0>;
|
||||
+ };
|
||||
+
|
||||
+ port@4 {
|
||||
+ reg = <4>;
|
||||
+ label = "wan";
|
||||
+ cpu = <&cpu_port0>;
|
||||
+ };
|
||||
+
|
||||
+ cpu_port0: port@6 {
|
||||
+ reg = <6>;
|
||||
+ label = "cpu";
|
||||
+ ethernet = <&gmac0>;
|
||||
+ phy-mode = "trgmii";
|
||||
+
|
||||
+ fixed-link {
|
||||
+ speed = <1000>;
|
||||
+ full-duplex;
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&mmc0 {
|
||||
+ pinctrl-names = "default", "state_uhs";
|
||||
+ pinctrl-0 = <&mmc0_pins_default>;
|
||||
+ pinctrl-1 = <&mmc0_pins_uhs>;
|
||||
+ status = "okay";
|
||||
+ bus-width = <8>;
|
||||
+ max-frequency = <50000000>;
|
||||
+ cap-mmc-highspeed;
|
||||
+ vmmc-supply = <®_3p3v>;
|
||||
+ vqmmc-supply = <®_1p8v>;
|
||||
+ non-removable;
|
||||
+};
|
||||
+
|
||||
+&pio {
|
||||
+ key_pins_a: keys-alt {
|
||||
+ pins-keys {
|
||||
+ pinmux = <MT7623_PIN_256_GPIO256_FUNC_GPIO256>,
|
||||
+ <MT7623_PIN_257_GPIO257_FUNC_GPIO257>;
|
||||
+ input-enable;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ led_pins_unielec: leds-unielec {
|
||||
+ pins-leds {
|
||||
+ pinmux = <MT7623_PIN_14_GPIO14_FUNC_GPIO14>,
|
||||
+ <MT7623_PIN_15_GPIO15_FUNC_GPIO15>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ mmc0_pins_default: mmc0default {
|
||||
+ pins_cmd_dat {
|
||||
+ pinmux = <MT7623_PIN_111_MSDC0_DAT7_FUNC_MSDC0_DAT7>,
|
||||
+ <MT7623_PIN_112_MSDC0_DAT6_FUNC_MSDC0_DAT6>,
|
||||
+ <MT7623_PIN_113_MSDC0_DAT5_FUNC_MSDC0_DAT5>,
|
||||
+ <MT7623_PIN_114_MSDC0_DAT4_FUNC_MSDC0_DAT4>,
|
||||
+ <MT7623_PIN_118_MSDC0_DAT3_FUNC_MSDC0_DAT3>,
|
||||
+ <MT7623_PIN_119_MSDC0_DAT2_FUNC_MSDC0_DAT2>,
|
||||
+ <MT7623_PIN_120_MSDC0_DAT1_FUNC_MSDC0_DAT1>,
|
||||
+ <MT7623_PIN_121_MSDC0_DAT0_FUNC_MSDC0_DAT0>,
|
||||
+ <MT7623_PIN_116_MSDC0_CMD_FUNC_MSDC0_CMD>;
|
||||
+ input-enable;
|
||||
+ bias-pull-up;
|
||||
+ };
|
||||
+
|
||||
+ pins_clk {
|
||||
+ pinmux = <MT7623_PIN_117_MSDC0_CLK_FUNC_MSDC0_CLK>;
|
||||
+ bias-pull-down;
|
||||
+ };
|
||||
+
|
||||
+ pins_rst {
|
||||
+ pinmux = <MT7623_PIN_115_MSDC0_RSTB_FUNC_MSDC0_RSTB>;
|
||||
+ bias-pull-up;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ mmc0_pins_uhs: mmc0 {
|
||||
+ pins_cmd_dat {
|
||||
+ pinmux = <MT7623_PIN_111_MSDC0_DAT7_FUNC_MSDC0_DAT7>,
|
||||
+ <MT7623_PIN_112_MSDC0_DAT6_FUNC_MSDC0_DAT6>,
|
||||
+ <MT7623_PIN_113_MSDC0_DAT5_FUNC_MSDC0_DAT5>,
|
||||
+ <MT7623_PIN_114_MSDC0_DAT4_FUNC_MSDC0_DAT4>,
|
||||
+ <MT7623_PIN_118_MSDC0_DAT3_FUNC_MSDC0_DAT3>,
|
||||
+ <MT7623_PIN_119_MSDC0_DAT2_FUNC_MSDC0_DAT2>,
|
||||
+ <MT7623_PIN_120_MSDC0_DAT1_FUNC_MSDC0_DAT1>,
|
||||
+ <MT7623_PIN_121_MSDC0_DAT0_FUNC_MSDC0_DAT0>,
|
||||
+ <MT7623_PIN_116_MSDC0_CMD_FUNC_MSDC0_CMD>;
|
||||
+ input-enable;
|
||||
+ drive-strength = <MTK_DRIVE_2mA>;
|
||||
+ bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
|
||||
+ };
|
||||
+
|
||||
+ pins_clk {
|
||||
+ pinmux = <MT7623_PIN_117_MSDC0_CLK_FUNC_MSDC0_CLK>;
|
||||
+ drive-strength = <MTK_DRIVE_2mA>;
|
||||
+ bias-pull-down = <MTK_PUPD_SET_R1R0_01>;
|
||||
+ };
|
||||
+
|
||||
+ pins_rst {
|
||||
+ pinmux = <MT7623_PIN_115_MSDC0_RSTB_FUNC_MSDC0_RSTB>;
|
||||
+ bias-pull-up;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ pcie_default: pcie_pin_default {
|
||||
+ pins_cmd_dat {
|
||||
+ pinmux = <MT7623_PIN_208_AUD_EXT_CK1_FUNC_PCIE0_PERST_N>,
|
||||
+ <MT7623_PIN_209_AUD_EXT_CK2_FUNC_PCIE1_PERST_N>;
|
||||
+ bias-disable;
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&pwm {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&pwm_pins_a>;
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&pwrap {
|
||||
+ mt6323 {
|
||||
+ mt6323led: led {
|
||||
+ compatible = "mediatek,mt6323-led";
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+
|
||||
+ led@0 {
|
||||
+ reg = <0>;
|
||||
+ label = "led0";
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&uart2 {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&uart2_pins_b>;
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&usb1 {
|
||||
+ vusb33-supply = <®_3p3v>;
|
||||
+ vbus-supply = <®_3p3v>;
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&u3phy1 {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&u3phy2 {
|
||||
+ status = "okay";
|
||||
+ mediatek,phy-switch = <&hifsys>;
|
||||
+};
|
||||
+
|
||||
+&pcie {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&pcie_default>;
|
||||
+ status = "okay";
|
||||
+
|
||||
+ pcie@1,0 {
|
||||
+ status = "okay";
|
||||
+ };
|
||||
+
|
||||
+ pcie@2,0 {
|
||||
+ status = "okay";
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&pcie1_phy {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
|
@ -0,0 +1,139 @@
|
|||
From a2479dc254ebe31c84fbcfda73f35e2321576494 Mon Sep 17 00:00:00 2001
|
||||
From: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
|
||||
Date: Tue, 19 Mar 2019 13:57:38 +0800
|
||||
Subject: [PATCH 1/6] mtd: mtk ecc: move mtk ecc header file to include/mtd
|
||||
|
||||
Change-Id: I8dc1d30e21b40d68ef5efd9587012f82970156a5
|
||||
Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
|
||||
---
|
||||
drivers/mtd/nand/raw/mtk_ecc.c | 3 +--
|
||||
drivers/mtd/nand/raw/mtk_nand.c | 2 +-
|
||||
{drivers/mtd/nand/raw => include/linux/mtd}/mtk_ecc.h | 0
|
||||
3 files changed, 2 insertions(+), 3 deletions(-)
|
||||
rename {drivers/mtd/nand/raw => include/linux/mtd}/mtk_ecc.h (100%)
|
||||
|
||||
--- a/drivers/mtd/nand/raw/mtk_ecc.c
|
||||
+++ b/drivers/mtd/nand/raw/mtk_ecc.c
|
||||
@@ -15,8 +15,7 @@
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/mutex.h>
|
||||
-
|
||||
-#include "mtk_ecc.h"
|
||||
+#include <linux/mtd/mtk_ecc.h>
|
||||
|
||||
#define ECC_IDLE_MASK BIT(0)
|
||||
#define ECC_IRQ_EN BIT(0)
|
||||
--- a/drivers/mtd/nand/raw/mtk_nand.c
|
||||
+++ b/drivers/mtd/nand/raw/mtk_nand.c
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <linux/iopoll.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_device.h>
|
||||
-#include "mtk_ecc.h"
|
||||
+#include <linux/mtd/mtk_ecc.h>
|
||||
|
||||
/* NAND controller register definition */
|
||||
#define NFI_CNFG (0x00)
|
||||
--- /dev/null
|
||||
+++ b/include/linux/mtd/mtk_ecc.h
|
||||
@@ -0,0 +1,49 @@
|
||||
+/*
|
||||
+ * MTK SDG1 ECC controller
|
||||
+ *
|
||||
+ * Copyright (c) 2016 Mediatek
|
||||
+ * Authors: Xiaolei Li <xiaolei.li@mediatek.com>
|
||||
+ * Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
|
||||
+ * This program is free software; you can redistribute it and/or modify it
|
||||
+ * under the terms of the GNU General Public License version 2 as published
|
||||
+ * by the Free Software Foundation.
|
||||
+ */
|
||||
+
|
||||
+#ifndef __DRIVERS_MTD_NAND_MTK_ECC_H__
|
||||
+#define __DRIVERS_MTD_NAND_MTK_ECC_H__
|
||||
+
|
||||
+#include <linux/types.h>
|
||||
+
|
||||
+enum mtk_ecc_mode {ECC_DMA_MODE = 0, ECC_NFI_MODE = 1};
|
||||
+enum mtk_ecc_operation {ECC_ENCODE, ECC_DECODE};
|
||||
+
|
||||
+struct device_node;
|
||||
+struct mtk_ecc;
|
||||
+
|
||||
+struct mtk_ecc_stats {
|
||||
+ u32 corrected;
|
||||
+ u32 bitflips;
|
||||
+ u32 failed;
|
||||
+};
|
||||
+
|
||||
+struct mtk_ecc_config {
|
||||
+ enum mtk_ecc_operation op;
|
||||
+ enum mtk_ecc_mode mode;
|
||||
+ dma_addr_t addr;
|
||||
+ u32 strength;
|
||||
+ u32 sectors;
|
||||
+ u32 len;
|
||||
+};
|
||||
+
|
||||
+int mtk_ecc_encode(struct mtk_ecc *, struct mtk_ecc_config *, u8 *, u32);
|
||||
+void mtk_ecc_get_stats(struct mtk_ecc *, struct mtk_ecc_stats *, int);
|
||||
+int mtk_ecc_wait_done(struct mtk_ecc *, enum mtk_ecc_operation);
|
||||
+int mtk_ecc_enable(struct mtk_ecc *, struct mtk_ecc_config *);
|
||||
+void mtk_ecc_disable(struct mtk_ecc *);
|
||||
+void mtk_ecc_adjust_strength(struct mtk_ecc *ecc, u32 *p);
|
||||
+unsigned int mtk_ecc_get_parity_bits(struct mtk_ecc *ecc);
|
||||
+
|
||||
+struct mtk_ecc *of_mtk_ecc_get(struct device_node *);
|
||||
+void mtk_ecc_release(struct mtk_ecc *);
|
||||
+
|
||||
+#endif
|
||||
--- a/drivers/mtd/nand/raw/mtk_ecc.h
|
||||
+++ /dev/null
|
||||
@@ -1,47 +0,0 @@
|
||||
-/* SPDX-License-Identifier: GPL-2.0 OR MIT */
|
||||
-/*
|
||||
- * MTK SDG1 ECC controller
|
||||
- *
|
||||
- * Copyright (c) 2016 Mediatek
|
||||
- * Authors: Xiaolei Li <xiaolei.li@mediatek.com>
|
||||
- * Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>
|
||||
- */
|
||||
-
|
||||
-#ifndef __DRIVERS_MTD_NAND_MTK_ECC_H__
|
||||
-#define __DRIVERS_MTD_NAND_MTK_ECC_H__
|
||||
-
|
||||
-#include <linux/types.h>
|
||||
-
|
||||
-enum mtk_ecc_mode {ECC_DMA_MODE = 0, ECC_NFI_MODE = 1};
|
||||
-enum mtk_ecc_operation {ECC_ENCODE, ECC_DECODE};
|
||||
-
|
||||
-struct device_node;
|
||||
-struct mtk_ecc;
|
||||
-
|
||||
-struct mtk_ecc_stats {
|
||||
- u32 corrected;
|
||||
- u32 bitflips;
|
||||
- u32 failed;
|
||||
-};
|
||||
-
|
||||
-struct mtk_ecc_config {
|
||||
- enum mtk_ecc_operation op;
|
||||
- enum mtk_ecc_mode mode;
|
||||
- dma_addr_t addr;
|
||||
- u32 strength;
|
||||
- u32 sectors;
|
||||
- u32 len;
|
||||
-};
|
||||
-
|
||||
-int mtk_ecc_encode(struct mtk_ecc *, struct mtk_ecc_config *, u8 *, u32);
|
||||
-void mtk_ecc_get_stats(struct mtk_ecc *, struct mtk_ecc_stats *, int);
|
||||
-int mtk_ecc_wait_done(struct mtk_ecc *, enum mtk_ecc_operation);
|
||||
-int mtk_ecc_enable(struct mtk_ecc *, struct mtk_ecc_config *);
|
||||
-void mtk_ecc_disable(struct mtk_ecc *);
|
||||
-void mtk_ecc_adjust_strength(struct mtk_ecc *ecc, u32 *p);
|
||||
-unsigned int mtk_ecc_get_parity_bits(struct mtk_ecc *ecc);
|
||||
-
|
||||
-struct mtk_ecc *of_mtk_ecc_get(struct device_node *);
|
||||
-void mtk_ecc_release(struct mtk_ecc *);
|
||||
-
|
||||
-#endif
|
|
@ -0,0 +1,31 @@
|
|||
From b341f120cfc9ca1dfd48364b7f36ac2c1fbdea43 Mon Sep 17 00:00:00 2001
|
||||
From: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
|
||||
Date: Wed, 3 Apr 2019 16:30:01 +0800
|
||||
Subject: [PATCH 3/6] mtd: spinand: disable on-die ECC
|
||||
|
||||
Change-Id: I9745adaed5295202fabbe8ab8947885c57a5b847
|
||||
Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
|
||||
---
|
||||
drivers/mtd/nand/spi/core.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/mtd/nand/spi/core.c
|
||||
+++ b/drivers/mtd/nand/spi/core.c
|
||||
@@ -491,7 +491,7 @@ static int spinand_mtd_read(struct mtd_i
|
||||
int ret = 0;
|
||||
|
||||
if (ops->mode != MTD_OPS_RAW && spinand->eccinfo.ooblayout)
|
||||
- enable_ecc = true;
|
||||
+ enable_ecc = false;
|
||||
|
||||
mutex_lock(&spinand->lock);
|
||||
|
||||
@@ -539,7 +539,7 @@ static int spinand_mtd_write(struct mtd_
|
||||
int ret = 0;
|
||||
|
||||
if (ops->mode != MTD_OPS_RAW && mtd->ooblayout)
|
||||
- enable_ecc = true;
|
||||
+ enable_ecc = false;
|
||||
|
||||
mutex_lock(&spinand->lock);
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,97 @@
|
|||
From c813fbe806257c574240770ef716fbee19f7dbfa Mon Sep 17 00:00:00 2001
|
||||
From: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
|
||||
Date: Thu, 6 Jun 2019 16:29:04 +0800
|
||||
Subject: [PATCH] spi: spi-mem: Mediatek: Add SPI Nand support for MT7629
|
||||
|
||||
Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
|
||||
---
|
||||
arch/arm/boot/dts/mt7629-rfb.dts | 45 ++++++++++++++++++++++++++++++++
|
||||
arch/arm/boot/dts/mt7629.dtsi | 22 ++++++++++++++++
|
||||
3 files changed, 79 insertions(+)
|
||||
|
||||
--- a/arch/arm/boot/dts/mt7629.dtsi
|
||||
+++ b/arch/arm/boot/dts/mt7629.dtsi
|
||||
@@ -258,6 +258,28 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
+ bch: ecc@1100e000 {
|
||||
+ compatible = "mediatek,mt7622-ecc";
|
||||
+ reg = <0x1100e000 0x1000>;
|
||||
+ interrupts = <GIC_SPI 95 IRQ_TYPE_LEVEL_LOW>;
|
||||
+ clocks = <&pericfg CLK_PERI_NFIECC_PD>;
|
||||
+ clock-names = "nfiecc_clk";
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
+ snfi: spi@1100d000 {
|
||||
+ compatible = "mediatek,mt7629-snfi";
|
||||
+ reg = <0x1100d000 0x1000>;
|
||||
+ interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_LOW>;
|
||||
+ clocks = <&pericfg CLK_PERI_NFI_PD>,
|
||||
+ <&pericfg CLK_PERI_SNFI_PD>;
|
||||
+ clock-names = "nfi_clk", "spi_clk";
|
||||
+ ecc-engine = <&bch>;
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
spi: spi@1100a000 {
|
||||
compatible = "mediatek,mt7629-spi",
|
||||
"mediatek,mt7622-spi";
|
||||
--- a/arch/arm/boot/dts/mt7629-rfb.dts
|
||||
+++ b/arch/arm/boot/dts/mt7629-rfb.dts
|
||||
@@ -276,6 +276,52 @@
|
||||
};
|
||||
};
|
||||
|
||||
+&bch {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&snfi {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&serial_nand_pins>;
|
||||
+ status = "okay";
|
||||
+
|
||||
+ spi_nand@0 {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <1>;
|
||||
+ compatible = "spi-nand";
|
||||
+ spi-max-frequency = <104000000>;
|
||||
+ reg = <0>;
|
||||
+
|
||||
+ partitions {
|
||||
+ compatible = "fixed-partitions";
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <1>;
|
||||
+
|
||||
+ partition@0 {
|
||||
+ label = "Bootloader";
|
||||
+ reg = <0x00000 0x0100000>;
|
||||
+ read-only;
|
||||
+ };
|
||||
+
|
||||
+ partition@100000 {
|
||||
+ label = "Config";
|
||||
+ reg = <0x100000 0x0040000>;
|
||||
+ };
|
||||
+
|
||||
+ partition@140000 {
|
||||
+ label = "factory";
|
||||
+ reg = <0x140000 0x0080000>;
|
||||
+ };
|
||||
+
|
||||
+ partition@1c0000 {
|
||||
+ label = "firmware";
|
||||
+ reg = <0x1c0000 0x1000000>;
|
||||
+ };
|
||||
+
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
&spi {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&spi_pins>;
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,27 @@
|
|||
--- a/drivers/crypto/inside-secure/safexcel.c
|
||||
+++ b/drivers/crypto/inside-secure/safexcel.c
|
||||
@@ -595,6 +595,14 @@ static int safexcel_hw_init(struct safex
|
||||
val |= EIP197_MST_CTRL_TX_MAX_CMD(5);
|
||||
writel(val, EIP197_HIA_AIC(priv) + EIP197_HIA_MST_CTRL);
|
||||
}
|
||||
+ /*
|
||||
+ * Set maximum number of TX commands to 2^4 = 16 for EIP97 HW2.1/HW2.3
|
||||
+ */
|
||||
+ else {
|
||||
+ val = 0;
|
||||
+ val |= EIP97_MST_CTRL_TX_MAX_CMD(4);
|
||||
+ writel(val, EIP197_HIA_AIC(priv) + EIP197_HIA_MST_CTRL);
|
||||
+ }
|
||||
|
||||
/* Configure wr/rd cache values */
|
||||
writel(EIP197_MST_CTRL_RD_CACHE(RD_CACHE_4BITS) |
|
||||
--- a/drivers/crypto/inside-secure/safexcel.h
|
||||
+++ b/drivers/crypto/inside-secure/safexcel.h
|
||||
@@ -306,6 +306,7 @@
|
||||
#define EIP197_MST_CTRL_RD_CACHE(n) (((n) & 0xf) << 0)
|
||||
#define EIP197_MST_CTRL_WD_CACHE(n) (((n) & 0xf) << 4)
|
||||
#define EIP197_MST_CTRL_TX_MAX_CMD(n) (((n) & 0xf) << 20)
|
||||
+#define EIP97_MST_CTRL_TX_MAX_CMD(n) (((n) & 0xf) << 4)
|
||||
#define EIP197_MST_CTRL_BYTE_SWAP BIT(24)
|
||||
#define EIP197_MST_CTRL_NO_BYTE_SWAP BIT(25)
|
||||
#define EIP197_MST_CTRL_BYTE_SWAP_BITS GENMASK(25, 24)
|
|
@ -0,0 +1,23 @@
|
|||
--- a/arch/arm/boot/dts/mt7623.dtsi
|
||||
+++ b/arch/arm/boot/dts/mt7623.dtsi
|
||||
@@ -1047,17 +1047,14 @@
|
||||
};
|
||||
|
||||
crypto: crypto@1b240000 {
|
||||
- compatible = "mediatek,eip97-crypto";
|
||||
+ compatible = "inside-secure,safexcel-eip97";
|
||||
reg = <0 0x1b240000 0 0x20000>;
|
||||
interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_LOW>,
|
||||
<GIC_SPI 83 IRQ_TYPE_LEVEL_LOW>,
|
||||
<GIC_SPI 84 IRQ_TYPE_LEVEL_LOW>,
|
||||
- <GIC_SPI 91 IRQ_TYPE_LEVEL_LOW>,
|
||||
- <GIC_SPI 97 IRQ_TYPE_LEVEL_LOW>;
|
||||
+ <GIC_SPI 91 IRQ_TYPE_LEVEL_LOW>;
|
||||
+ interrupt-names = "ring0", "ring1", "ring2", "ring3";
|
||||
clocks = <ðsys CLK_ETHSYS_CRYPTO>;
|
||||
- clock-names = "cryp";
|
||||
- power-domains = <&scpsys MT2701_POWER_DOMAIN_ETH>;
|
||||
- status = "disabled";
|
||||
};
|
||||
|
||||
bdpsys: syscon@1c000000 {
|
|
@ -0,0 +1,26 @@
|
|||
--- a/drivers/crypto/inside-secure/safexcel.h
|
||||
+++ b/drivers/crypto/inside-secure/safexcel.h
|
||||
@@ -722,6 +722,9 @@ enum safexcel_eip_version {
|
||||
/* Priority we use for advertising our algorithms */
|
||||
#define SAFEXCEL_CRA_PRIORITY 300
|
||||
|
||||
+/* System cache line size */
|
||||
+#define SYSTEM_CACHELINE_SIZE 64
|
||||
+
|
||||
/* SM3 digest result for zero length message */
|
||||
#define EIP197_SM3_ZEROM_HASH "\x1A\xB2\x1D\x83\x55\xCF\xA1\x7F" \
|
||||
"\x8E\x61\x19\x48\x31\xE8\x1A\x8F" \
|
||||
--- a/drivers/crypto/inside-secure/safexcel_hash.c
|
||||
+++ b/drivers/crypto/inside-secure/safexcel_hash.c
|
||||
@@ -57,9 +57,9 @@ struct safexcel_ahash_req {
|
||||
u8 block_sz; /* block size, only set once */
|
||||
u8 digest_sz; /* output digest size, only set once */
|
||||
__le32 state[SHA3_512_BLOCK_SIZE /
|
||||
- sizeof(__le32)] __aligned(sizeof(__le32));
|
||||
+ sizeof(__le32)] __aligned(SYSTEM_CACHELINE_SIZE);
|
||||
|
||||
- u64 len;
|
||||
+ u64 len __aligned(SYSTEM_CACHELINE_SIZE);
|
||||
u64 processed;
|
||||
|
||||
u8 cache[HASH_CACHE_SIZE] __aligned(sizeof(u32));
|
|
@ -0,0 +1,246 @@
|
|||
From: Russell King <rmk+kernel@armlinux.org.uk>
|
||||
Date: Wed, 26 Feb 2020 10:23:41 +0000
|
||||
Subject: [PATCH] net: phylink: propagate resolved link config via
|
||||
mac_link_up()
|
||||
|
||||
Propagate the resolved link parameters via the mac_link_up() call for
|
||||
MACs that do not automatically track their PCS state. We propagate the
|
||||
link parameters via function arguments so that inappropriate members
|
||||
of struct phylink_link_state can't be accessed, and creating a new
|
||||
structure just for this adds needless complexity to the API.
|
||||
|
||||
Tested-by: Andre Przywara <andre.przywara@arm.com>
|
||||
Tested-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
|
||||
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
|
||||
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
|
||||
--- a/Documentation/networking/sfp-phylink.rst
|
||||
+++ b/Documentation/networking/sfp-phylink.rst
|
||||
@@ -74,10 +74,13 @@ phylib to the sfp/phylink support. Plea
|
||||
this documentation.
|
||||
|
||||
1. Optionally split the network driver's phylib update function into
|
||||
- three parts dealing with link-down, link-up and reconfiguring the
|
||||
- MAC settings. This can be done as a separate preparation commit.
|
||||
+ two parts dealing with link-down and link-up. This can be done as
|
||||
+ a separate preparation commit.
|
||||
|
||||
- An example of this preparation can be found in git commit fc548b991fb0.
|
||||
+ An older example of this preparation can be found in git commit
|
||||
+ fc548b991fb0, although this was splitting into three parts; the
|
||||
+ link-up part now includes configuring the MAC for the link settings.
|
||||
+ Please see :c:func:`mac_link_up` for more information on this.
|
||||
|
||||
2. Replace::
|
||||
|
||||
@@ -207,6 +210,14 @@ this documentation.
|
||||
using. This is particularly important for in-band negotiation
|
||||
methods such as 1000base-X and SGMII.
|
||||
|
||||
+ The :c:func:`mac_link_up` method is used to inform the MAC that the
|
||||
+ link has come up. The call includes the negotiation mode and interface
|
||||
+ for reference only. The finalised link parameters are also supplied
|
||||
+ (speed, duplex and flow control/pause enablement settings) which
|
||||
+ should be used to configure the MAC when the MAC and PCS are not
|
||||
+ tightly integrated, or when the settings are not coming from in-band
|
||||
+ negotiation.
|
||||
+
|
||||
The :c:func:`mac_config` method is used to update the MAC with the
|
||||
requested state, and must avoid unnecessarily taking the link down
|
||||
when making changes to the MAC configuration. This means the
|
||||
--- a/drivers/net/ethernet/marvell/mvneta.c
|
||||
+++ b/drivers/net/ethernet/marvell/mvneta.c
|
||||
@@ -3655,9 +3655,11 @@ static void mvneta_mac_link_down(struct
|
||||
mvneta_set_eee(pp, false);
|
||||
}
|
||||
|
||||
-static void mvneta_mac_link_up(struct phylink_config *config, unsigned int mode,
|
||||
- phy_interface_t interface,
|
||||
- struct phy_device *phy)
|
||||
+static void mvneta_mac_link_up(struct phylink_config *config,
|
||||
+ struct phy_device *phy,
|
||||
+ unsigned int mode, phy_interface_t interface,
|
||||
+ int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause)
|
||||
{
|
||||
struct net_device *ndev = to_net_dev(config->dev);
|
||||
struct mvneta_port *pp = netdev_priv(ndev);
|
||||
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
|
||||
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
|
||||
@@ -58,8 +58,11 @@ static struct {
|
||||
*/
|
||||
static void mvpp2_mac_config(struct phylink_config *config, unsigned int mode,
|
||||
const struct phylink_link_state *state);
|
||||
-static void mvpp2_mac_link_up(struct phylink_config *config, unsigned int mode,
|
||||
- phy_interface_t interface, struct phy_device *phy);
|
||||
+static void mvpp2_mac_link_up(struct phylink_config *config,
|
||||
+ struct phy_device *phy,
|
||||
+ unsigned int mode, phy_interface_t interface,
|
||||
+ int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause);
|
||||
|
||||
/* Queue modes */
|
||||
#define MVPP2_QDIST_SINGLE_MODE 0
|
||||
@@ -3468,8 +3471,9 @@ static void mvpp2_start_dev(struct mvpp2
|
||||
.interface = port->phy_interface,
|
||||
};
|
||||
mvpp2_mac_config(&port->phylink_config, MLO_AN_INBAND, &state);
|
||||
- mvpp2_mac_link_up(&port->phylink_config, MLO_AN_INBAND,
|
||||
- port->phy_interface, NULL);
|
||||
+ mvpp2_mac_link_up(&port->phylink_config, NULL,
|
||||
+ MLO_AN_INBAND, port->phy_interface,
|
||||
+ SPEED_UNKNOWN, DUPLEX_UNKNOWN, false, false);
|
||||
}
|
||||
|
||||
netif_tx_start_all_queues(port->dev);
|
||||
@@ -5125,8 +5129,11 @@ static void mvpp2_mac_config(struct phyl
|
||||
mvpp2_port_enable(port);
|
||||
}
|
||||
|
||||
-static void mvpp2_mac_link_up(struct phylink_config *config, unsigned int mode,
|
||||
- phy_interface_t interface, struct phy_device *phy)
|
||||
+static void mvpp2_mac_link_up(struct phylink_config *config,
|
||||
+ struct phy_device *phy,
|
||||
+ unsigned int mode, phy_interface_t interface,
|
||||
+ int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause)
|
||||
{
|
||||
struct mvpp2_port *port = mvpp2_phylink_to_port(config);
|
||||
u32 val;
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
@@ -449,9 +449,10 @@ static void mtk_mac_link_down(struct phy
|
||||
mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id));
|
||||
}
|
||||
|
||||
-static void mtk_mac_link_up(struct phylink_config *config, unsigned int mode,
|
||||
- phy_interface_t interface,
|
||||
- struct phy_device *phy)
|
||||
+static void mtk_mac_link_up(struct phylink_config *config,
|
||||
+ struct phy_device *phy,
|
||||
+ unsigned int mode, phy_interface_t interface,
|
||||
+ int speed, int duplex, bool tx_pause, bool rx_pause)
|
||||
{
|
||||
struct mtk_mac *mac = container_of(config, struct mtk_mac,
|
||||
phylink_config);
|
||||
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
|
||||
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
|
||||
@@ -925,8 +925,10 @@ static void stmmac_mac_link_down(struct
|
||||
}
|
||||
|
||||
static void stmmac_mac_link_up(struct phylink_config *config,
|
||||
+ struct phy_device *phy,
|
||||
unsigned int mode, phy_interface_t interface,
|
||||
- struct phy_device *phy)
|
||||
+ int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause)
|
||||
{
|
||||
struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
|
||||
|
||||
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
|
||||
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
|
||||
@@ -1501,9 +1501,10 @@ static void axienet_mac_link_down(struct
|
||||
}
|
||||
|
||||
static void axienet_mac_link_up(struct phylink_config *config,
|
||||
- unsigned int mode,
|
||||
- phy_interface_t interface,
|
||||
- struct phy_device *phy)
|
||||
+ struct phy_device *phy,
|
||||
+ unsigned int mode, phy_interface_t interface,
|
||||
+ int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause)
|
||||
{
|
||||
/* nothing meaningful to do */
|
||||
}
|
||||
--- a/drivers/net/phy/phylink.c
|
||||
+++ b/drivers/net/phy/phylink.c
|
||||
@@ -447,8 +447,11 @@ static void phylink_mac_link_up(struct p
|
||||
struct net_device *ndev = pl->netdev;
|
||||
|
||||
pl->cur_interface = link_state.interface;
|
||||
- pl->ops->mac_link_up(pl->config, pl->cur_link_an_mode,
|
||||
- pl->cur_interface, pl->phydev);
|
||||
+ pl->ops->mac_link_up(pl->config, pl->phydev,
|
||||
+ pl->cur_link_an_mode, pl->cur_interface,
|
||||
+ link_state.speed, link_state.duplex,
|
||||
+ !!(link_state.pause & MLO_PAUSE_TX),
|
||||
+ !!(link_state.pause & MLO_PAUSE_RX));
|
||||
|
||||
if (ndev)
|
||||
netif_carrier_on(ndev);
|
||||
--- a/include/linux/phylink.h
|
||||
+++ b/include/linux/phylink.h
|
||||
@@ -91,9 +91,10 @@ struct phylink_mac_ops {
|
||||
void (*mac_an_restart)(struct phylink_config *config);
|
||||
void (*mac_link_down)(struct phylink_config *config, unsigned int mode,
|
||||
phy_interface_t interface);
|
||||
- void (*mac_link_up)(struct phylink_config *config, unsigned int mode,
|
||||
- phy_interface_t interface,
|
||||
- struct phy_device *phy);
|
||||
+ void (*mac_link_up)(struct phylink_config *config,
|
||||
+ struct phy_device *phy, unsigned int mode,
|
||||
+ phy_interface_t interface, int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause);
|
||||
};
|
||||
|
||||
#if 0 /* For kernel-doc purposes only. */
|
||||
@@ -217,19 +218,34 @@ void mac_link_down(struct phylink_config
|
||||
/**
|
||||
* mac_link_up() - allow the link to come up
|
||||
* @config: a pointer to a &struct phylink_config.
|
||||
+ * @phy: any attached phy
|
||||
* @mode: link autonegotiation mode
|
||||
* @interface: link &typedef phy_interface_t mode
|
||||
- * @phy: any attached phy
|
||||
+ * @speed: link speed
|
||||
+ * @duplex: link duplex
|
||||
+ * @tx_pause: link transmit pause enablement status
|
||||
+ * @rx_pause: link receive pause enablement status
|
||||
+ *
|
||||
+ * Configure the MAC for an established link.
|
||||
+ *
|
||||
+ * @speed, @duplex, @tx_pause and @rx_pause indicate the finalised link
|
||||
+ * settings, and should be used to configure the MAC block appropriately
|
||||
+ * where these settings are not automatically conveyed from the PCS block,
|
||||
+ * or if in-band negotiation (as defined by phylink_autoneg_inband(@mode))
|
||||
+ * is disabled.
|
||||
+ *
|
||||
+ * Note that when 802.3z in-band negotiation is in use, it is possible
|
||||
+ * that the user wishes to override the pause settings, and this should
|
||||
+ * be allowed when considering the implementation of this method.
|
||||
*
|
||||
- * If @mode is not an in-band negotiation mode (as defined by
|
||||
- * phylink_autoneg_inband()), allow the link to come up. If @phy
|
||||
- * is non-%NULL, configure Energy Efficient Ethernet by calling
|
||||
+ * If in-band negotiation mode is disabled, allow the link to come up. If
|
||||
+ * @phy is non-%NULL, configure Energy Efficient Ethernet by calling
|
||||
* phy_init_eee() and perform appropriate MAC configuration for EEE.
|
||||
* Interface type selection must be done in mac_config().
|
||||
*/
|
||||
-void mac_link_up(struct phylink_config *config, unsigned int mode,
|
||||
- phy_interface_t interface,
|
||||
- struct phy_device *phy);
|
||||
+void mac_link_up(struct phylink_config *config, struct phy_device *phy,
|
||||
+ unsigned int mode, phy_interface_t interface,
|
||||
+ int speed, int duplex, bool tx_pause, bool rx_pause);
|
||||
#endif
|
||||
|
||||
struct phylink *phylink_create(struct phylink_config *, struct fwnode_handle *,
|
||||
--- a/net/dsa/port.c
|
||||
+++ b/net/dsa/port.c
|
||||
@@ -529,9 +529,11 @@ void dsa_port_phylink_mac_link_down(stru
|
||||
EXPORT_SYMBOL_GPL(dsa_port_phylink_mac_link_down);
|
||||
|
||||
void dsa_port_phylink_mac_link_up(struct phylink_config *config,
|
||||
+ struct phy_device *phydev,
|
||||
unsigned int mode,
|
||||
phy_interface_t interface,
|
||||
- struct phy_device *phydev)
|
||||
+ int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause)
|
||||
{
|
||||
struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
|
||||
struct dsa_switch *ds = dp->ds;
|
|
@ -0,0 +1,143 @@
|
|||
From: Russell King <rmk+kernel@armlinux.org.uk>
|
||||
Date: Wed, 26 Feb 2020 10:23:46 +0000
|
||||
Subject: [PATCH] net: dsa: propagate resolved link config via mac_link_up()
|
||||
|
||||
Propagate the resolved link configuration down via DSA's
|
||||
phylink_mac_link_up() operation to allow split PCS/MAC to work.
|
||||
|
||||
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
|
||||
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
|
||||
--- a/drivers/net/dsa/b53/b53_common.c
|
||||
+++ b/drivers/net/dsa/b53/b53_common.c
|
||||
@@ -1284,7 +1284,9 @@ EXPORT_SYMBOL(b53_phylink_mac_link_down)
|
||||
void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,
|
||||
unsigned int mode,
|
||||
phy_interface_t interface,
|
||||
- struct phy_device *phydev)
|
||||
+ struct phy_device *phydev,
|
||||
+ int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause)
|
||||
{
|
||||
struct b53_device *dev = ds->priv;
|
||||
|
||||
--- a/drivers/net/dsa/b53/b53_priv.h
|
||||
+++ b/drivers/net/dsa/b53/b53_priv.h
|
||||
@@ -337,7 +337,9 @@ void b53_phylink_mac_link_down(struct ds
|
||||
void b53_phylink_mac_link_up(struct dsa_switch *ds, int port,
|
||||
unsigned int mode,
|
||||
phy_interface_t interface,
|
||||
- struct phy_device *phydev);
|
||||
+ struct phy_device *phydev,
|
||||
+ int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause);
|
||||
int b53_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering);
|
||||
int b53_vlan_prepare(struct dsa_switch *ds, int port,
|
||||
const struct switchdev_obj_port_vlan *vlan);
|
||||
--- a/drivers/net/dsa/bcm_sf2.c
|
||||
+++ b/drivers/net/dsa/bcm_sf2.c
|
||||
@@ -636,7 +636,9 @@ static void bcm_sf2_sw_mac_link_down(str
|
||||
static void bcm_sf2_sw_mac_link_up(struct dsa_switch *ds, int port,
|
||||
unsigned int mode,
|
||||
phy_interface_t interface,
|
||||
- struct phy_device *phydev)
|
||||
+ struct phy_device *phydev,
|
||||
+ int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause)
|
||||
{
|
||||
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
|
||||
struct ethtool_eee *p = &priv->dev->ports[port].eee;
|
||||
--- a/drivers/net/dsa/lantiq_gswip.c
|
||||
+++ b/drivers/net/dsa/lantiq_gswip.c
|
||||
@@ -1664,7 +1664,9 @@ static void gswip_phylink_mac_link_down(
|
||||
static void gswip_phylink_mac_link_up(struct dsa_switch *ds, int port,
|
||||
unsigned int mode,
|
||||
phy_interface_t interface,
|
||||
- struct phy_device *phydev)
|
||||
+ struct phy_device *phydev,
|
||||
+ int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause)
|
||||
{
|
||||
struct gswip_priv *priv = ds->priv;
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -1440,7 +1440,9 @@ static void mt7530_phylink_mac_link_down
|
||||
static void mt7530_phylink_mac_link_up(struct dsa_switch *ds, int port,
|
||||
unsigned int mode,
|
||||
phy_interface_t interface,
|
||||
- struct phy_device *phydev)
|
||||
+ struct phy_device *phydev,
|
||||
+ int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause)
|
||||
{
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
|
||||
--- a/drivers/net/dsa/mv88e6xxx/chip.c
|
||||
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
|
||||
@@ -652,7 +652,9 @@ static void mv88e6xxx_mac_link_down(stru
|
||||
|
||||
static void mv88e6xxx_mac_link_up(struct dsa_switch *ds, int port,
|
||||
unsigned int mode, phy_interface_t interface,
|
||||
- struct phy_device *phydev)
|
||||
+ struct phy_device *phydev,
|
||||
+ int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause)
|
||||
{
|
||||
if (mode == MLO_AN_FIXED)
|
||||
mv88e6xxx_mac_link_force(ds, port, LINK_FORCED_UP);
|
||||
--- a/drivers/net/dsa/sja1105/sja1105_main.c
|
||||
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
|
||||
@@ -831,7 +831,9 @@ static void sja1105_mac_link_down(struct
|
||||
static void sja1105_mac_link_up(struct dsa_switch *ds, int port,
|
||||
unsigned int mode,
|
||||
phy_interface_t interface,
|
||||
- struct phy_device *phydev)
|
||||
+ struct phy_device *phydev,
|
||||
+ int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause)
|
||||
{
|
||||
sja1105_inhibit_tx(ds->priv, BIT(port), false);
|
||||
}
|
||||
--- a/include/net/dsa.h
|
||||
+++ b/include/net/dsa.h
|
||||
@@ -406,7 +406,9 @@ struct dsa_switch_ops {
|
||||
void (*phylink_mac_link_up)(struct dsa_switch *ds, int port,
|
||||
unsigned int mode,
|
||||
phy_interface_t interface,
|
||||
- struct phy_device *phydev);
|
||||
+ struct phy_device *phydev,
|
||||
+ int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause);
|
||||
void (*phylink_fixed_state)(struct dsa_switch *ds, int port,
|
||||
struct phylink_link_state *state);
|
||||
/*
|
||||
--- a/net/dsa/port.c
|
||||
+++ b/net/dsa/port.c
|
||||
@@ -544,7 +544,8 @@ void dsa_port_phylink_mac_link_up(struct
|
||||
return;
|
||||
}
|
||||
|
||||
- ds->ops->phylink_mac_link_up(ds, dp->index, mode, interface, phydev);
|
||||
+ ds->ops->phylink_mac_link_up(ds, dp->index, mode, interface, phydev,
|
||||
+ speed, duplex, tx_pause, rx_pause);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dsa_port_phylink_mac_link_up);
|
||||
|
||||
--- a/net/dsa/dsa_priv.h
|
||||
+++ b/net/dsa/dsa_priv.h
|
||||
@@ -192,9 +192,11 @@ void dsa_port_phylink_mac_link_down(stru
|
||||
unsigned int mode,
|
||||
phy_interface_t interface);
|
||||
void dsa_port_phylink_mac_link_up(struct phylink_config *config,
|
||||
+ struct phy_device *phydev,
|
||||
unsigned int mode,
|
||||
phy_interface_t interface,
|
||||
- struct phy_device *phydev);
|
||||
+ int speed, int duplex,
|
||||
+ bool tx_pause, bool rx_pause);
|
||||
extern const struct phylink_mac_ops dsa_port_phylink_mac_ops;
|
||||
|
||||
/* slave.c */
|
|
@ -0,0 +1,145 @@
|
|||
From: =?UTF-8?q?Ren=C3=A9=20van=20Dorst?= <opensource@vdorst.com>
|
||||
Date: Fri, 27 Mar 2020 15:44:12 +0100
|
||||
Subject: [PATCH] net: dsa: mt7530: use resolved link config in mac_link_up()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Convert the mt7530 switch driver to use the finalised link
|
||||
parameters in mac_link_up() rather than the parameters in mac_config().
|
||||
|
||||
Signed-off-by: René van Dorst <opensource@vdorst.com>
|
||||
Tested-by: Sean Wang <sean.wang@mediatek.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -489,17 +489,6 @@ mt7530_mib_reset(struct dsa_switch *ds)
|
||||
mt7530_write(priv, MT7530_MIB_CCR, CCR_MIB_ACTIVATE);
|
||||
}
|
||||
|
||||
-static void
|
||||
-mt7530_port_set_status(struct mt7530_priv *priv, int port, int enable)
|
||||
-{
|
||||
- u32 mask = PMCR_TX_EN | PMCR_RX_EN | PMCR_FORCE_LNK;
|
||||
-
|
||||
- if (enable)
|
||||
- mt7530_set(priv, MT7530_PMCR_P(port), mask);
|
||||
- else
|
||||
- mt7530_clear(priv, MT7530_PMCR_P(port), mask);
|
||||
-}
|
||||
-
|
||||
static int mt7530_phy_read(struct dsa_switch *ds, int port, int regnum)
|
||||
{
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
@@ -673,7 +662,7 @@ mt7530_port_enable(struct dsa_switch *ds
|
||||
priv->ports[port].enable = true;
|
||||
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
|
||||
priv->ports[port].pm);
|
||||
- mt7530_port_set_status(priv, port, 0);
|
||||
+ mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
|
||||
|
||||
mutex_unlock(&priv->reg_mutex);
|
||||
|
||||
@@ -696,7 +685,7 @@ mt7530_port_disable(struct dsa_switch *d
|
||||
priv->ports[port].enable = false;
|
||||
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
|
||||
PCR_MATRIX_CLR);
|
||||
- mt7530_port_set_status(priv, port, 0);
|
||||
+ mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
|
||||
|
||||
mutex_unlock(&priv->reg_mutex);
|
||||
}
|
||||
@@ -1395,8 +1384,7 @@ static void mt7530_phylink_mac_config(st
|
||||
|
||||
mcr_cur = mt7530_read(priv, MT7530_PMCR_P(port));
|
||||
mcr_new = mcr_cur;
|
||||
- mcr_new &= ~(PMCR_FORCE_SPEED_1000 | PMCR_FORCE_SPEED_100 |
|
||||
- PMCR_FORCE_FDX | PMCR_TX_FC_EN | PMCR_RX_FC_EN);
|
||||
+ mcr_new &= ~PMCR_LINK_SETTINGS_MASK;
|
||||
mcr_new |= PMCR_IFG_XMIT(1) | PMCR_MAC_MODE | PMCR_BACKOFF_EN |
|
||||
PMCR_BACKPR_EN | PMCR_FORCE_MODE;
|
||||
|
||||
@@ -1404,26 +1392,6 @@ static void mt7530_phylink_mac_config(st
|
||||
if (port == 5 && dsa_is_user_port(ds, 5))
|
||||
mcr_new |= PMCR_EXT_PHY;
|
||||
|
||||
- switch (state->speed) {
|
||||
- case SPEED_1000:
|
||||
- mcr_new |= PMCR_FORCE_SPEED_1000;
|
||||
- if (priv->eee_enable & BIT(port))
|
||||
- mcr_new |= PMCR_FORCE_EEE1G;
|
||||
- break;
|
||||
- case SPEED_100:
|
||||
- mcr_new |= PMCR_FORCE_SPEED_100;
|
||||
- if (priv->eee_enable & BIT(port))
|
||||
- mcr_new |= PMCR_FORCE_EEE100;
|
||||
- break;
|
||||
- }
|
||||
- if (state->duplex == DUPLEX_FULL) {
|
||||
- mcr_new |= PMCR_FORCE_FDX;
|
||||
- if (state->pause & MLO_PAUSE_TX)
|
||||
- mcr_new |= PMCR_TX_FC_EN;
|
||||
- if (state->pause & MLO_PAUSE_RX)
|
||||
- mcr_new |= PMCR_RX_FC_EN;
|
||||
- }
|
||||
-
|
||||
if (mcr_new != mcr_cur)
|
||||
mt7530_write(priv, MT7530_PMCR_P(port), mcr_new);
|
||||
}
|
||||
@@ -1434,7 +1402,7 @@ static void mt7530_phylink_mac_link_down
|
||||
{
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
|
||||
- mt7530_port_set_status(priv, port, 0);
|
||||
+ mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
|
||||
}
|
||||
|
||||
static void mt7530_phylink_mac_link_up(struct dsa_switch *ds, int port,
|
||||
@@ -1445,8 +1413,31 @@ static void mt7530_phylink_mac_link_up(s
|
||||
bool tx_pause, bool rx_pause)
|
||||
{
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
+ u32 mcr;
|
||||
+
|
||||
+ mcr = PMCR_RX_EN | PMCR_TX_EN | PMCR_FORCE_LNK;
|
||||
+
|
||||
+ switch (speed) {
|
||||
+ case SPEED_1000:
|
||||
+ mcr |= PMCR_FORCE_SPEED_1000;
|
||||
+ if (priv->eee_enable & BIT(port))
|
||||
+ mcr_new |= PMCR_FORCE_EEE1G;
|
||||
+ break;
|
||||
+ case SPEED_100:
|
||||
+ mcr |= PMCR_FORCE_SPEED_100;
|
||||
+ if (priv->eee_enable & BIT(port))
|
||||
+ mcr_new |= PMCR_FORCE_EEE100;
|
||||
+ break;
|
||||
+ }
|
||||
+ if (duplex == DUPLEX_FULL) {
|
||||
+ mcr |= PMCR_FORCE_FDX;
|
||||
+ if (tx_pause)
|
||||
+ mcr |= PMCR_TX_FC_EN;
|
||||
+ if (rx_pause)
|
||||
+ mcr |= PMCR_RX_FC_EN;
|
||||
+ }
|
||||
|
||||
- mt7530_port_set_status(priv, port, 1);
|
||||
+ mt7530_set(priv, MT7530_PMCR_P(port), mcr);
|
||||
}
|
||||
|
||||
static void mt7530_phylink_validate(struct dsa_switch *ds, int port,
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -222,6 +222,10 @@ enum mt7530_vlan_port_attr {
|
||||
#define PMCR_FORCE_LNK BIT(0)
|
||||
#define PMCR_SPEED_MASK (PMCR_FORCE_SPEED_100 | \
|
||||
PMCR_FORCE_SPEED_1000)
|
||||
+#define PMCR_LINK_SETTINGS_MASK (PMCR_TX_EN | PMCR_FORCE_SPEED_1000 | \
|
||||
+ PMCR_RX_EN | PMCR_FORCE_SPEED_100 | \
|
||||
+ PMCR_TX_FC_EN | PMCR_RX_FC_EN | \
|
||||
+ PMCR_FORCE_FDX | PMCR_FORCE_LNK)
|
||||
|
||||
#define MT7530_PMSR_P(x) (0x3008 + (x) * 0x100)
|
||||
#define PMSR_EEE1G BIT(7)
|
|
@ -0,0 +1,458 @@
|
|||
From: Landen Chao <landen.chao@mediatek.com>
|
||||
Date: Fri, 4 Sep 2020 22:21:57 +0800
|
||||
Subject: [PATCH] net: dsa: mt7530: Extend device data ready for adding a
|
||||
new hardware
|
||||
|
||||
Add a structure holding required operations for each device such as device
|
||||
initialization, PHY port read or write, a checker whether PHY interface is
|
||||
supported on a certain port, MAC port setup for either bus pad or a
|
||||
specific PHY interface.
|
||||
|
||||
The patch is done for ready adding a new hardware MT7531, and keep the
|
||||
same setup logic of existing hardware.
|
||||
|
||||
Signed-off-by: Landen Chao <landen.chao@mediatek.com>
|
||||
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
|
||||
---
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -373,8 +373,9 @@ mt7530_fdb_write(struct mt7530_priv *pri
|
||||
mt7530_write(priv, MT7530_ATA1 + (i * 4), reg[i]);
|
||||
}
|
||||
|
||||
+/* Setup TX circuit including relevant PAD and driving */
|
||||
static int
|
||||
-mt7530_pad_clk_setup(struct dsa_switch *ds, int mode)
|
||||
+mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface)
|
||||
{
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
u32 ncpo1, ssc_delta, trgint, i, xtal;
|
||||
@@ -388,7 +389,7 @@ mt7530_pad_clk_setup(struct dsa_switch *
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
- switch (mode) {
|
||||
+ switch (interface) {
|
||||
case PHY_INTERFACE_MODE_RGMII:
|
||||
trgint = 0;
|
||||
/* PLL frequency: 125MHz */
|
||||
@@ -410,7 +411,8 @@ mt7530_pad_clk_setup(struct dsa_switch *
|
||||
}
|
||||
break;
|
||||
default:
|
||||
- dev_err(priv->dev, "xMII mode %d not supported\n", mode);
|
||||
+ dev_err(priv->dev, "xMII interface %d not supported\n",
|
||||
+ interface);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -1332,12 +1334,11 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static void mt7530_phylink_mac_config(struct dsa_switch *ds, int port,
|
||||
- unsigned int mode,
|
||||
- const struct phylink_link_state *state)
|
||||
+static bool
|
||||
+mt7530_phy_mode_supported(struct dsa_switch *ds, int port,
|
||||
+ const struct phylink_link_state *state)
|
||||
{
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
- u32 mcr_cur, mcr_new;
|
||||
|
||||
switch (port) {
|
||||
case 0: /* Internal phy */
|
||||
@@ -1346,33 +1347,114 @@ static void mt7530_phylink_mac_config(st
|
||||
case 3:
|
||||
case 4:
|
||||
if (state->interface != PHY_INTERFACE_MODE_GMII)
|
||||
- return;
|
||||
+ goto unsupported;
|
||||
break;
|
||||
case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */
|
||||
- if (priv->p5_interface == state->interface)
|
||||
- break;
|
||||
if (!phy_interface_mode_is_rgmii(state->interface) &&
|
||||
state->interface != PHY_INTERFACE_MODE_MII &&
|
||||
state->interface != PHY_INTERFACE_MODE_GMII)
|
||||
- return;
|
||||
+ goto unsupported;
|
||||
+ break;
|
||||
+ case 6: /* 1st cpu port */
|
||||
+ if (state->interface != PHY_INTERFACE_MODE_RGMII &&
|
||||
+ state->interface != PHY_INTERFACE_MODE_TRGMII)
|
||||
+ goto unsupported;
|
||||
+ break;
|
||||
+ default:
|
||||
+ dev_err(priv->dev, "%s: unsupported port: %i\n", __func__,
|
||||
+ port);
|
||||
+ goto unsupported;
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+
|
||||
+unsupported:
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static bool
|
||||
+mt753x_phy_mode_supported(struct dsa_switch *ds, int port,
|
||||
+ const struct phylink_link_state *state)
|
||||
+{
|
||||
+ struct mt7530_priv *priv = ds->priv;
|
||||
+
|
||||
+ return priv->info->phy_mode_supported(ds, port, state);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+mt753x_pad_setup(struct dsa_switch *ds, const struct phylink_link_state *state)
|
||||
+{
|
||||
+ struct mt7530_priv *priv = ds->priv;
|
||||
+
|
||||
+ return priv->info->pad_setup(ds, state->interface);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||
+ phy_interface_t interface)
|
||||
+{
|
||||
+ struct mt7530_priv *priv = ds->priv;
|
||||
+
|
||||
+ /* Only need to setup port5. */
|
||||
+ if (port != 5)
|
||||
+ return 0;
|
||||
+
|
||||
+ mt7530_setup_port5(priv->ds, interface);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+mt753x_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||
+ const struct phylink_link_state *state)
|
||||
+{
|
||||
+ struct mt7530_priv *priv = ds->priv;
|
||||
+
|
||||
+ return priv->info->mac_port_config(ds, port, mode, state->interface);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||
+ const struct phylink_link_state *state)
|
||||
+{
|
||||
+ struct mt7530_priv *priv = ds->priv;
|
||||
+ u32 mcr_cur, mcr_new;
|
||||
+
|
||||
+ if (!mt753x_phy_mode_supported(ds, port, state))
|
||||
+ goto unsupported;
|
||||
+
|
||||
+ switch (port) {
|
||||
+ case 0: /* Internal phy */
|
||||
+ case 1:
|
||||
+ case 2:
|
||||
+ case 3:
|
||||
+ case 4:
|
||||
+ if (state->interface != PHY_INTERFACE_MODE_GMII)
|
||||
+ goto unsupported;
|
||||
+ break;
|
||||
+ case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */
|
||||
+ if (priv->p5_interface == state->interface)
|
||||
+ break;
|
||||
+
|
||||
+ if (mt753x_mac_config(ds, port, mode, state) < 0)
|
||||
+ goto unsupported;
|
||||
|
||||
- mt7530_setup_port5(ds, state->interface);
|
||||
break;
|
||||
case 6: /* 1st cpu port */
|
||||
if (priv->p6_interface == state->interface)
|
||||
break;
|
||||
|
||||
- if (state->interface != PHY_INTERFACE_MODE_RGMII &&
|
||||
- state->interface != PHY_INTERFACE_MODE_TRGMII)
|
||||
- return;
|
||||
+ mt753x_pad_setup(ds, state);
|
||||
|
||||
- /* Setup TX circuit incluing relevant PAD and driving */
|
||||
- mt7530_pad_clk_setup(ds, state->interface);
|
||||
+ if (mt753x_mac_config(ds, port, mode, state) < 0)
|
||||
+ goto unsupported;
|
||||
|
||||
priv->p6_interface = state->interface;
|
||||
break;
|
||||
default:
|
||||
- dev_err(ds->dev, "%s: unsupported port: %i\n", __func__, port);
|
||||
+unsupported:
|
||||
+ dev_err(ds->dev, "%s: unsupported %s port: %i\n",
|
||||
+ __func__, phy_modes(state->interface), port);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1440,61 +1522,44 @@ static void mt7530_phylink_mac_link_up(s
|
||||
mt7530_set(priv, MT7530_PMCR_P(port), mcr);
|
||||
}
|
||||
|
||||
-static void mt7530_phylink_validate(struct dsa_switch *ds, int port,
|
||||
- unsigned long *supported,
|
||||
- struct phylink_link_state *state)
|
||||
+static void
|
||||
+mt7530_mac_port_validate(struct dsa_switch *ds, int port,
|
||||
+ unsigned long *supported)
|
||||
{
|
||||
+ if (port == 5)
|
||||
+ phylink_set(supported, 1000baseX_Full);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+mt753x_phylink_validate(struct dsa_switch *ds, int port,
|
||||
+ unsigned long *supported,
|
||||
+ struct phylink_link_state *state)
|
||||
+{
|
||||
+ struct mt7530_priv *priv = ds->priv;
|
||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
|
||||
|
||||
- switch (port) {
|
||||
- case 0: /* Internal phy */
|
||||
- case 1:
|
||||
- case 2:
|
||||
- case 3:
|
||||
- case 4:
|
||||
- if (state->interface != PHY_INTERFACE_MODE_NA &&
|
||||
- state->interface != PHY_INTERFACE_MODE_GMII)
|
||||
- goto unsupported;
|
||||
- break;
|
||||
- case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */
|
||||
- if (state->interface != PHY_INTERFACE_MODE_NA &&
|
||||
- !phy_interface_mode_is_rgmii(state->interface) &&
|
||||
- state->interface != PHY_INTERFACE_MODE_MII &&
|
||||
- state->interface != PHY_INTERFACE_MODE_GMII)
|
||||
- goto unsupported;
|
||||
- break;
|
||||
- case 6: /* 1st cpu port */
|
||||
- if (state->interface != PHY_INTERFACE_MODE_NA &&
|
||||
- state->interface != PHY_INTERFACE_MODE_RGMII &&
|
||||
- state->interface != PHY_INTERFACE_MODE_TRGMII)
|
||||
- goto unsupported;
|
||||
- break;
|
||||
- default:
|
||||
- dev_err(ds->dev, "%s: unsupported port: %i\n", __func__, port);
|
||||
-unsupported:
|
||||
+ if (state->interface != PHY_INTERFACE_MODE_NA &&
|
||||
+ !mt753x_phy_mode_supported(ds, port, state)) {
|
||||
linkmode_zero(supported);
|
||||
return;
|
||||
}
|
||||
|
||||
phylink_set_port_modes(mask);
|
||||
- phylink_set(mask, Autoneg);
|
||||
|
||||
- if (state->interface == PHY_INTERFACE_MODE_TRGMII) {
|
||||
- phylink_set(mask, 1000baseT_Full);
|
||||
- } else {
|
||||
+ if (state->interface != PHY_INTERFACE_MODE_TRGMII) {
|
||||
phylink_set(mask, 10baseT_Half);
|
||||
phylink_set(mask, 10baseT_Full);
|
||||
phylink_set(mask, 100baseT_Half);
|
||||
phylink_set(mask, 100baseT_Full);
|
||||
-
|
||||
- if (state->interface != PHY_INTERFACE_MODE_MII) {
|
||||
- /* This switch only supports 1G full-duplex. */
|
||||
- phylink_set(mask, 1000baseT_Full);
|
||||
- if (port == 5)
|
||||
- phylink_set(mask, 1000baseX_Full);
|
||||
- }
|
||||
+ phylink_set(mask, Autoneg);
|
||||
}
|
||||
|
||||
+ /* This switch only supports 1G full-duplex. */
|
||||
+ if (state->interface != PHY_INTERFACE_MODE_MII)
|
||||
+ phylink_set(mask, 1000baseT_Full);
|
||||
+
|
||||
+ priv->info->mac_port_validate(ds, port, mask);
|
||||
+
|
||||
phylink_set(mask, Pause);
|
||||
phylink_set(mask, Asym_Pause);
|
||||
|
||||
@@ -1590,12 +1655,45 @@ static int mt7530_set_mac_eee(struct dsa
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int
|
||||
+mt753x_phylink_mac_link_state(struct dsa_switch *ds, int port,
|
||||
+ struct phylink_link_state *state)
|
||||
+{
|
||||
+ struct mt7530_priv *priv = ds->priv;
|
||||
+
|
||||
+ return priv->info->mac_port_get_state(ds, port, state);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+mt753x_setup(struct dsa_switch *ds)
|
||||
+{
|
||||
+ struct mt7530_priv *priv = ds->priv;
|
||||
+
|
||||
+ return priv->info->sw_setup(ds);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+mt753x_phy_read(struct dsa_switch *ds, int port, int regnum)
|
||||
+{
|
||||
+ struct mt7530_priv *priv = ds->priv;
|
||||
+
|
||||
+ return priv->info->phy_read(ds, port, regnum);
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+mt753x_phy_write(struct dsa_switch *ds, int port, int regnum, u16 val)
|
||||
+{
|
||||
+ struct mt7530_priv *priv = ds->priv;
|
||||
+
|
||||
+ return priv->info->phy_write(ds, port, regnum, val);
|
||||
+}
|
||||
+
|
||||
static const struct dsa_switch_ops mt7530_switch_ops = {
|
||||
.get_tag_protocol = mtk_get_tag_protocol,
|
||||
- .setup = mt7530_setup,
|
||||
+ .setup = mt753x_setup,
|
||||
.get_strings = mt7530_get_strings,
|
||||
- .phy_read = mt7530_phy_read,
|
||||
- .phy_write = mt7530_phy_write,
|
||||
+ .phy_read = mt753x_phy_read,
|
||||
+ .phy_write = mt753x_phy_write,
|
||||
.get_ethtool_stats = mt7530_get_ethtool_stats,
|
||||
.get_sset_count = mt7530_get_sset_count,
|
||||
.port_enable = mt7530_port_enable,
|
||||
@@ -1612,18 +1710,43 @@ static const struct dsa_switch_ops mt753
|
||||
.port_vlan_del = mt7530_port_vlan_del,
|
||||
.port_mirror_add = mt7530_port_mirror_add,
|
||||
.port_mirror_del = mt7530_port_mirror_del,
|
||||
- .phylink_validate = mt7530_phylink_validate,
|
||||
- .phylink_mac_link_state = mt7530_phylink_mac_link_state,
|
||||
- .phylink_mac_config = mt7530_phylink_mac_config,
|
||||
+ .phylink_validate = mt753x_phylink_validate,
|
||||
+ .phylink_mac_link_state = mt753x_phylink_mac_link_state,
|
||||
+ .phylink_mac_config = mt753x_phylink_mac_config,
|
||||
.phylink_mac_link_down = mt7530_phylink_mac_link_down,
|
||||
.phylink_mac_link_up = mt7530_phylink_mac_link_up,
|
||||
.get_mac_eee = mt7530_get_mac_eee,
|
||||
.set_mac_eee = mt7530_set_mac_eee,
|
||||
};
|
||||
|
||||
+static const struct mt753x_info mt753x_table[] = {
|
||||
+ [ID_MT7621] = {
|
||||
+ .id = ID_MT7621,
|
||||
+ .sw_setup = mt7530_setup,
|
||||
+ .phy_read = mt7530_phy_read,
|
||||
+ .phy_write = mt7530_phy_write,
|
||||
+ .pad_setup = mt7530_pad_clk_setup,
|
||||
+ .phy_mode_supported = mt7530_phy_mode_supported,
|
||||
+ .mac_port_validate = mt7530_mac_port_validate,
|
||||
+ .mac_port_get_state = mt7530_phylink_mac_link_state,
|
||||
+ .mac_port_config = mt7530_mac_config,
|
||||
+ },
|
||||
+ [ID_MT7530] = {
|
||||
+ .id = ID_MT7530,
|
||||
+ .sw_setup = mt7530_setup,
|
||||
+ .phy_read = mt7530_phy_read,
|
||||
+ .phy_write = mt7530_phy_write,
|
||||
+ .pad_setup = mt7530_pad_clk_setup,
|
||||
+ .phy_mode_supported = mt7530_phy_mode_supported,
|
||||
+ .mac_port_validate = mt7530_mac_port_validate,
|
||||
+ .mac_port_get_state = mt7530_phylink_mac_link_state,
|
||||
+ .mac_port_config = mt7530_mac_config,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
static const struct of_device_id mt7530_of_match[] = {
|
||||
- { .compatible = "mediatek,mt7621", .data = (void *)ID_MT7621, },
|
||||
- { .compatible = "mediatek,mt7530", .data = (void *)ID_MT7530, },
|
||||
+ { .compatible = "mediatek,mt7621", .data = &mt753x_table[ID_MT7621], },
|
||||
+ { .compatible = "mediatek,mt7530", .data = &mt753x_table[ID_MT7530], },
|
||||
{ /* sentinel */ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, mt7530_of_match);
|
||||
@@ -1661,8 +1784,21 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
/* Get the hardware identifier from the devicetree node.
|
||||
* We will need it for some of the clock and regulator setup.
|
||||
*/
|
||||
- priv->id = (unsigned int)(unsigned long)
|
||||
- of_device_get_match_data(&mdiodev->dev);
|
||||
+ priv->info = of_device_get_match_data(&mdiodev->dev);
|
||||
+ if (!priv->info)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ /* Sanity check if these required device operations are filled
|
||||
+ * properly.
|
||||
+ */
|
||||
+ if (!priv->info->sw_setup || !priv->info->pad_setup ||
|
||||
+ !priv->info->phy_read || !priv->info->phy_write ||
|
||||
+ !priv->info->phy_mode_supported ||
|
||||
+ !priv->info->mac_port_validate ||
|
||||
+ !priv->info->mac_port_get_state || !priv->info->mac_port_config)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ priv->id = priv->info->id;
|
||||
|
||||
if (priv->id == ID_MT7530) {
|
||||
priv->core_pwr = devm_regulator_get(&mdiodev->dev, "core");
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -11,7 +11,7 @@
|
||||
#define MT7530_NUM_FDB_RECORDS 2048
|
||||
#define MT7530_ALL_MEMBERS 0xff
|
||||
|
||||
-enum {
|
||||
+enum mt753x_id {
|
||||
ID_MT7530 = 0,
|
||||
ID_MT7621 = 1,
|
||||
};
|
||||
@@ -451,6 +451,40 @@ static const char *p5_intf_modes(unsigne
|
||||
}
|
||||
}
|
||||
|
||||
+/* struct mt753x_info - This is the main data structure for holding the specific
|
||||
+ * part for each supported device
|
||||
+ * @sw_setup: Holding the handler to a device initialization
|
||||
+ * @phy_read: Holding the way reading PHY port
|
||||
+ * @phy_write: Holding the way writing PHY port
|
||||
+ * @pad_setup: Holding the way setting up the bus pad for a certain
|
||||
+ * MAC port
|
||||
+ * @phy_mode_supported: Check if the PHY type is being supported on a certain
|
||||
+ * port
|
||||
+ * @mac_port_validate: Holding the way to set addition validate type for a
|
||||
+ * certan MAC port
|
||||
+ * @mac_port_get_state: Holding the way getting the MAC/PCS state for a certain
|
||||
+ * MAC port
|
||||
+ * @mac_port_config: Holding the way setting up the PHY attribute to a
|
||||
+ * certain MAC port
|
||||
+ */
|
||||
+struct mt753x_info {
|
||||
+ enum mt753x_id id;
|
||||
+
|
||||
+ int (*sw_setup)(struct dsa_switch *ds);
|
||||
+ int (*phy_read)(struct dsa_switch *ds, int port, int regnum);
|
||||
+ int (*phy_write)(struct dsa_switch *ds, int port, int regnum, u16 val);
|
||||
+ int (*pad_setup)(struct dsa_switch *ds, phy_interface_t interface);
|
||||
+ bool (*phy_mode_supported)(struct dsa_switch *ds, int port,
|
||||
+ const struct phylink_link_state *state);
|
||||
+ void (*mac_port_validate)(struct dsa_switch *ds, int port,
|
||||
+ unsigned long *supported);
|
||||
+ int (*mac_port_get_state)(struct dsa_switch *ds, int port,
|
||||
+ struct phylink_link_state *state);
|
||||
+ int (*mac_port_config)(struct dsa_switch *ds, int port,
|
||||
+ unsigned int mode,
|
||||
+ phy_interface_t interface);
|
||||
+};
|
||||
+
|
||||
/* struct mt7530_priv - This is the main data structure for holding the state
|
||||
* of the driver
|
||||
* @dev: The device pointer
|
||||
@@ -476,6 +510,7 @@ struct mt7530_priv {
|
||||
struct regulator *core_pwr;
|
||||
struct regulator *io_pwr;
|
||||
struct gpio_desc *reset;
|
||||
+ const struct mt753x_info *info;
|
||||
unsigned int id;
|
||||
bool mcm;
|
||||
phy_interface_t p6_interface;
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,33 @@
|
|||
--- a/drivers/tty/serial/8250/8250.h
|
||||
+++ b/drivers/tty/serial/8250/8250.h
|
||||
@@ -82,6 +82,7 @@ struct serial8250_config {
|
||||
#define UART_CAP_MINI (1 << 17) /* Mini UART on BCM283X family lacks:
|
||||
* STOP PARITY EPAR SPAR WLEN5 WLEN6
|
||||
*/
|
||||
+#define UART_CAP_NMOD (1 << 18) /* UART doesn't do termios */
|
||||
|
||||
#define UART_BUG_QUOT (1 << 0) /* UART has buggy quot LSB */
|
||||
#define UART_BUG_TXEN (1 << 1) /* UART has buggy TX IIR status */
|
||||
--- a/drivers/tty/serial/8250/8250_port.c
|
||||
+++ b/drivers/tty/serial/8250/8250_port.c
|
||||
@@ -291,7 +291,7 @@ static const struct serial8250_config ua
|
||||
.tx_loadsz = 16,
|
||||
.fcr = UART_FCR_ENABLE_FIFO |
|
||||
UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT,
|
||||
- .flags = UART_CAP_FIFO,
|
||||
+ .flags = UART_CAP_FIFO | UART_CAP_NMOD,
|
||||
},
|
||||
[PORT_NPCM] = {
|
||||
.name = "Nuvoton 16550",
|
||||
@@ -2598,6 +2598,11 @@ serial8250_do_set_termios(struct uart_po
|
||||
unsigned long flags;
|
||||
unsigned int baud, quot, frac = 0;
|
||||
|
||||
+ if (up->capabilities & UART_CAP_NMOD) {
|
||||
+ termios->c_cflag = 0;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
if (up->capabilities & UART_CAP_MINI) {
|
||||
termios->c_cflag &= ~(CSTOPB | PARENB | PARODD | CMSPAR);
|
||||
if ((termios->c_cflag & CSIZE) == CS5 ||
|
|
@ -0,0 +1,23 @@
|
|||
--- a/drivers/net/phy/Kconfig
|
||||
+++ b/drivers/net/phy/Kconfig
|
||||
@@ -42,6 +42,12 @@ config MDIO_BCM_IPROC
|
||||
This module provides a driver for the MDIO busses found in the
|
||||
Broadcom iProc SoC's.
|
||||
|
||||
+config RTL8367S_GSW
|
||||
+ tristate "rtl8367 Gigabit Switch support for mt7622"
|
||||
+ depends on NET_VENDOR_MEDIATEK
|
||||
+ help
|
||||
+ This driver supports rtl8367s in mt7622
|
||||
+
|
||||
config MDIO_BCM_UNIMAC
|
||||
tristate "Broadcom UniMAC MDIO bus controller"
|
||||
depends on HAS_IOMEM
|
||||
--- a/drivers/net/phy/Makefile
|
||||
+++ b/drivers/net/phy/Makefile
|
||||
@@ -110,4 +110,5 @@ obj-$(CONFIG_TERANETICS_PHY) += teraneti
|
||||
obj-$(CONFIG_VITESSE_PHY) += vitesse.o
|
||||
obj-$(CONFIG_XILINX_GMII2RGMII) += xilinx_gmii2rgmii.o
|
||||
obj-$(CONFIG_MT753X_GSW) += mtk/mt753x/
|
||||
+obj-$(CONFIG_RTL8367S_GSW) += rtk/
|
||||
|
|
@ -0,0 +1,415 @@
|
|||
From patchwork Thu May 28 06:16:45 2020
|
||||
Content-Type: text/plain; charset="utf-8"
|
||||
MIME-Version: 1.0
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Patchwork-Submitter: Chuanjia Liu <chuanjia.liu@mediatek.com>
|
||||
X-Patchwork-Id: 11574793
|
||||
Return-Path:
|
||||
<SRS0=ftSA=7K=lists.infradead.org=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@kernel.org>
|
||||
Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org
|
||||
[172.30.200.123])
|
||||
by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 391201392
|
||||
for <patchwork-linux-mediatek@patchwork.kernel.org>;
|
||||
Thu, 28 May 2020 06:20:27 +0000 (UTC)
|
||||
Received: from bombadil.infradead.org (bombadil.infradead.org
|
||||
[198.137.202.133])
|
||||
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
|
||||
(No client certificate requested)
|
||||
by mail.kernel.org (Postfix) with ESMTPS id 104F620657
|
||||
for <patchwork-linux-mediatek@patchwork.kernel.org>;
|
||||
Thu, 28 May 2020 06:20:27 +0000 (UTC)
|
||||
Authentication-Results: mail.kernel.org;
|
||||
dkim=pass (2048-bit key) header.d=lists.infradead.org
|
||||
header.i=@lists.infradead.org header.b="raZHaWxs";
|
||||
dkim=fail reason="signature verification failed" (1024-bit key)
|
||||
header.d=mediatek.com header.i=@mediatek.com header.b="YztrByG/"
|
||||
DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 104F620657
|
||||
Authentication-Results: mail.kernel.org;
|
||||
dmarc=fail (p=none dis=none) header.from=mediatek.com
|
||||
Authentication-Results: mail.kernel.org;
|
||||
spf=none
|
||||
smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org
|
||||
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
|
||||
d=lists.infradead.org; s=bombadil.20170209; h=Sender:
|
||||
Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:
|
||||
List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:
|
||||
Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:
|
||||
Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
|
||||
List-Owner; bh=aVtKU+Ey8KEM97+S66fz9ZMo+H8BP570jhAAvaRsNWc=; b=raZHaWxsfCxsrd
|
||||
Byn/w1oLN/J82ApnNdBBXixq9Qj0uXIU2tBVqkiQ9lG6QDk7uguxQSJLeTqrsI/uxQmCI/PGQtZdP
|
||||
sH0oboi2sbQSqJ/1ud4uL2pPaiLRJCxINF5oWjoZMsjn/b2fWvn52P6vTr/dxDTaabiVhY0HL0J+X
|
||||
7YGc1aYtO76HZHE2ke3puR42QkI8hE9E2cEhiLWeuUiLdUBegNM5MdYftu4nJTcCXnAeJjp/wIpYG
|
||||
7X737N9cmanDf6Bxr2bNPgaYzH+m7JK6eGxuAvWo0+PE9OX7MLrXY3KjixcjD/b0he0mfEM++gBAq
|
||||
KBYKl5wh1mnlR2WIWXew==;
|
||||
Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org)
|
||||
by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux))
|
||||
id 1jeBtx-0005JC-DJ; Thu, 28 May 2020 06:20:25 +0000
|
||||
Received: from mailgw01.mediatek.com ([216.200.240.184])
|
||||
by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux))
|
||||
id 1jeBtW-0002f2-75; Thu, 28 May 2020 06:20:01 +0000
|
||||
X-UUID: d5cb6d96c2a5421796c2f8a284ff3670-20200527
|
||||
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
|
||||
d=mediatek.com;
|
||||
s=dk;
|
||||
h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From;
|
||||
bh=EqjC+5cHgv6eykN7FPf2mtwK9UivJ3XSCE0jEvb8h+8=;
|
||||
b=YztrByG/Ia304l9KDPBwoHFYkFCN6qBXPqwZgg56CA9VitadAg2+K1VgfEU+oHqsqcsGAMdZTRMQh17tpm4bJParw6MMzAQ28te2TcxvQMV8PZMkerJdZyyYblI7ybauPWuofAQgQMtuwSKVii8eTRJbf99OZ9vDGJP3zo2j1wU=;
|
||||
X-UUID: d5cb6d96c2a5421796c2f8a284ff3670-20200527
|
||||
Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by
|
||||
mailgw01.mediatek.com
|
||||
(envelope-from <chuanjia.liu@mediatek.com>)
|
||||
(musrelay.mediatek.com ESMTP with TLS)
|
||||
with ESMTP id 681958707; Wed, 27 May 2020 22:20:16 -0800
|
||||
Received: from MTKMBS07N2.mediatek.inc (172.21.101.141) by
|
||||
MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id
|
||||
15.0.1497.2; Wed, 27 May 2020 23:18:52 -0700
|
||||
Received: from mtkcas07.mediatek.inc (172.21.101.84) by
|
||||
mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id
|
||||
15.0.1497.2; Thu, 28 May 2020 14:18:49 +0800
|
||||
Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc
|
||||
(172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend
|
||||
Transport; Thu, 28 May 2020 14:18:47 +0800
|
||||
From: <chuanjia.liu@mediatek.com>
|
||||
To: <robh+dt@kernel.org>, <ryder.lee@mediatek.com>, <matthias.bgg@gmail.com>
|
||||
Subject: [PATCH v2 1/4] dt-bindings: PCI: Mediatek: Update PCIe binding
|
||||
Date: Thu, 28 May 2020 14:16:45 +0800
|
||||
Message-ID: <20200528061648.32078-2-chuanjia.liu@mediatek.com>
|
||||
X-Mailer: git-send-email 2.18.0
|
||||
In-Reply-To: <20200528061648.32078-1-chuanjia.liu@mediatek.com>
|
||||
References: <20200528061648.32078-1-chuanjia.liu@mediatek.com>
|
||||
MIME-Version: 1.0
|
||||
X-MTK: N
|
||||
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
|
||||
X-CRM114-CacheID: sfid-20200527_231958_261064_608CC03E
|
||||
X-CRM114-Status: GOOD ( 13.95 )
|
||||
X-Spam-Score: -0.2 (/)
|
||||
X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary:
|
||||
Content analysis details: (-0.2 points)
|
||||
pts rule name description
|
||||
---- ----------------------
|
||||
--------------------------------------------------
|
||||
-0.0 SPF_PASS SPF: sender matches SPF record
|
||||
0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record
|
||||
0.0 MIME_BASE64_TEXT RAW: Message text disguised using base64
|
||||
encoding
|
||||
-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from
|
||||
author's domain
|
||||
0.1 DKIM_SIGNED Message has a DKIM or DK signature,
|
||||
not necessarily
|
||||
valid
|
||||
-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature
|
||||
-0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from
|
||||
envelope-from domain
|
||||
0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay
|
||||
lines
|
||||
X-BeenThere: linux-mediatek@lists.infradead.org
|
||||
X-Mailman-Version: 2.1.29
|
||||
Precedence: list
|
||||
List-Id: <linux-mediatek.lists.infradead.org>
|
||||
List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-mediatek>,
|
||||
<mailto:linux-mediatek-request@lists.infradead.org?subject=unsubscribe>
|
||||
List-Archive: <http://lists.infradead.org/pipermail/linux-mediatek/>
|
||||
List-Post: <mailto:linux-mediatek@lists.infradead.org>
|
||||
List-Help: <mailto:linux-mediatek-request@lists.infradead.org?subject=help>
|
||||
List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mediatek>,
|
||||
<mailto:linux-mediatek-request@lists.infradead.org?subject=subscribe>
|
||||
Cc: devicetree@vger.kernel.org, lorenzo.pieralisi@arm.com,
|
||||
srv_heupstream@mediatek.com, "chuanjia.liu" <Chuanjia.Liu@mediatek.com>,
|
||||
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
|
||||
jianjun.wang@mediatek.com, linux-mediatek@lists.infradead.org,
|
||||
yong.wu@mediatek.com, bhelgaas@google.com,
|
||||
linux-arm-kernel@lists.infradead.org, amurray@thegoodpenguin.co.uk
|
||||
Sender: "Linux-mediatek" <linux-mediatek-bounces@lists.infradead.org>
|
||||
Errors-To:
|
||||
linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org
|
||||
|
||||
From: "chuanjia.liu" <Chuanjia.Liu@mediatek.com>
|
||||
|
||||
There are two independent PCIe controllers in MT2712/MT7622 platform,
|
||||
and each of them should contain an independent MSI domain.
|
||||
|
||||
In current architecture, MSI domain will be inherited from the root
|
||||
bridge, and all of the devices will share the same MSI domain.
|
||||
Hence that, the PCIe devices will not work properly if the irq number
|
||||
which required is more than 32.
|
||||
|
||||
Split the PCIe node for MT2712/MT7622 platform to fix MSI issue and
|
||||
comply with the hardware design.
|
||||
|
||||
Signed-off-by: chuanjia.liu <Chuanjia.Liu@mediatek.com>
|
||||
---
|
||||
.../bindings/pci/mediatek-pcie-cfg.yaml | 38 +++++
|
||||
.../devicetree/bindings/pci/mediatek-pcie.txt | 144 +++++++++++-------
|
||||
2 files changed, 129 insertions(+), 53 deletions(-)
|
||||
create mode 100644 Documentation/devicetree/bindings/pci/mediatek-pcie-cfg.yaml
|
||||
|
||||
--- /dev/null
|
||||
+++ b/Documentation/devicetree/bindings/pci/mediatek-pcie-cfg.yaml
|
||||
@@ -0,0 +1,38 @@
|
||||
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
|
||||
+%YAML 1.2
|
||||
+---
|
||||
+$id: http://devicetree.org/schemas/pci/mediatek-pcie-cfg.yaml#
|
||||
+$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
+
|
||||
+title: Mediatek PCIECFG controller
|
||||
+
|
||||
+maintainers:
|
||||
+ - Chuanjia Liu <chuanjia.liu@mediatek.com>
|
||||
+ - Jianjun Wang <jianjun.wang@mediatek.com>
|
||||
+
|
||||
+description: |
|
||||
+ The MediaTek PCIECFG controller controls some feature about
|
||||
+ LTSSM, ASPM and so on.
|
||||
+
|
||||
+properties:
|
||||
+ compatible:
|
||||
+ items:
|
||||
+ - enum:
|
||||
+ - mediatek,mt7622-pciecfg
|
||||
+ - mediatek,mt7629-pciecfg
|
||||
+ - const: syscon
|
||||
+
|
||||
+ reg:
|
||||
+ maxItems: 1
|
||||
+
|
||||
+required:
|
||||
+ - compatible
|
||||
+ - reg
|
||||
+
|
||||
+examples:
|
||||
+ - |
|
||||
+ pciecfg: pciecfg@1a140000 {
|
||||
+ compatible = "mediatek,mt7622-pciecfg", "syscon";
|
||||
+ reg = <0 0x1a140000 0 0x1000>;
|
||||
+ };
|
||||
+...
|
||||
--- a/Documentation/devicetree/bindings/pci/mediatek-pcie.txt
|
||||
+++ b/Documentation/devicetree/bindings/pci/mediatek-pcie.txt
|
||||
@@ -8,7 +8,7 @@ Required properties:
|
||||
"mediatek,mt7623-pcie"
|
||||
"mediatek,mt7629-pcie"
|
||||
- device_type: Must be "pci"
|
||||
-- reg: Base addresses and lengths of the PCIe subsys and root ports.
|
||||
+- reg: Base addresses and lengths of the root ports.
|
||||
- reg-names: Names of the above areas to use during resource lookup.
|
||||
- #address-cells: Address representation for root ports (must be 3)
|
||||
- #size-cells: Size representation for root ports (must be 2)
|
||||
@@ -19,10 +19,10 @@ Required properties:
|
||||
- sys_ckN :transaction layer and data link layer clock
|
||||
Required entries for MT2701/MT7623:
|
||||
- free_ck :for reference clock of PCIe subsys
|
||||
- Required entries for MT2712/MT7622:
|
||||
+ Required entries for MT2712/MT7622/MT7629:
|
||||
- ahb_ckN :AHB slave interface operating clock for CSR access and RC
|
||||
initiated MMIO access
|
||||
- Required entries for MT7622:
|
||||
+ Required entries for MT7622/MT7629:
|
||||
- axi_ckN :application layer MMIO channel operating clock
|
||||
- aux_ckN :pe2_mac_bridge and pe2_mac_core operating clock when
|
||||
pcie_mac_ck/pcie_pipe_ck is turned off
|
||||
@@ -47,10 +47,13 @@ Required properties for MT7623/MT2701:
|
||||
- reset-names: Must be "pcie-rst0", "pcie-rst1", "pcie-rstN".. based on the
|
||||
number of root ports.
|
||||
|
||||
-Required properties for MT2712/MT7622:
|
||||
+Required properties for MT2712/MT7622/MT7629:
|
||||
-interrupts: A list of interrupt outputs of the controller, must have one
|
||||
entry for each PCIe port
|
||||
|
||||
+Required properties for MT7622/MT7629:
|
||||
+- mediatek,pcie-subsys: Should be a phandle of the pciecfg node.
|
||||
+
|
||||
In addition, the device tree node must have sub-nodes describing each
|
||||
PCIe port interface, having the following mandatory properties:
|
||||
|
||||
@@ -143,56 +146,73 @@ Examples for MT7623:
|
||||
|
||||
Examples for MT2712:
|
||||
|
||||
- pcie: pcie@11700000 {
|
||||
+ pcie1: pcie@112ff000 {
|
||||
compatible = "mediatek,mt2712-pcie";
|
||||
device_type = "pci";
|
||||
- reg = <0 0x11700000 0 0x1000>,
|
||||
- <0 0x112ff000 0 0x1000>;
|
||||
- reg-names = "port0", "port1";
|
||||
+ reg = <0 0x112ff000 0 0x1000>;
|
||||
+ reg-names = "port1";
|
||||
#address-cells = <3>;
|
||||
#size-cells = <2>;
|
||||
- interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH>,
|
||||
- <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>;
|
||||
- clocks = <&topckgen CLK_TOP_PE2_MAC_P0_SEL>,
|
||||
- <&topckgen CLK_TOP_PE2_MAC_P1_SEL>,
|
||||
- <&pericfg CLK_PERI_PCIE0>,
|
||||
+ interrupts = <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ interrupt-names = "pcie_irq";
|
||||
+ clocks = <&topckgen CLK_TOP_PE2_MAC_P1_SEL>,
|
||||
<&pericfg CLK_PERI_PCIE1>;
|
||||
- clock-names = "sys_ck0", "sys_ck1", "ahb_ck0", "ahb_ck1";
|
||||
- phys = <&pcie0_phy PHY_TYPE_PCIE>, <&pcie1_phy PHY_TYPE_PCIE>;
|
||||
- phy-names = "pcie-phy0", "pcie-phy1";
|
||||
+ clock-names = "sys_ck1", "ahb_ck1";
|
||||
+ phys = <&u3port1 PHY_TYPE_PCIE>;
|
||||
+ phy-names = "pcie-phy1";
|
||||
bus-range = <0x00 0xff>;
|
||||
- ranges = <0x82000000 0 0x20000000 0x0 0x20000000 0 0x10000000>;
|
||||
+ ranges = <0x82000000 0 0x11400000 0x0 0x11400000 0 0x300000>;
|
||||
+ status = "disabled";
|
||||
|
||||
- pcie0: pcie@0,0 {
|
||||
- reg = <0x0000 0 0 0 0>;
|
||||
+ slot1: pcie@1,0 {
|
||||
+ reg = <0x0800 0 0 0 0>;
|
||||
#address-cells = <3>;
|
||||
#size-cells = <2>;
|
||||
#interrupt-cells = <1>;
|
||||
ranges;
|
||||
interrupt-map-mask = <0 0 0 7>;
|
||||
- interrupt-map = <0 0 0 1 &pcie_intc0 0>,
|
||||
- <0 0 0 2 &pcie_intc0 1>,
|
||||
- <0 0 0 3 &pcie_intc0 2>,
|
||||
- <0 0 0 4 &pcie_intc0 3>;
|
||||
- pcie_intc0: interrupt-controller {
|
||||
+ interrupt-map = <0 0 0 1 &pcie_intc1 0>,
|
||||
+ <0 0 0 2 &pcie_intc1 1>,
|
||||
+ <0 0 0 3 &pcie_intc1 2>,
|
||||
+ <0 0 0 4 &pcie_intc1 3>;
|
||||
+ pcie_intc1: interrupt-controller {
|
||||
interrupt-controller;
|
||||
#address-cells = <0>;
|
||||
#interrupt-cells = <1>;
|
||||
};
|
||||
};
|
||||
+ };
|
||||
|
||||
- pcie1: pcie@1,0 {
|
||||
- reg = <0x0800 0 0 0 0>;
|
||||
+ pcie0: pcie@11700000 {
|
||||
+ compatible = "mediatek,mt2712-pcie";
|
||||
+ device_type = "pci";
|
||||
+ reg = <0 0x11700000 0 0x1000>;
|
||||
+ reg-names = "port0";
|
||||
+ #address-cells = <3>;
|
||||
+ #size-cells = <2>;
|
||||
+ interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ interrupt-names = "pcie_irq";
|
||||
+ clocks = <&topckgen CLK_TOP_PE2_MAC_P0_SEL>,
|
||||
+ <&pericfg CLK_PERI_PCIE0>;
|
||||
+ clock-names = "sys_ck0", "ahb_ck0";
|
||||
+ phys = <&u3port0 PHY_TYPE_PCIE>;
|
||||
+ phy-names = "pcie-phy0";
|
||||
+ bus-range = <0x00 0xff>;
|
||||
+ ranges = <0x82000000 0 0x20000000 0x0 0x20000000 0 0x10000000>;
|
||||
+ status = "disabled";
|
||||
+
|
||||
+ slot0: pcie@0,0 {
|
||||
+ reg = <0x0000 0 0 0 0>;
|
||||
#address-cells = <3>;
|
||||
#size-cells = <2>;
|
||||
#interrupt-cells = <1>;
|
||||
ranges;
|
||||
interrupt-map-mask = <0 0 0 7>;
|
||||
- interrupt-map = <0 0 0 1 &pcie_intc1 0>,
|
||||
- <0 0 0 2 &pcie_intc1 1>,
|
||||
- <0 0 0 3 &pcie_intc1 2>,
|
||||
- <0 0 0 4 &pcie_intc1 3>;
|
||||
- pcie_intc1: interrupt-controller {
|
||||
+ interrupt-map = <0 0 0 1 &pcie_intc0 0>,
|
||||
+ <0 0 0 2 &pcie_intc0 1>,
|
||||
+ <0 0 0 3 &pcie_intc0 2>,
|
||||
+ <0 0 0 4 &pcie_intc0 3>;
|
||||
+ pcie_intc0: interrupt-controller {
|
||||
interrupt-controller;
|
||||
#address-cells = <0>;
|
||||
#interrupt-cells = <1>;
|
||||
@@ -202,39 +222,31 @@ Examples for MT2712:
|
||||
|
||||
Examples for MT7622:
|
||||
|
||||
- pcie: pcie@1a140000 {
|
||||
+ pcie0: pcie@1a143000 {
|
||||
compatible = "mediatek,mt7622-pcie";
|
||||
device_type = "pci";
|
||||
- reg = <0 0x1a140000 0 0x1000>,
|
||||
- <0 0x1a143000 0 0x1000>,
|
||||
- <0 0x1a145000 0 0x1000>;
|
||||
- reg-names = "subsys", "port0", "port1";
|
||||
+ reg = <0 0x1a143000 0 0x1000>;
|
||||
+ reg-names = "port0";
|
||||
+ mediatek,pcie-cfg = <&pciecfg>;
|
||||
#address-cells = <3>;
|
||||
#size-cells = <2>;
|
||||
- interrupts = <GIC_SPI 228 IRQ_TYPE_LEVEL_LOW>,
|
||||
- <GIC_SPI 229 IRQ_TYPE_LEVEL_LOW>;
|
||||
+ interrupts = <GIC_SPI 228 IRQ_TYPE_LEVEL_LOW>;
|
||||
+ interrupt-names = "pcie_irq";
|
||||
clocks = <&pciesys CLK_PCIE_P0_MAC_EN>,
|
||||
- <&pciesys CLK_PCIE_P1_MAC_EN>,
|
||||
<&pciesys CLK_PCIE_P0_AHB_EN>,
|
||||
- <&pciesys CLK_PCIE_P1_AHB_EN>,
|
||||
<&pciesys CLK_PCIE_P0_AUX_EN>,
|
||||
- <&pciesys CLK_PCIE_P1_AUX_EN>,
|
||||
<&pciesys CLK_PCIE_P0_AXI_EN>,
|
||||
- <&pciesys CLK_PCIE_P1_AXI_EN>,
|
||||
<&pciesys CLK_PCIE_P0_OBFF_EN>,
|
||||
- <&pciesys CLK_PCIE_P1_OBFF_EN>,
|
||||
- <&pciesys CLK_PCIE_P0_PIPE_EN>,
|
||||
- <&pciesys CLK_PCIE_P1_PIPE_EN>;
|
||||
- clock-names = "sys_ck0", "sys_ck1", "ahb_ck0", "ahb_ck1",
|
||||
- "aux_ck0", "aux_ck1", "axi_ck0", "axi_ck1",
|
||||
- "obff_ck0", "obff_ck1", "pipe_ck0", "pipe_ck1";
|
||||
- phys = <&pcie0_phy PHY_TYPE_PCIE>, <&pcie1_phy PHY_TYPE_PCIE>;
|
||||
- phy-names = "pcie-phy0", "pcie-phy1";
|
||||
+ <&pciesys CLK_PCIE_P0_PIPE_EN>;
|
||||
+ clock-names = "sys_ck0", "ahb_ck0", "aux_ck0",
|
||||
+ "axi_ck0", "obff_ck0", "pipe_ck0";
|
||||
+
|
||||
power-domains = <&scpsys MT7622_POWER_DOMAIN_HIF0>;
|
||||
bus-range = <0x00 0xff>;
|
||||
- ranges = <0x82000000 0 0x20000000 0x0 0x20000000 0 0x10000000>;
|
||||
+ ranges = <0x82000000 0 0x20000000 0 0x20000000 0 0x8000000>;
|
||||
+ status = "disabled";
|
||||
|
||||
- pcie0: pcie@0,0 {
|
||||
+ slot0: pcie@0,0 {
|
||||
reg = <0x0000 0 0 0 0>;
|
||||
#address-cells = <3>;
|
||||
#size-cells = <2>;
|
||||
@@ -251,8 +263,34 @@ Examples for MT7622:
|
||||
#interrupt-cells = <1>;
|
||||
};
|
||||
};
|
||||
+ };
|
||||
+
|
||||
+ pcie1: pcie@1a145000 {
|
||||
+ compatible = "mediatek,mt7622-pcie";
|
||||
+ device_type = "pci";
|
||||
+ reg = <0 0x1a145000 0 0x1000>;
|
||||
+ reg-names = "port1";
|
||||
+ mediatek,pcie-cfg = <&pciecfg>;
|
||||
+ #address-cells = <3>;
|
||||
+ #size-cells = <2>;
|
||||
+ interrupts = <GIC_SPI 229 IRQ_TYPE_LEVEL_LOW>;
|
||||
+ interrupt-names = "pcie_irq";
|
||||
+ clocks = <&pciesys CLK_PCIE_P1_MAC_EN>,
|
||||
+ /* designer has connect RC1 with p0_ahb clock */
|
||||
+ <&pciesys CLK_PCIE_P0_AHB_EN>,
|
||||
+ <&pciesys CLK_PCIE_P1_AUX_EN>,
|
||||
+ <&pciesys CLK_PCIE_P1_AXI_EN>,
|
||||
+ <&pciesys CLK_PCIE_P1_OBFF_EN>,
|
||||
+ <&pciesys CLK_PCIE_P1_PIPE_EN>;
|
||||
+ clock-names = "sys_ck1", "ahb_ck1", "aux_ck1",
|
||||
+ "axi_ck1", "obff_ck1", "pipe_ck1";
|
||||
+
|
||||
+ power-domains = <&scpsys MT7622_POWER_DOMAIN_HIF0>;
|
||||
+ bus-range = <0x00 0xff>;
|
||||
+ ranges = <0x82000000 0 0x28000000 0 0x28000000 0 0x8000000>;
|
||||
+ status = "disabled";
|
||||
|
||||
- pcie1: pcie@1,0 {
|
||||
+ slot1: pcie@1,0 {
|
||||
reg = <0x0800 0 0 0 0>;
|
||||
#address-cells = <3>;
|
||||
#size-cells = <2>;
|
|
@ -0,0 +1,217 @@
|
|||
From patchwork Thu May 28 06:16:46 2020
|
||||
Content-Type: text/plain; charset="utf-8"
|
||||
MIME-Version: 1.0
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Patchwork-Submitter: Chuanjia Liu <chuanjia.liu@mediatek.com>
|
||||
X-Patchwork-Id: 11574781
|
||||
Return-Path:
|
||||
<SRS0=ftSA=7K=lists.infradead.org=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@kernel.org>
|
||||
Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org
|
||||
[172.30.200.123])
|
||||
by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A99B60D
|
||||
for <patchwork-linux-mediatek@patchwork.kernel.org>;
|
||||
Thu, 28 May 2020 06:19:04 +0000 (UTC)
|
||||
Received: from bombadil.infradead.org (bombadil.infradead.org
|
||||
[198.137.202.133])
|
||||
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
|
||||
(No client certificate requested)
|
||||
by mail.kernel.org (Postfix) with ESMTPS id DCC99208FE
|
||||
for <patchwork-linux-mediatek@patchwork.kernel.org>;
|
||||
Thu, 28 May 2020 06:19:03 +0000 (UTC)
|
||||
Authentication-Results: mail.kernel.org;
|
||||
dkim=pass (2048-bit key) header.d=lists.infradead.org
|
||||
header.i=@lists.infradead.org header.b="SpOi0ueF";
|
||||
dkim=fail reason="signature verification failed" (1024-bit key)
|
||||
header.d=mediatek.com header.i=@mediatek.com header.b="UGIBoIEG"
|
||||
DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCC99208FE
|
||||
Authentication-Results: mail.kernel.org;
|
||||
dmarc=fail (p=none dis=none) header.from=mediatek.com
|
||||
Authentication-Results: mail.kernel.org;
|
||||
spf=none
|
||||
smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org
|
||||
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
|
||||
d=lists.infradead.org; s=bombadil.20170209; h=Sender:
|
||||
Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:
|
||||
List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:
|
||||
Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:
|
||||
Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
|
||||
List-Owner; bh=LIr5poLUT/UdH6/akh/pnICGGa3rUBkN+4FhE1DyOrU=; b=SpOi0ueFcoJ/ka
|
||||
4esa6cDd5oU4fp0z684ZVPaVvvhm/azSZBBMYinHaAW6EvzKcMNYIX9grP8eg/728lEPNTKVq0I8H
|
||||
PQZ9KvD4uTu8Opo1hD8LsRSLr+YLpNKt3KPOY/4gpwQ97uU9rI5PwkuAxPBgR949Vh5EiG0Vaww1H
|
||||
Ep+I5BFRn2LVVQZP1Z7U0A0VUcOTLJ4znoWRLEXxtM9/Wd4hwQsrEPQszeDFti/RbwGfJ5efOb5UL
|
||||
fhwBzSxELEzAAgH7env/XD2sSSpVf2Qsn6WO8D3ZepMtWrRtARiaRKSNxSBQTg2SSHcjmBSJSzcX+
|
||||
w8wqWaUMs0crlBuZWS1g==;
|
||||
Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org)
|
||||
by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux))
|
||||
id 1jeBsc-0001tI-88; Thu, 28 May 2020 06:19:02 +0000
|
||||
Received: from mailgw01.mediatek.com ([216.200.240.184])
|
||||
by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux))
|
||||
id 1jeBsZ-0001rp-6g; Thu, 28 May 2020 06:19:01 +0000
|
||||
X-UUID: beeaf5765357439c91eab1f67ca7ef43-20200527
|
||||
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
|
||||
d=mediatek.com;
|
||||
s=dk;
|
||||
h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From;
|
||||
bh=+IjWjsF/DhknqZB+lLSZ50cyvxDap+8w4tvqhp8Dv68=;
|
||||
b=UGIBoIEGJUuq5pEvYEad1HVGpiv6yma+94hva83D2gD8lYmihRWkpJxB2yn+dVtNm7ZXXoQBf+jvvULOmslJgs1HZTLJTnjpdvLmQqo42OXRXSVpTE49HdRkJZDAIWIAReBfOEkFgNxcIX3uedrtnww/NLJ2lagrYPG5ET4lI2E=;
|
||||
X-UUID: beeaf5765357439c91eab1f67ca7ef43-20200527
|
||||
Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw01.mediatek.com
|
||||
(envelope-from <chuanjia.liu@mediatek.com>)
|
||||
(musrelay.mediatek.com ESMTP with TLS)
|
||||
with ESMTP id 603406343; Wed, 27 May 2020 22:19:17 -0800
|
||||
Received: from mtkmbs07n1.mediatek.inc (172.21.101.16) by
|
||||
MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id
|
||||
15.0.1497.2; Wed, 27 May 2020 23:18:47 -0700
|
||||
Received: from mtkcas07.mediatek.inc (172.21.101.84) by
|
||||
mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id
|
||||
15.0.1497.2; Thu, 28 May 2020 14:18:51 +0800
|
||||
Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc
|
||||
(172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend
|
||||
Transport; Thu, 28 May 2020 14:18:49 +0800
|
||||
From: <chuanjia.liu@mediatek.com>
|
||||
To: <robh+dt@kernel.org>, <ryder.lee@mediatek.com>, <matthias.bgg@gmail.com>
|
||||
Subject: [PATCH v2 2/4] PCI: mediatek: Use regmap to get shared pcie-cfg base
|
||||
Date: Thu, 28 May 2020 14:16:46 +0800
|
||||
Message-ID: <20200528061648.32078-3-chuanjia.liu@mediatek.com>
|
||||
X-Mailer: git-send-email 2.18.0
|
||||
In-Reply-To: <20200528061648.32078-1-chuanjia.liu@mediatek.com>
|
||||
References: <20200528061648.32078-1-chuanjia.liu@mediatek.com>
|
||||
MIME-Version: 1.0
|
||||
X-MTK: N
|
||||
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
|
||||
X-CRM114-CacheID: sfid-20200527_231859_251275_BED2B1E2
|
||||
X-CRM114-Status: GOOD ( 11.62 )
|
||||
X-Spam-Score: -0.2 (/)
|
||||
X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary:
|
||||
Content analysis details: (-0.2 points)
|
||||
pts rule name description
|
||||
---- ----------------------
|
||||
--------------------------------------------------
|
||||
-0.0 SPF_PASS SPF: sender matches SPF record
|
||||
0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record
|
||||
0.0 MIME_BASE64_TEXT RAW: Message text disguised using base64
|
||||
encoding
|
||||
-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from
|
||||
author's domain
|
||||
0.1 DKIM_SIGNED Message has a DKIM or DK signature,
|
||||
not necessarily
|
||||
valid
|
||||
-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature
|
||||
-0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from
|
||||
envelope-from domain
|
||||
0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay
|
||||
lines
|
||||
X-BeenThere: linux-mediatek@lists.infradead.org
|
||||
X-Mailman-Version: 2.1.29
|
||||
Precedence: list
|
||||
List-Id: <linux-mediatek.lists.infradead.org>
|
||||
List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-mediatek>,
|
||||
<mailto:linux-mediatek-request@lists.infradead.org?subject=unsubscribe>
|
||||
List-Archive: <http://lists.infradead.org/pipermail/linux-mediatek/>
|
||||
List-Post: <mailto:linux-mediatek@lists.infradead.org>
|
||||
List-Help: <mailto:linux-mediatek-request@lists.infradead.org?subject=help>
|
||||
List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mediatek>,
|
||||
<mailto:linux-mediatek-request@lists.infradead.org?subject=subscribe>
|
||||
Cc: devicetree@vger.kernel.org, lorenzo.pieralisi@arm.com,
|
||||
srv_heupstream@mediatek.com, "chuanjia.liu" <Chuanjia.Liu@mediatek.com>,
|
||||
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
|
||||
jianjun.wang@mediatek.com, linux-mediatek@lists.infradead.org,
|
||||
yong.wu@mediatek.com, bhelgaas@google.com,
|
||||
linux-arm-kernel@lists.infradead.org, amurray@thegoodpenguin.co.uk
|
||||
Sender: "Linux-mediatek" <linux-mediatek-bounces@lists.infradead.org>
|
||||
Errors-To:
|
||||
linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org
|
||||
|
||||
From: "chuanjia.liu" <Chuanjia.Liu@mediatek.com>
|
||||
|
||||
Use regmap to get shared pcie-cfg base and change
|
||||
the method to get pcie irq.
|
||||
|
||||
Signed-off-by: chuanjia.liu <Chuanjia.Liu@mediatek.com>
|
||||
---
|
||||
drivers/pci/controller/pcie-mediatek.c | 25 ++++++++++++++++++-------
|
||||
1 file changed, 18 insertions(+), 7 deletions(-)
|
||||
|
||||
--- a/drivers/pci/controller/pcie-mediatek.c
|
||||
+++ b/drivers/pci/controller/pcie-mediatek.c
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <linux/irqchip/chained_irq.h>
|
||||
#include <linux/irqdomain.h>
|
||||
#include <linux/kernel.h>
|
||||
+#include <linux/mfd/syscon.h>
|
||||
#include <linux/msi.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of_address.h>
|
||||
@@ -23,6 +24,7 @@
|
||||
#include <linux/phy/phy.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
+#include <linux/regmap.h>
|
||||
#include <linux/reset.h>
|
||||
|
||||
#include "../pci.h"
|
||||
@@ -205,6 +207,7 @@ struct mtk_pcie_port {
|
||||
* struct mtk_pcie - PCIe host information
|
||||
* @dev: pointer to PCIe device
|
||||
* @base: IO mapped register base
|
||||
+ * @cfg: IO mapped register map for PCIe config
|
||||
* @free_ck: free-run reference clock
|
||||
* @mem: non-prefetchable memory resource
|
||||
* @ports: pointer to PCIe port information
|
||||
@@ -214,6 +217,7 @@ struct mtk_pcie_port {
|
||||
struct mtk_pcie {
|
||||
struct device *dev;
|
||||
void __iomem *base;
|
||||
+ struct regmap *cfg;
|
||||
struct clk *free_ck;
|
||||
|
||||
struct resource mem;
|
||||
@@ -651,7 +655,7 @@ static int mtk_pcie_setup_irq(struct mtk
|
||||
return err;
|
||||
}
|
||||
|
||||
- port->irq = platform_get_irq(pdev, port->slot);
|
||||
+ port->irq = platform_get_irq_byname(pdev, "pcie_irq");
|
||||
irq_set_chained_handler_and_data(port->irq,
|
||||
mtk_pcie_intr_handler, port);
|
||||
|
||||
@@ -666,12 +670,11 @@ static int mtk_pcie_startup_port_v2(stru
|
||||
u32 val;
|
||||
int err;
|
||||
|
||||
- /* MT7622 platforms need to enable LTSSM and ASPM from PCIe subsys */
|
||||
- if (pcie->base) {
|
||||
- val = readl(pcie->base + PCIE_SYS_CFG_V2);
|
||||
- val |= PCIE_CSR_LTSSM_EN(port->slot) |
|
||||
- PCIE_CSR_ASPM_L1_EN(port->slot);
|
||||
- writel(val, pcie->base + PCIE_SYS_CFG_V2);
|
||||
+ /* MT7622/MT7629 platforms need to enable LTSSM and ASPM. */
|
||||
+ if (pcie->cfg) {
|
||||
+ val = PCIE_CSR_LTSSM_EN(port->slot) |
|
||||
+ PCIE_CSR_ASPM_L1_EN(port->slot);
|
||||
+ regmap_update_bits(pcie->cfg, PCIE_SYS_CFG_V2, val, val);
|
||||
}
|
||||
|
||||
/* Assert all reset signals */
|
||||
@@ -977,6 +980,7 @@ static int mtk_pcie_subsys_powerup(struc
|
||||
struct device *dev = pcie->dev;
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct resource *regs;
|
||||
+ struct device_node *cfg_node;
|
||||
int err;
|
||||
|
||||
/* get shared registers, which are optional */
|
||||
@@ -989,6 +993,13 @@ static int mtk_pcie_subsys_powerup(struc
|
||||
}
|
||||
}
|
||||
|
||||
+ cfg_node = of_parse_phandle(dev->of_node, "mediatek,pcie-cfg", 0);
|
||||
+ if (cfg_node) {
|
||||
+ pcie->cfg = syscon_node_to_regmap(cfg_node);
|
||||
+ if (IS_ERR(pcie->cfg))
|
||||
+ return PTR_ERR(pcie->cfg);
|
||||
+ }
|
||||
+
|
||||
pcie->free_ck = devm_clk_get(dev, "free_ck");
|
||||
if (IS_ERR(pcie->free_ck)) {
|
||||
if (PTR_ERR(pcie->free_ck) == -EPROBE_DEFER)
|
|
@ -0,0 +1,203 @@
|
|||
From patchwork Thu May 28 06:16:48 2020
|
||||
Content-Type: text/plain; charset="utf-8"
|
||||
MIME-Version: 1.0
|
||||
Content-Transfer-Encoding: 7bit
|
||||
X-Patchwork-Submitter: Chuanjia Liu <chuanjia.liu@mediatek.com>
|
||||
X-Patchwork-Id: 11574797
|
||||
Return-Path:
|
||||
<SRS0=ftSA=7K=lists.infradead.org=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@kernel.org>
|
||||
Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org
|
||||
[172.30.200.123])
|
||||
by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 30A5E1392
|
||||
for <patchwork-linux-mediatek@patchwork.kernel.org>;
|
||||
Thu, 28 May 2020 06:29:05 +0000 (UTC)
|
||||
Received: from bombadil.infradead.org (bombadil.infradead.org
|
||||
[198.137.202.133])
|
||||
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
|
||||
(No client certificate requested)
|
||||
by mail.kernel.org (Postfix) with ESMTPS id 08B6320721
|
||||
for <patchwork-linux-mediatek@patchwork.kernel.org>;
|
||||
Thu, 28 May 2020 06:29:05 +0000 (UTC)
|
||||
Authentication-Results: mail.kernel.org;
|
||||
dkim=pass (2048-bit key) header.d=lists.infradead.org
|
||||
header.i=@lists.infradead.org header.b="auhxDafY";
|
||||
dkim=fail reason="signature verification failed" (1024-bit key)
|
||||
header.d=mediatek.com header.i=@mediatek.com header.b="Kj09Arxb"
|
||||
DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08B6320721
|
||||
Authentication-Results: mail.kernel.org;
|
||||
dmarc=fail (p=none dis=none) header.from=mediatek.com
|
||||
Authentication-Results: mail.kernel.org;
|
||||
spf=none
|
||||
smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org
|
||||
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
|
||||
d=lists.infradead.org; s=bombadil.20170209; h=Sender:
|
||||
Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post:
|
||||
List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:
|
||||
Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description:
|
||||
Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
|
||||
List-Owner; bh=+QPxF1vlOH7StIZYuXJa3V40x8QVDxCLF9AFXHblB9M=; b=auhxDafYBeaUZO
|
||||
aYp2KVO8Aie0v4tYtRwBon7hF+x55JwD78SAxQR2RsSvrlOo9cMYYby+ToUWflVUWQ60FapAl+w+l
|
||||
nkEjIOrLBErHwxNOcsD8T5kjyCBMqlz4OMAQYUDNJ3fSugRlGhOtxkjCGd9ebB8N2Rvu6/U8P1A9n
|
||||
P15mEQoc+RLonR1+9mBgwTEXErjsraxkimTD4Txsp4IvMs3UdsMkP+r3OT5S/p+Uj6O9ES0h7xIon
|
||||
aL79KaVqRLHrfZxnrVwuGiecAiTp8qLy9clHuJU32NA6ZcXH1OnWipKApgp8Ck7ys80WPKaMrat9B
|
||||
XuskJ63w13DZAbCVvuGQ==;
|
||||
Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org)
|
||||
by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux))
|
||||
id 1jeC2J-00014n-M9; Thu, 28 May 2020 06:29:03 +0000
|
||||
Received: from mailgw02.mediatek.com ([216.200.240.185])
|
||||
by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux))
|
||||
id 1jeC2H-00013t-Li; Thu, 28 May 2020 06:29:03 +0000
|
||||
X-UUID: a4877c1586e64afeb2d6172e10605d2b-20200527
|
||||
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
|
||||
d=mediatek.com;
|
||||
s=dk;
|
||||
h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From;
|
||||
bh=CIwcBFK1x0LbOjDt1BG6/knHFxDHRiqj8ov/jWEZDBY=;
|
||||
b=Kj09ArxbnLVTc9bpaVPT3jQrIVjhL87sSYyVF9dFypS976k78Ce9gZd0f4K3zAZbYZHYoQtuyOQ9TOeufQfgD+Cr+j5VR7pTdO2E1iXHFs/eQAz5gAjvjlK01z1JiunrLnn9dvIr6c1gEkjQHny0VpuZ1duxx79jwYusg/Nw6Wc=;
|
||||
X-UUID: a4877c1586e64afeb2d6172e10605d2b-20200527
|
||||
Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by
|
||||
mailgw02.mediatek.com
|
||||
(envelope-from <chuanjia.liu@mediatek.com>)
|
||||
(musrelay.mediatek.com ESMTP with TLS)
|
||||
with ESMTP id 899663677; Wed, 27 May 2020 22:29:21 -0800
|
||||
Received: from MTKMBS07N2.mediatek.inc (172.21.101.141) by
|
||||
MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id
|
||||
15.0.1497.2; Wed, 27 May 2020 23:18:50 -0700
|
||||
Received: from mtkcas07.mediatek.inc (172.21.101.84) by
|
||||
mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id
|
||||
15.0.1497.2; Thu, 28 May 2020 14:18:54 +0800
|
||||
Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc
|
||||
(172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend
|
||||
Transport; Thu, 28 May 2020 14:18:52 +0800
|
||||
From: <chuanjia.liu@mediatek.com>
|
||||
To: <robh+dt@kernel.org>, <ryder.lee@mediatek.com>, <matthias.bgg@gmail.com>
|
||||
Subject: [PATCH v2 4/4] ARM: dts: mediatek: Update mt7629 PCIe node
|
||||
Date: Thu, 28 May 2020 14:16:48 +0800
|
||||
Message-ID: <20200528061648.32078-5-chuanjia.liu@mediatek.com>
|
||||
X-Mailer: git-send-email 2.18.0
|
||||
In-Reply-To: <20200528061648.32078-1-chuanjia.liu@mediatek.com>
|
||||
References: <20200528061648.32078-1-chuanjia.liu@mediatek.com>
|
||||
MIME-Version: 1.0
|
||||
X-MTK: N
|
||||
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
|
||||
X-CRM114-CacheID: sfid-20200527_232901_719172_E5A99C62
|
||||
X-CRM114-Status: GOOD ( 11.61 )
|
||||
X-Spam-Score: -0.2 (/)
|
||||
X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary:
|
||||
Content analysis details: (-0.2 points)
|
||||
pts rule name description
|
||||
---- ----------------------
|
||||
--------------------------------------------------
|
||||
-0.0 SPF_PASS SPF: sender matches SPF record
|
||||
0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record
|
||||
0.0 MIME_BASE64_TEXT RAW: Message text disguised using base64
|
||||
encoding
|
||||
-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from
|
||||
author's domain
|
||||
0.1 DKIM_SIGNED Message has a DKIM or DK signature,
|
||||
not necessarily
|
||||
valid
|
||||
-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature
|
||||
-0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from
|
||||
envelope-from domain
|
||||
0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay
|
||||
lines
|
||||
X-BeenThere: linux-mediatek@lists.infradead.org
|
||||
X-Mailman-Version: 2.1.29
|
||||
Precedence: list
|
||||
List-Id: <linux-mediatek.lists.infradead.org>
|
||||
List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-mediatek>,
|
||||
<mailto:linux-mediatek-request@lists.infradead.org?subject=unsubscribe>
|
||||
List-Archive: <http://lists.infradead.org/pipermail/linux-mediatek/>
|
||||
List-Post: <mailto:linux-mediatek@lists.infradead.org>
|
||||
List-Help: <mailto:linux-mediatek-request@lists.infradead.org?subject=help>
|
||||
List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mediatek>,
|
||||
<mailto:linux-mediatek-request@lists.infradead.org?subject=subscribe>
|
||||
Cc: devicetree@vger.kernel.org, lorenzo.pieralisi@arm.com,
|
||||
srv_heupstream@mediatek.com, "chuanjia.liu" <Chuanjia.Liu@mediatek.com>,
|
||||
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
|
||||
jianjun.wang@mediatek.com, linux-mediatek@lists.infradead.org,
|
||||
yong.wu@mediatek.com, bhelgaas@google.com,
|
||||
linux-arm-kernel@lists.infradead.org, amurray@thegoodpenguin.co.uk
|
||||
Sender: "Linux-mediatek" <linux-mediatek-bounces@lists.infradead.org>
|
||||
Errors-To:
|
||||
linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org
|
||||
|
||||
From: "chuanjia.liu" <Chuanjia.Liu@mediatek.com>
|
||||
|
||||
Remove unused property and add pciecfg node.
|
||||
|
||||
Signed-off-by: chuanjia.liu <Chuanjia.Liu@mediatek.com>
|
||||
---
|
||||
arch/arm/boot/dts/mt7629-rfb.dts | 3 ++-
|
||||
arch/arm/boot/dts/mt7629.dtsi | 23 +++++++++++++----------
|
||||
2 files changed, 15 insertions(+), 11 deletions(-)
|
||||
|
||||
--- a/arch/arm/boot/dts/mt7629-rfb.dts
|
||||
+++ b/arch/arm/boot/dts/mt7629-rfb.dts
|
||||
@@ -171,9 +171,10 @@
|
||||
};
|
||||
};
|
||||
|
||||
-&pcie {
|
||||
+&pcie1 {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&pcie_pins>;
|
||||
+ status = "okay";
|
||||
};
|
||||
|
||||
&pciephy1 {
|
||||
--- a/arch/arm/boot/dts/mt7629.dtsi
|
||||
+++ b/arch/arm/boot/dts/mt7629.dtsi
|
||||
@@ -368,16 +368,21 @@
|
||||
#reset-cells = <1>;
|
||||
};
|
||||
|
||||
- pcie: pcie@1a140000 {
|
||||
+ pciecfg: pciecfg@1a140000 {
|
||||
+ compatible = "mediatek,mt7629-pciecfg", "syscon";
|
||||
+ reg = <0x1a140000 0x1000>;
|
||||
+ };
|
||||
+
|
||||
+ pcie1: pcie@1a145000 {
|
||||
compatible = "mediatek,mt7629-pcie";
|
||||
device_type = "pci";
|
||||
- reg = <0x1a140000 0x1000>,
|
||||
- <0x1a145000 0x1000>;
|
||||
- reg-names = "subsys","port1";
|
||||
+ reg = <0x1a145000 0x1000>;
|
||||
+ reg-names = "port1";
|
||||
+ mediatek,pcie-cfg = <&pciecfg>;
|
||||
#address-cells = <3>;
|
||||
#size-cells = <2>;
|
||||
- interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_LOW>,
|
||||
- <GIC_SPI 229 IRQ_TYPE_LEVEL_LOW>;
|
||||
+ interrupts = <GIC_SPI 229 IRQ_TYPE_LEVEL_LOW>;
|
||||
+ interrupt-names = "pcie_irq";
|
||||
clocks = <&pciesys CLK_PCIE_P1_MAC_EN>,
|
||||
<&pciesys CLK_PCIE_P0_AHB_EN>,
|
||||
<&pciesys CLK_PCIE_P1_AUX_EN>,
|
||||
@@ -398,21 +403,19 @@
|
||||
power-domains = <&scpsys MT7622_POWER_DOMAIN_HIF0>;
|
||||
bus-range = <0x00 0xff>;
|
||||
ranges = <0x82000000 0 0x20000000 0x20000000 0 0x10000000>;
|
||||
+ status = "disabled";
|
||||
|
||||
- pcie1: pcie@1,0 {
|
||||
- device_type = "pci";
|
||||
+ slot1: pcie@1,0 {
|
||||
reg = <0x0800 0 0 0 0>;
|
||||
#address-cells = <3>;
|
||||
#size-cells = <2>;
|
||||
#interrupt-cells = <1>;
|
||||
ranges;
|
||||
- num-lanes = <1>;
|
||||
interrupt-map-mask = <0 0 0 7>;
|
||||
interrupt-map = <0 0 0 1 &pcie_intc1 0>,
|
||||
<0 0 0 2 &pcie_intc1 1>,
|
||||
<0 0 0 3 &pcie_intc1 2>,
|
||||
<0 0 0 4 &pcie_intc1 3>;
|
||||
-
|
||||
pcie_intc1: interrupt-controller {
|
||||
interrupt-controller;
|
||||
#address-cells = <0>;
|
|
@ -0,0 +1,24 @@
|
|||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Date: Fri, 4 Sep 2020 18:33:27 +0200
|
||||
Subject: [PATCH] pcie-mediatek: fix clearing interrupt status
|
||||
|
||||
Clearing the status needs to happen after running the handler, otherwise
|
||||
we will get an extra spurious interrupt after the cause has been cleared
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
|
||||
--- a/drivers/pci/controller/pcie-mediatek.c
|
||||
+++ b/drivers/pci/controller/pcie-mediatek.c
|
||||
@@ -616,10 +616,10 @@ static void mtk_pcie_intr_handler(struct
|
||||
if (status & INTX_MASK) {
|
||||
for_each_set_bit_from(bit, &status, PCI_NUM_INTX + INTX_SHIFT) {
|
||||
/* Clear the INTx */
|
||||
- writel(1 << bit, port->base + PCIE_INT_STATUS);
|
||||
virq = irq_find_mapping(port->irq_domain,
|
||||
bit - INTX_SHIFT);
|
||||
generic_handle_irq(virq);
|
||||
+ writel(1 << bit, port->base + PCIE_INT_STATUS);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Date: Fri, 4 Sep 2020 18:36:06 +0200
|
||||
Subject: [PATCH] net: ethernet: mtk_eth_soc: add support for coherent DMA
|
||||
|
||||
It improves performance by eliminating the need for a cache flush on rx and tx
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7622.dtsi
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7622.dtsi
|
||||
@@ -357,7 +357,7 @@
|
||||
};
|
||||
|
||||
cci_control2: slave-if@5000 {
|
||||
- compatible = "arm,cci-400-ctrl-if";
|
||||
+ compatible = "arm,cci-400-ctrl-if", "syscon";
|
||||
interface-type = "ace";
|
||||
reg = <0x5000 0x1000>;
|
||||
};
|
||||
@@ -969,6 +969,8 @@
|
||||
power-domains = <&scpsys MT7622_POWER_DOMAIN_ETHSYS>;
|
||||
mediatek,ethsys = <ðsys>;
|
||||
mediatek,sgmiisys = <&sgmiisys>;
|
||||
+ mediatek,cci-control = <&cci_control2>;
|
||||
+ dma-coherent;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
status = "disabled";
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/of_mdio.h>
|
||||
#include <linux/of_net.h>
|
||||
+#include <linux/of_address.h>
|
||||
#include <linux/mfd/syscon.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/clk.h>
|
||||
@@ -2506,6 +2507,13 @@ static int mtk_hw_init(struct mtk_eth *e
|
||||
if (ret)
|
||||
goto err_disable_pm;
|
||||
|
||||
+ if (of_dma_is_coherent(eth->dev->of_node)) {
|
||||
+ u32 mask = ETHSYS_DMA_AG_MAP_PDMA | ETHSYS_DMA_AG_MAP_QDMA |
|
||||
+ ETHSYS_DMA_AG_MAP_PPE;
|
||||
+
|
||||
+ regmap_update_bits(eth->ethsys, ETHSYS_DMA_AG_MAP, mask, mask);
|
||||
+ }
|
||||
+
|
||||
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) {
|
||||
ret = device_reset(eth->dev);
|
||||
if (ret) {
|
||||
@@ -3104,6 +3112,16 @@ static int mtk_probe(struct platform_dev
|
||||
}
|
||||
}
|
||||
|
||||
+ if (of_dma_is_coherent(pdev->dev.of_node)) {
|
||||
+ struct regmap *cci;
|
||||
+
|
||||
+ cci = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
|
||||
+ "mediatek,cci-control");
|
||||
+ /* enable CPU/bus coherency */
|
||||
+ if (!IS_ERR(cci))
|
||||
+ regmap_write(cci, 0, 3);
|
||||
+ }
|
||||
+
|
||||
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SGMII)) {
|
||||
eth->sgmii = devm_kzalloc(eth->dev, sizeof(*eth->sgmii),
|
||||
GFP_KERNEL);
|
||||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
||||
@@ -448,6 +448,12 @@
|
||||
#define RSTCTRL_FE BIT(6)
|
||||
#define RSTCTRL_PPE BIT(31)
|
||||
|
||||
+/* ethernet dma channel agent map */
|
||||
+#define ETHSYS_DMA_AG_MAP 0x408
|
||||
+#define ETHSYS_DMA_AG_MAP_PDMA BIT(0)
|
||||
+#define ETHSYS_DMA_AG_MAP_QDMA BIT(1)
|
||||
+#define ETHSYS_DMA_AG_MAP_PPE BIT(2)
|
||||
+
|
||||
/* SGMII subsystem config registers */
|
||||
/* Register to auto-negotiation restart */
|
||||
#define SGMSYS_PCS_CONTROL_1 0x0
|
|
@ -0,0 +1,25 @@
|
|||
From: David Bauer <mail@david-bauer.net>
|
||||
Date: Thu, 11 Feb 2021 19:57:26 +0100
|
||||
Subject: [PATCH] mtd: spi-nor: add support for Winbond W25Q512
|
||||
|
||||
The Winbond W25Q512 is a 512mb SPI-NOR chip. It supports 4K sectors as
|
||||
well as block protection and Dual-/Quad-read.
|
||||
|
||||
Tested on: Ubiquiti UniFi 6 LR
|
||||
|
||||
Signed-off-by: David Bauer <mail@david-bauer.net>
|
||||
|
||||
Ref: https://patchwork.ozlabs.org/project/linux-mtd/patch/20210213151047.11700-1-mail@david-bauer.net/
|
||||
|
||||
--- a/drivers/mtd/spi-nor/spi-nor.c
|
||||
+++ b/drivers/mtd/spi-nor/spi-nor.c
|
||||
@@ -2552,6 +2552,9 @@ static const struct flash_info spi_nor_i
|
||||
.fixups = &w25q256_fixups },
|
||||
{ "w25q256jvm", INFO(0xef7019, 0, 64 * 1024, 512,
|
||||
SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
|
||||
+ { "w25q512jv", INFO(0xef4020, 0, 64 * 1024, 1024,
|
||||
+ SECT_4K | SPI_NOR_QUAD_READ | SPI_NOR_DUAL_READ |
|
||||
+ SPI_NOR_HAS_TB | SPI_NOR_HAS_LOCK) },
|
||||
{ "w25m512jv", INFO(0xef7119, 0, 64 * 1024, 1024,
|
||||
SECT_4K | SPI_NOR_QUAD_READ | SPI_NOR_DUAL_READ) },
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
--- a/drivers/leds/Kconfig
|
||||
+++ b/drivers/leds/Kconfig
|
||||
@@ -824,6 +824,16 @@ config LEDS_LM36274
|
||||
Say Y to enable the LM36274 LED driver for TI LMU devices.
|
||||
This supports the LED device LM36274.
|
||||
|
||||
+config LEDS_UBNT_LEDBAR
|
||||
+ tristate "LED support for Ubiquiti UniFi 6 LR"
|
||||
+ depends on LEDS_CLASS && I2C && OF
|
||||
+ help
|
||||
+ This option enables support for the Ubiquiti LEDBAR
|
||||
+ LED driver.
|
||||
+
|
||||
+ To compile this driver as a module, choose M here: the module
|
||||
+ will be called leds-ubnt-ledbar.
|
||||
+
|
||||
comment "LED Triggers"
|
||||
source "drivers/leds/trigger/Kconfig"
|
||||
|
||||
--- a/drivers/leds/Makefile
|
||||
+++ b/drivers/leds/Makefile
|
||||
@@ -85,6 +85,7 @@ obj-$(CONFIG_LEDS_LM3601X) += leds-lm36
|
||||
obj-$(CONFIG_LEDS_TI_LMU_COMMON) += leds-ti-lmu-common.o
|
||||
obj-$(CONFIG_LEDS_LM3697) += leds-lm3697.o
|
||||
obj-$(CONFIG_LEDS_LM36274) += leds-lm36274.o
|
||||
+obj-$(CONFIG_LEDS_UBNT_LEDBAR) += leds-ubnt-ledbar.o
|
||||
|
||||
# LED SPI Drivers
|
||||
obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o
|
|
@ -0,0 +1,35 @@
|
|||
From 9ba7c246063ae43baf2e53ccc8c8b5f8d025aaaa Mon Sep 17 00:00:00 2001
|
||||
From: Chuanhong Guo <gch981213@gmail.com>
|
||||
Date: Sun, 3 Apr 2022 10:19:29 +0800
|
||||
Subject: [PATCH 15/15] arm64: dts: mediatek: add mtk-snfi for mt7622
|
||||
|
||||
This patch adds a device-tree node for the MTK SPI-NAND Flash Interface
|
||||
for MT7622 device tree.
|
||||
|
||||
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
|
||||
(cherry picked from commit 2e022641709011ef0843d0416b0f264b5fc217af)
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt7622.dtsi | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7622.dtsi
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7622.dtsi
|
||||
@@ -552,6 +552,18 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
+ snfi: spi@1100d000 {
|
||||
+ compatible = "mediatek,mt7622-snand";
|
||||
+ reg = <0 0x1100d000 0 0x1000>;
|
||||
+ interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_LOW>;
|
||||
+ clocks = <&pericfg CLK_PERI_NFI_PD>, <&pericfg CLK_PERI_SNFI_PD>;
|
||||
+ clock-names = "nfi_clk", "pad_clk";
|
||||
+ nand-ecc-engine = <&bch>;
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
bch: ecc@1100e000 {
|
||||
compatible = "mediatek,mt7622-ecc";
|
||||
reg = <0 0x1100e000 0 0x1000>;
|
|
@ -0,0 +1,28 @@
|
|||
--- a/arch/arm64/boot/dts/mediatek/mt7622.dtsi
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7622.dtsi
|
||||
@@ -847,6 +847,12 @@
|
||||
#address-cells = <0>;
|
||||
#interrupt-cells = <1>;
|
||||
};
|
||||
+
|
||||
+ slot0: pcie@0,0 {
|
||||
+ reg = <0x0000 0 0 0 0>;
|
||||
+ #address-cells = <3>;
|
||||
+ #size-cells = <2>;
|
||||
+ };
|
||||
};
|
||||
|
||||
pcie1: pcie@1a145000 {
|
||||
@@ -885,6 +891,12 @@
|
||||
#address-cells = <0>;
|
||||
#interrupt-cells = <1>;
|
||||
};
|
||||
+
|
||||
+ slot1: pcie@1,0 {
|
||||
+ reg = <0x0800 0 0 0 0>;
|
||||
+ #address-cells = <3>;
|
||||
+ #size-cells = <2>;
|
||||
+ };
|
||||
};
|
||||
|
||||
sata: sata@1a200000 {
|
|
@ -1,80 +0,0 @@
|
|||
--- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
|
||||
@@ -279,14 +279,14 @@
|
||||
&pcie1 {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&pcie1_pins>;
|
||||
- status = "okay";
|
||||
+ status = "disabled";
|
||||
};
|
||||
|
||||
&pio {
|
||||
/* Attention: GPIO 90 is used to switch between PCIe@1,0 and
|
||||
* SATA functions. i.e. output-high: PCIe, output-low: SATA
|
||||
*/
|
||||
- asm_sel {
|
||||
+ asmsel: asm_sel {
|
||||
gpio-hog;
|
||||
gpios = <90 GPIO_ACTIVE_HIGH>;
|
||||
output-high;
|
||||
--- /dev/null
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64-sata.dts
|
||||
@@ -0,0 +1,31 @@
|
||||
+/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */
|
||||
+
|
||||
+#include <dt-bindings/gpio/gpio.h>
|
||||
+
|
||||
+/dts-v1/;
|
||||
+/plugin/;
|
||||
+
|
||||
+/ {
|
||||
+ compatible = "bananapi,bpi-r64", "mediatek,mt7622";
|
||||
+
|
||||
+ fragment@0 {
|
||||
+ target = <&asmsel>;
|
||||
+ __overlay__ {
|
||||
+ gpios = <90 GPIO_ACTIVE_LOW>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ fragment@1 {
|
||||
+ target = <&sata>;
|
||||
+ __overlay__ {
|
||||
+ status = "okay";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ fragment@2 {
|
||||
+ target = <&sata_phy>;
|
||||
+ __overlay__ {
|
||||
+ status = "okay";
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
--- /dev/null
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64-pcie1.dts
|
||||
@@ -0,0 +1,24 @@
|
||||
+/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */
|
||||
+
|
||||
+#include <dt-bindings/gpio/gpio.h>
|
||||
+
|
||||
+/dts-v1/;
|
||||
+/plugin/;
|
||||
+
|
||||
+/ {
|
||||
+ compatible = "bananapi,bpi-r64", "mediatek,mt7622";
|
||||
+
|
||||
+ fragment@0 {
|
||||
+ target = <&asmsel>;
|
||||
+ __overlay__ {
|
||||
+ gpios = <90 GPIO_ACTIVE_HIGH>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ fragment@1 {
|
||||
+ target = <&pcie1>;
|
||||
+ __overlay__ {
|
||||
+ status = "okay";
|
||||
+ };
|
||||
+ };
|
||||
+};
|
Loading…
Add table
Add a link
Reference in a new issue