From patchwork Wed Jul 24 07:34:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3317 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id E58FE3F18D for ; Wed, 24 Jul 2024 09:34:16 +0200 (CEST) Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-427b7a2052bsf64968965e9.2 for ; Wed, 24 Jul 2024 00:34:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1721806456; cv=pass; d=google.com; s=arc-20160816; b=YLJvrJ5jANd4YUQB09iNXpfNHnPKk1zflwaXvAK5sI4JhU3HsFb5n3wQC8clB6paPV IYYZc7s/IBHJgXuz/BK8Zf7wath0vn9F/AcnW2Fb2rAbDCOfIW2mMnCGAOuNiguWZazx 0Y1V2IE8hwJjLorACQEY4R3ZPsQ3HOGY9A1LCPpZvN+iPWSnWfMbwYm49K4Oj4xviS5D mJaJIIPyTHcoid4jhwfEUr8SNIZjBStGVQ/SYZM08wYwwYhc4+KDzS3116nOOQ2KNW4F fQOuxia1/nZmv8l/7+buA+oLkjLS+vALGba4vtPX/eejsVHhAMDehW/DHcmNmkUjEHr8 /bBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:message-id:date:subject:cc:to :from:dkim-signature; bh=tayWFoptrb+C5Yu4aLXlW6w91NH5ZtQQbK+kgYGgDZI=; fh=IhzlTlsEWvD9AH1/SuLyVTrxUej8c1dvCMBfWPThUNA=; b=zN71hwgD98nCeHvfIeSaFztqQ0MWfZUK5h79qQs2WEb3F51wnLLIy58gtfSv/3eSps URffN0DuPftQu4L+1450nGvwihQegusnapSFaWplXhNTpXEfjptbBTgnQgCNcjZliTkY Vbx/4Expffmk7t/srLRG6tUmxKdxUP8QFWoqxpI2Z/3Qm4cNU+Y1aROZ89SsiM+hEUoP 06iHZKXLs3HMqJWcLrZ5kqaUttRZLRHUkpBl4Uk0FC3/s9lWFq/hs/Q5nb43K9mUDL1L 8GXrR0cnfOTnmyqYpZM04/K/9t7M/VrZlOboSunJRoAwsx5C3MJe+SEtMT1r9pdNiXp2 s7vw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="qhJ/d8rZ"; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1721806456; x=1722411256; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :from:to:cc:subject:date:message-id:reply-to; bh=tayWFoptrb+C5Yu4aLXlW6w91NH5ZtQQbK+kgYGgDZI=; b=BqZL58bMj7QvKTQoUkQ1bbPJckRFWqMTl6BsVJmsIfATOwES4RKFoPohEYEm9jDaUp NFk8vmNXpoW5qDDnn1CvRoV/KjluZtNkR5Y29rodKp0w8xlXY5Y7M6YJy7bcg1PKcUWC DUIdD1hTVxT3Z5ODOZVWrrdZSeG9QKlTTrXi4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721806456; x=1722411256; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-beenthere:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=tayWFoptrb+C5Yu4aLXlW6w91NH5ZtQQbK+kgYGgDZI=; b=cShV6sAkYztGvdB8tQLmUf9Pg+GNR24FdQV0mYDRJh+VlOkiI5rnbMMXmKKyJn4fDD 3+pz+LuKC77kliy/yRROOP3NeyAMx7ryMw8zJiX71Bst9jaLiueJu+awpRfifH+BkrgA kCy6tyqxijz5gj2Lc/wXHmFC6TqTJMQ6DfTtPQ5eJx6jv1m9Wk/O+JLWbwX18OZZaE85 CLnuG2YPiTMd1fshVPsPcfCTQZiEQOMrdGw5L1+8sxKrSuzZUJNqxJ2GWzKcJ/Gz2xnn 4dHwiLrWqEkz+yRyXPwT7NkuSj1WLdzJWeRLs+bRe2IDziLec7RiNvdNHcGwcOecYZOl lKUQ== X-Forwarded-Encrypted: i=2; AJvYcCWTD50KJQL42AGPmm9TZTr2VYTC2nZMIoTigt154OfwsCPZAO/QYpfE+OtvCia/WkfVR0aZuwoRV3VGMapPk6M9MS+76BnoYSjQwAtGNIXRmnylzr+Fnz/d+zuYwQ== X-Gm-Message-State: AOJu0YyHQRNN7dftL+o8G97mguzFGVgx2eNfGGTEGY7ZLWIntDBAO1fA A3fMUhCe8OaqPPADkIqMjh6xQBeOQplQ8SV1hESCArrhxhdIwzb2MYle+3OzZF+gBw== X-Google-Smtp-Source: AGHT+IF76t25HWnPiEp1T0yOhLb3YbN9lOwJLANz9iPoLT2G7gyWFD/aWDf9dqlQcUAo8PHivOsiBg== X-Received: by 2002:a05:600c:3582:b0:426:6f87:65fc with SMTP id 5b1f17b1804b1-427f7ac20f8mr16161585e9.17.1721806456207; Wed, 24 Jul 2024 00:34:16 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:3b23:b0:426:6eb9:5098 with SMTP id 5b1f17b1804b1-427c8396963ls41831875e9.1.-pod-prod-05-eu; Wed, 24 Jul 2024 00:34:15 -0700 (PDT) X-Received: by 2002:a5d:6a8d:0:b0:368:5b38:14ee with SMTP id ffacd0b85a97d-369f09bd458mr1540249f8f.23.1721806454631; Wed, 24 Jul 2024 00:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721806454; cv=none; d=google.com; s=arc-20160816; b=myPnHzzAv0opg2EcgA2vVtxXU3PeF7orD1kOzMtHzgXW9eT/DiLYb0LNCjNvxejySB JM64jWqCPVfWgEFas/khHbopJTtFAOHcEWUuwdVjZsoFrY57Z0Ni+IE1DBZK/iuuVUrC kADyhctqZuqYWjJNLIF5YOVYQslSmmA2l/RZ0ki+ePuwBqads7FJzAqKEgu2wa24s08r dnDQYZPVIUUQTMqFw9HdJ/n/HUIp3bYUHe6+thIHRc+nUv6Th7ebXXrbwA4O43ShQ6Sg CJOnlVmlobSJWrMuqlikraZlcw/hgwXSPuqvJaIkApc6hQ2iDfWrB3Skw5EI/5XC+MWK Wu3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=zFumCpoWyKkjr/xNREQtSzIrmXUkP2nQ2TL5EH9h4tM=; fh=TxZqpDnmNnEuFpzvSuJnex3klziSlCfIJQeCLB2WEQk=; b=UM1C5ReCTH4v91dAcvAAQVppOtno6jmnLKO/07WTmpsvt8oX051kYKDLaUDsAeuiQ1 2Pa1/9YIDf55oYSoPO43E0HrHi1E8HspF3o++UmNzO6/40crgOEiRf9FknbsfADtQamI YTg6NzUllaXkzbXuE8kqBRL67In1Zd8izTsz7r0kPdKZwsNBGUlmFYoaLe/DjTFH1lI7 /Wj0G7ykL/vXVhxYSRKBP2+CyF5bO1mMTZ/r7VqJ4ng9JpwYtwtD8+/0meI7eKqzC6DY 8iNfj60o90mcyrRopyRKAR1jEyiEpiVN2K7IZUv10wVYaFGiZxttkqn7WCAzbg5zH9E2 1uIQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="qhJ/d8rZ"; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id ffacd0b85a97d-368787bb29dsor3958912f8f.3.2024.07.24.00.34.14 for (Google Transport Security); Wed, 24 Jul 2024 00:34:14 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a5d:69cc:0:b0:366:ee01:30d6 with SMTP id ffacd0b85a97d-369f0a7c90cmr1570960f8f.49.1721806454066; Wed, 24 Jul 2024 00:34:14 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.. ([2.196.40.97]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787ced05sm13474613f8f.67.2024.07.24.00.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 00:34:13 -0700 (PDT) From: Dario Binacchi To: michael@amarulasolutions.com Cc: linux-amarula@amarulasolutions.com, Dario Binacchi Subject: [PATCH 1/2] fix(imx8m): set uart domain permission Date: Wed, 24 Jul 2024 09:34:00 +0200 Message-ID: <20240724073401.1587434-1-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="qhJ/d8rZ"; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The commit d76f012ea8fc0 ("refactor(imx8m): replace magic number with enum type") also hardcodes the domain permissions for the UARTs, without considering that read/write rights for domain 0 must be enabled for the boot UART. This creates a regression. Indeed, previously, the RDC_PDAP_UARTn registers were set to the reset value (0xff), meaning all domains were enabled for read and write access. The patch fixes this issue by assigning read/write rights for domain 0 to the boot UART. Signed-off-by: Dario Binacchi --- plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c | 5 +++-- plat/imx/imx8m/imx8mn/imx8mn_bl31_setup.c | 5 +++-- plat/imx/imx8m/include/imx8m_uart.h | 15 +++++++++++++++ plat/imx/imx8m/include/imx_rdc.h | 3 +++ 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 plat/imx/imx8m/include/imx8m_uart.h diff --git a/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c b/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c index dc9dd5949798..7f7319392b1d 100644 --- a/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c +++ b/plat/imx/imx8m/imx8mm/imx8mm_bl31_setup.c @@ -30,6 +30,7 @@ #include #include #include + #include #define TRUSTY_PARAMS_LEN_BYTES (4096*2) @@ -66,8 +67,8 @@ static const struct imx_rdc_cfg rdc[] = { RDC_MDAn(RDC_MDA_M4, DID1), /* peripherals domain permission */ - RDC_PDAPn(RDC_PDAP_UART4, D1R | D1W), - RDC_PDAPn(RDC_PDAP_UART2, D0R | D0W), + RDC_PDAPn(RDC_PDAP_UART4, PDAPn_UART_DOMAIN(UART4_BASE_ADDR, D1R | D1W)), + RDC_PDAPn(RDC_PDAP_UART2, PDAPn_UART_DOMAIN(UART2_BASE_ADDR, D1R | D1W)), /* memory region */ diff --git a/plat/imx/imx8m/imx8mn/imx8mn_bl31_setup.c b/plat/imx/imx8m/imx8mn/imx8mn_bl31_setup.c index f9e430bf964a..0b6e9c979efd 100644 --- a/plat/imx/imx8m/imx8mn/imx8mn_bl31_setup.c +++ b/plat/imx/imx8m/imx8mn/imx8mn_bl31_setup.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -52,8 +53,8 @@ static const struct imx_rdc_cfg rdc[] = { RDC_MDAn(RDC_MDA_M7, DID1), /* peripherals domain permission */ - RDC_PDAPn(RDC_PDAP_UART4, D1R | D1W), - RDC_PDAPn(RDC_PDAP_UART2, D0R | D0W), + RDC_PDAPn(RDC_PDAP_UART4, PDAPn_UART_DOMAIN(UART4_BASE_ADDR, D1R | D1W)), + RDC_PDAPn(RDC_PDAP_UART2, PDAPn_UART_DOMAIN(UART2_BASE_ADDR, D1R | D1W)), /* memory region */ RDC_MEM_REGIONn(16, 0x0, 0x0, 0xff), diff --git a/plat/imx/imx8m/include/imx8m_uart.h b/plat/imx/imx8m/include/imx8m_uart.h new file mode 100644 index 000000000000..46e32f30bc97 --- /dev/null +++ b/plat/imx/imx8m/include/imx8m_uart.h @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2024, Amarula Solutions B.V. + * + * SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause + */ + +#ifndef IMX8M_UART_H +#define IMX8M_UART_H + +#define UART1_BASE_ADDR 0x30860000 +#define UART2_BASE_ADDR 0x30890000 +#define UART3_BASE_ADDR 0x30880000 +#define UART4_BASE_ADDR 0x30A60000 + +#endif /*IMX8M_UART_H */ diff --git a/plat/imx/imx8m/include/imx_rdc.h b/plat/imx/imx8m/include/imx_rdc.h index a6e10a7b7529..f1a40cea3eed 100644 --- a/plat/imx/imx8m/include/imx_rdc.h +++ b/plat/imx/imx8m/include/imx_rdc.h @@ -36,6 +36,9 @@ #define D0R BIT(1) #define D0W BIT(0) +#define PDAPn_UART_DOMAIN(base, def_domain) \ + (IMX_BOOT_UART_BASE == base ? D0R | D0W : def_domain) + union rdc_setting { uint32_t rdc_mda; /* Master Domain Assignment */ uint32_t rdc_pdap; /* Peripheral Domain Access Permissions */