From 10e4d64e345b6b684d27d3da6ed8d887c8e45f76 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 13 Aug 2020 12:43:22 +0200 Subject: firmware: psci: Do not bind driver if U-Boot runs in EL3 There is no reason to bind psci driver if U-Boot runs in EL3 because SMC/HVC instructions can't be called. That's why detect this state and don't let user to crash from prompt by performing reset or poweroff commands (if enabled). Signed-off-by: Michal Simek --- drivers/firmware/psci.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers') diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 7d2e49fd3e..68953cc4f4 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -19,6 +19,7 @@ #include #include #include +#include #define DRIVER_NAME "psci" @@ -73,6 +74,11 @@ static int psci_probe(struct udevice *dev) { const char *method; +#if defined(CONFIG_ARM64) + if (current_el() == 3) + return -EINVAL; +#endif + method = ofnode_read_string(dev_ofnode(dev), "method"); if (!method) { pr_warn("missing \"method\" property\n"); -- cgit From 6b0ddd1fbc6c8f7cbd0418e8a87d02404ad3dd9b Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Wed, 19 Aug 2020 18:07:32 +0900 Subject: virtio_blk: set log2blksz correctly 'log2blksz' in blk_desc structure must always be initialized, otherwise it will cause a lot of weird failures in file operations. For example, fs_set_blk_dev[_with_part]() examines a block device against every file system with its probe function. In particular, ext4 file system's ext4_probe() will calls fs_devread() to fetch a super block. If log2blksz is 0, the actual 'read' size, i.e. block_len >> log2blksz, is much bigger than a buffer's size, and it can end up with memory corruption. Signed-off-by: AKASHI Takahiro Fixes: f4802209e59d ("virtio: Add block driver support") Reviewed-by: Bin Meng --- drivers/virtio/virtio_blk.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/virtio/virtio_blk.c b/drivers/virtio/virtio_blk.c index 992118c607..1799f5c5eb 100644 --- a/drivers/virtio/virtio_blk.c +++ b/drivers/virtio/virtio_blk.c @@ -115,6 +115,7 @@ static int virtio_blk_probe(struct udevice *dev) return ret; desc->blksz = 512; + desc->log2blksz = 9; virtio_cread(dev, struct virtio_blk_config, capacity, &cap); desc->lba = cap; -- cgit From 626892a779addb9604387ece522e3410d3ef3aa5 Mon Sep 17 00:00:00 2001 From: Frank Wunderlich Date: Thu, 20 Aug 2020 16:37:52 +0200 Subject: phy: mtk-tphy: make shared reg optional for v1 make the shared reg optional when version is v1 for sata Suggested-by: Chunfeng Yun Signed-off-by: Frank Wunderlich Reviewed-by: Chunfeng Yun --- drivers/phy/phy-mtk-tphy.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/phy/phy-mtk-tphy.c b/drivers/phy/phy-mtk-tphy.c index 326227a30d..3d7b9cd2b1 100644 --- a/drivers/phy/phy-mtk-tphy.c +++ b/drivers/phy/phy-mtk-tphy.c @@ -698,11 +698,10 @@ static int mtk_tphy_probe(struct udevice *dev) tphy->dev = dev; tphy->version = dev_get_driver_data(dev); - /* v1 has shared banks */ + /* v1 has shared banks for usb/pcie mode, */ + /* but not for sata mode */ if (tphy->version == MTK_TPHY_V1) { tphy->sif_base = dev_read_addr_ptr(dev); - if (!tphy->sif_base) - return -ENOENT; } dev_for_each_subnode(subnode, dev) { -- cgit From a300d696caee9e97da5a0b835451d27c98e07f8f Mon Sep 17 00:00:00 2001 From: Frank Wunderlich Date: Thu, 20 Aug 2020 16:37:53 +0200 Subject: reset: drop unnecessary comment for pciesys after review from sam this comment should be removed Signed-off-by: Frank Wunderlich --- drivers/clk/mediatek/clk-mt7622.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/clk/mediatek/clk-mt7622.c b/drivers/clk/mediatek/clk-mt7622.c index d53ed69189..a1a35f72a3 100644 --- a/drivers/clk/mediatek/clk-mt7622.c +++ b/drivers/clk/mediatek/clk-mt7622.c @@ -599,7 +599,6 @@ static int mt7622_pciesys_bind(struct udevice *dev) int ret = 0; if (IS_ENABLED(CONFIG_RESET_MEDIATEK)) { -// PCIESYS uses in linux also 0x34 = ETHSYS reset controller ret = mediatek_reset_bind(dev, ETHSYS_HIFSYS_RST_CTRL_OFS, 1); if (ret) debug("Warning: failed to bind reset controller\n"); -- cgit From a7e0ef15ddee2751110766e2abc010d2ec9325f8 Mon Sep 17 00:00:00 2001 From: Frank Wunderlich Date: Thu, 20 Aug 2020 16:37:54 +0200 Subject: ahci: mediatek: fix copyright and author-lines after review of sam copyright should be on one line and link should not between author lines just remove the link and put ryder first as he is author of linux-driver Signed-off-by: Frank Wunderlich --- drivers/ata/mtk_ahci.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/ata/mtk_ahci.c b/drivers/ata/mtk_ahci.c index 8e09c5f9e6..4ad260a5bb 100644 --- a/drivers/ata/mtk_ahci.c +++ b/drivers/ata/mtk_ahci.c @@ -2,12 +2,10 @@ /* * MTK SATA platform driver * - * (C) Copyright 2020 - * Mediatek + * Copyright (C) 2020 MediaTek Inc. * - * Author: Frank Wunderlich - * based on https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/ata/ahci_mtk.c * Author: Ryder Lee + * Author: Frank Wunderlich */ #include -- cgit From 9f25aa13ea2f106885ea52a1039b9c6e7a677a35 Mon Sep 17 00:00:00 2001 From: Frank Wunderlich Date: Thu, 20 Aug 2020 16:37:55 +0200 Subject: clk: mt7622: add needed clocks for ssusb-node MT7622 needs additional clock definitions to work properly Signed-off-by: Frank Wunderlich --- drivers/clk/mediatek/clk-mt7622.c | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'drivers') diff --git a/drivers/clk/mediatek/clk-mt7622.c b/drivers/clk/mediatek/clk-mt7622.c index a1a35f72a3..0246149107 100644 --- a/drivers/clk/mediatek/clk-mt7622.c +++ b/drivers/clk/mediatek/clk-mt7622.c @@ -521,6 +521,20 @@ static const struct mtk_gate_regs sgmii_cg_regs = { .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \ } +static const struct mtk_gate_regs ssusb_cg_regs = { + .set_ofs = 0x30, + .clr_ofs = 0x30, + .sta_ofs = 0x30, +}; + +#define GATE_SSUSB(_id, _parent, _shift) { \ + .id = _id, \ + .parent = _parent, \ + .regs = &ssusb_cg_regs, \ + .shift = _shift, \ + .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \ +} + static const struct mtk_gate sgmii_cgs[] = { GATE_SGMII(CLK_SGMII_TX250M_EN, CLK_TOP_SSUSB_TX250M, 2), GATE_SGMII(CLK_SGMII_RX250M_EN, CLK_TOP_SSUSB_EQ_RX250M, 3), @@ -528,6 +542,15 @@ static const struct mtk_gate sgmii_cgs[] = { GATE_SGMII(CLK_SGMII_CDR_FB, CLK_TOP_SSUSB_CDR_FB, 5), }; +static const struct mtk_gate ssusb_cgs[] = { + GATE_SSUSB(CLK_SSUSB_U2_PHY_1P_EN, CLK_TOP_TO_U2_PHY_1P, 0), + GATE_SSUSB(CLK_SSUSB_U2_PHY_EN, CLK_TOP_TO_U2_PHY, 1), + GATE_SSUSB(CLK_SSUSB_REF_EN, CLK_TOP_TO_USB3_REF, 5), + GATE_SSUSB(CLK_SSUSB_SYS_EN, CLK_TOP_TO_USB3_SYS, 6), + GATE_SSUSB(CLK_SSUSB_MCU_EN, CLK_TOP_AXI_SEL, 7), + GATE_SSUSB(CLK_SSUSB_DMA_EN, CLK_TOP_HIF_SEL, 8), +}; + static const struct mtk_clk_tree mt7622_clk_tree = { .xtal_rate = 25 * MHZ, .xtal2_rate = 25 * MHZ, @@ -630,6 +653,11 @@ static int mt7622_sgmiisys_probe(struct udevice *dev) return mtk_common_clk_gate_init(dev, &mt7622_clk_tree, sgmii_cgs); } +static int mt7622_ssusbsys_probe(struct udevice *dev) +{ + return mtk_common_clk_gate_init(dev, &mt7622_clk_tree, ssusb_cgs); +} + static const struct udevice_id mt7622_apmixed_compat[] = { { .compatible = "mediatek,mt7622-apmixedsys" }, { } @@ -670,6 +698,11 @@ static const struct udevice_id mt7622_mcucfg_compat[] = { { } }; +static const struct udevice_id mt7622_ssusbsys_compat[] = { + { .compatible = "mediatek,mt7622-ssusbsys" }, + { } +}; + U_BOOT_DRIVER(mtk_mcucfg) = { .name = "mt7622-mcucfg", .id = UCLASS_SYSCON, @@ -746,3 +779,12 @@ U_BOOT_DRIVER(mtk_clk_sgmiisys) = { .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), .ops = &mtk_clk_gate_ops, }; + +U_BOOT_DRIVER(mtk_clk_ssusbsys) = { + .name = "mt7622-clock-ssusbsys", + .id = UCLASS_CLK, + .of_match = mt7622_ssusbsys_compat, + .probe = mt7622_ssusbsys_probe, + .priv_auto_alloc_size = sizeof(struct mtk_cg_priv), + .ops = &mtk_clk_gate_ops, +}; -- cgit From 3337b291442e31b1db0ff5975f74fec7d9741794 Mon Sep 17 00:00:00 2001 From: Anastasiia Lukianenko Date: Fri, 21 Aug 2020 12:10:04 +0300 Subject: xen: Code style conformity Cleaning up the following: ERROR: do not use assignment in if condition #281: FILE: drivers/xen/pvblock.c:260: + if ((err = xenbus_switch_state(XBT_NIL, nodename, CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "err" #52: FILE: drivers/xen/pvblock.c:298: + if (err != NULL) { ERROR: do not use assignment in if condition #176: FILE: drivers/xen/gnttab.c:103: + if ((flags = nflags) & (GTF_reading | GTF_writing)) { WARNING: Missing or malformed SPDX-License-Identifier tag in line 1 #329: FILE: include/xen/gnttab.h:1: +/* WARNING: Misplaced SPDX-License-Identifier tag - use line 1 instead #330: FILE: include/xen/gnttab.h:2: + * SPDX-License-Identifier: GPL-2.0 ERROR: do not use assignment in if condition #630: FILE: lib/sscanf.c:558: + if ((n = inr) < width) { Signed-off-by: Anastasiia Lukianenko Reviewed-by: Simon Glass --- drivers/xen/gnttab.c | 3 ++- drivers/xen/pvblock.c | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/xen/gnttab.c b/drivers/xen/gnttab.c index becf7a79fb..9bf1091ab3 100644 --- a/drivers/xen/gnttab.c +++ b/drivers/xen/gnttab.c @@ -100,7 +100,8 @@ int gnttab_end_access(grant_ref_t ref) nflags = gnttab_table[ref].flags; do { - if ((flags = nflags) & (GTF_reading | GTF_writing)) { + flags = nflags; + if ((flags) & (GTF_reading | GTF_writing)) { printf("WARNING: g.e. still in use! (%x)\n", flags); return 0; } diff --git a/drivers/xen/pvblock.c b/drivers/xen/pvblock.c index 76e82fbf41..1b3325bbe2 100644 --- a/drivers/xen/pvblock.c +++ b/drivers/xen/pvblock.c @@ -294,8 +294,8 @@ static void shutdown_blkfront(struct blkfront_dev *dev) snprintf(path, sizeof(path), "%s/state", dev->backend); snprintf(nodename, sizeof(nodename), "%s/state", dev->nodename); - if ((err = xenbus_switch_state(XBT_NIL, nodename, - XenbusStateClosing)) != NULL) { + err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosing); + if (err) { printf("%s: error changing state to %d: %s\n", __func__, XenbusStateClosing, err); goto close; @@ -306,8 +306,8 @@ static void shutdown_blkfront(struct blkfront_dev *dev) err = xenbus_wait_for_state_change(path, &state); free(err); - if ((err = xenbus_switch_state(XBT_NIL, nodename, - XenbusStateClosed)) != NULL) { + err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosed); + if (err) { printf("%s: error changing state to %d: %s\n", __func__, XenbusStateClosed, err); goto close; @@ -319,8 +319,8 @@ static void shutdown_blkfront(struct blkfront_dev *dev) free(err); } - if ((err = xenbus_switch_state(XBT_NIL, nodename, - XenbusStateInitialising)) != NULL) { + err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateInitialising); + if (err) { printf("%s: error changing state to %d: %s\n", __func__, XenbusStateInitialising, err); goto close; -- cgit