Draft
Conversation
The mt65xx SoC family uses an earlier version of the SMI, which we refer to as gen 0. Unlike gen 1 or gen 2, gen 0 requires simultaneous access to two distinct MMIO ranges: an AO base for IOMMU configuration and ext base for OSTD, FIFO, and bandwidth limiter setup. Remove the union in struct mtk_smi to allow simultaneous use of smi_ao_base and base. Refactor the probe function into a switch statement to handle the different generation requirements cleanly. Signed-off-by: rva3 <rva333@protonmail.com>
The mt65xx SoC family utilizes a larb design that incorporates features from both gen 1 and gen 2 architectures. Introduce a specific configuration callback for this generation, which implements the port security configuration typical for gen 1 while including the ostd settings found in gen 2. Additionally, add a bandwidth calibration flag for some of the gen 0 SoCs. Signed-off-by: rva3 <rva333@protonmail.com>
The mt65xx SoC family utilizes an earlier version of the IOMMU which shares the same v1 architecture but has minor hardware differences compared to mt2701. Introduce mtk_iommu_type to distinguish between mt2701 and mt65xx variants and apply the necessary logic. Signed-off-by: rva3 <rva333@protonmail.com>
Member
Author
|
maybe needed |
XXX: maybe we should drop this?.. Signed-off-by: rva3 <rva333@protonmail.com>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Add a header for the IOMMU ports on the MediaTek MT6589 SoC. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Add platform data for the SMI common on the MT6589 SoC. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Make sure to drop the reference taken when looking up the SMI device during common probe on late probe failure (e.g. probe deferral) and on driver unbind. Fixes: 4740475 ("memory: mtk-smi: Add device link for smi-sub-common") Fixes: 038ae37 ("memory: mtk-smi: add missing put_device() call in mtk_smi_device_link_common") Cc: stable@vger.kernel.org # 5.16: 038ae37 Cc: stable@vger.kernel.org # 5.16 Cc: Yong Wu <yong.wu@mediatek.com> Cc: Miaoqian Lin <linmq006@gmail.com> Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20251121164624.13685-2-johan@kernel.org Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Make sure to drop the reference taken when looking up the SMI device during larb probe on late probe failure (e.g. probe deferral) and on driver unbind. Fixes: cc8bbe1 ("memory: mediatek: Add SMI driver") Fixes: 038ae37 ("memory: mtk-smi: add missing put_device() call in mtk_smi_device_link_common") Cc: stable@vger.kernel.org # 4.6: 038ae37 Cc: stable@vger.kernel.org # 4.6 Cc: Yong Wu <yong.wu@mediatek.com> Cc: Miaoqian Lin <linmq006@gmail.com> Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20251121164624.13685-3-johan@kernel.org Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Clean up device link creation by bailing out early in case the SMI platform device lookup fails. Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20251121164624.13685-4-johan@kernel.org Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Member
Author
|
TODO: mmsys (done by claude) mutex (done) ovl (done) dsi (done) drm main (done with mt2701_mmsys_driver_data) |
In MT6589, this IP is called "dispsys" for some reason. I don't know more than that. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
It's in Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml now. Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
everyone will say "fixme" Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Member
Author
|
mmsys routing: |
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
…rray to fix error Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
```
int larb_clock_on(int larb_id)
{
char name[30];
sprintf(name, "smi+%d", larb_id);
switch(larb_id)
{
case 0:
enable_clock(MT_CG_VENC_VEN, name);
break;
case 1:
enable_clock(MT_CG_VDEC0_VDE, name);
enable_clock(MT_CG_VDEC1_SMI, name);
break;
case 2:
enable_clock(MT_CG_DISP0_LARB2_SMI, name);
break;
case 3:
enable_clock(MT_CG_IMAGE_LARB3_SMI, name);
break;
case 4:
enable_clock(MT_CG_IMAGE_LARB4_SMI, name);
break;
case 5:
enable_clock(MT_CG_IMAGE_LARB4_SMI, name);
break;
default:
break;
}
return 0;
}
```
https://github.com/bq/aquaris-5/blob/bc1d0d0e35c969670e2d869001be944ad0c9c5e5/mediatek/platform/mt6589/kernel/drivers/smi/smi_common.c#L120-L154
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Member
Author
|
m4u hacking #define M4U_BASE0 0xf0205200
#define M4U_BASE1 0xf0205800 //0x16010000
#define M4U_BASEg 0xf0205000/* ============================= ==================================
* M4U global
* ============================= ================================== */
#define REG_MMUg_CTRL (0x0+M4U_BASEg)
#define F_MMUg_CTRL_INV_EN0 (1<<0)
#define F_MMUg_CTRL_INV_EN1 (1<<1)
#define F_MMUg_CTRL_INV_EN2 (1<<2)
#define F_MMUg_CTRL_PRE_LOCK(en) F_BIT_VAL(en, 3)
#define F_MMUg_CTRL_PRE_EN (1<<4)
#define REG_MMUg_INVLD (0x4 + M4U_BASEg)
#define F_MMUg_INV_ALL 0x2
#define F_MMUg_INV_RANGE 0x1
#define REG_MMUg_INVLD_SA (0x8 + M4U_BASEg)
#define REG_MMUg_INVLD_EA (0xC + M4U_BASEg)
#define REG_MMUg_PT_BASE (0x10 + M4U_BASEg)
#define F_MMUg_PT_VA_MSK 0xffff0000
#define REG_MMUg_L2_SEL (0x18 + M4U_BASEg)
#define F_MMUg_L2_SEL_FLUSH_EN(en) F_BIT_VAL(en, 3)
#define F_MMUg_L2_SEL_L2_ULTRA(en) F_BIT_VAL(en, 2)
#define F_MMUg_L2_SEL_L2_SHARE(en) F_BIT_VAL(en, 1)
#define F_MMUg_L2_SEL_L2_BUS_SEL(go_emi) F_BIT_VAL(go_emi, 0)
#define REG_MMUg_DCM (0x1C + M4U_BASEg)
#define F_MMUg_DCM_ON(on) F_BIT_VAL(on, 0)
//registers for security
#define REG_MMUg_CTRL_SEC (0x20 + M4U_BASEg)
#define F_MMUg_CTRL_SEC_INV_EN0 (1<<0)
#define F_MMUg_CTRL_SEC_INV_EN1 (1<<1)
#define F_MMUg_CTRL_SEC_INV_EN2 (1<<2)
#define F_MMUg_CTRL_SEC_PRE_LOCK (1<<3)
#define F_MMUg_CTRL_SEC_PRE_EN (1<<4)
#define F_MMUg_CTRL_SEC_DBG (1<<5)
#define REG_MMUg_INVLD_SEC (0x24+M4U_BASEg)
#define F_MMUg_INV_SEC_ALL 0x2
#define F_MMUg_INV_SEC_RANGE 0x1
#define REG_MMUg_INVLD_SA_SEC (0x28+M4U_BASEg)
#define REG_MMUg_INVLD_EA_SEC (0x2C+M4U_BASEg)
#define REG_MMUg_PT_BASE_SEC (0x30+M4U_BASEg)
#define F_MMUg_PT_VA_MSK_SEC 0xffff0000
#define REG_MMUg_SEC_ABORT_INFO (0x34+M4U_BASEg)
#define REG_MMUg_INFA_CTRL (0x80+M4U_BASEg)
#define REG_MMUg_INFA_ST1 (0x84+M4U_BASEg)
#define REG_MMUg_INFA_ST2 (0x88+M4U_BASEg)
#define REG_MMUg_INFA_ST3 (0x8c+M4U_BASEg)mt6572 /* ============================= ==================================
* M4U global
* ============================= ================================== */
#define REG_MMUg_CTRL (0x5D8 + M4U_BASE)
#define F_MMUg_CTRL_INV_EN0 (1<<0)
#define REG_MMUg_INVLD (0x5C0 + M4U_BASE)
#define F_MMUg_INV_ALL 0x2
#define F_MMUg_INV_RANGE 0x1
#define REG_MMUg_INVLD_SA (0x5C4 + M4U_BASE)
#define REG_MMUg_INVLD_EA (0x5C8 + M4U_BASE)
#define REG_MMUg_PT_BASE (0x0 + M4U_BASE)
#define F_MMUg_PT_VA_MSK 0xffff0000 //64kB alignment
#define REG_MMUg_DCM (0x5F0 + M4U_BASEg)
#define F_MMUg_DCM_ON(on) F_BIT_VAL(on, 0)
//registers for security
#define REG_MMUg_CTRL_SEC (0x5DC + M4U_BASE)
#define F_MMUg_CTRL_SEC_INV_EN0 (1<<0)
#define F_MMUg_CTRL_SEC_INV_EN0_MSK (1)
#define F_MMUg_CTRL_SEC_DBG (1<<5)
#define F_SEC_INT_EN (1<<12)
#define REG_MMUg_INVLD_SEC (0x5CC+M4U_BASE)
#define F_MMUg_INV_SEC_RANGE 0x1
#define REG_MMUg_PT_BASE_SEC (0x4 +M4U_BASE)
#define F_MMUg_PT_VA_MSK_SEC 0xffff0000 //64kB alignment#define REG_MMU_FAULT_ST 0x224
#define REG_MMU_FAULT_VA 0x228
#define REG_MMU_INVLD_PA 0x22C
#define REG_MMU_INT_ID 0x388
#define REG_MMU_INVALIDATE 0x5c0
#define REG_MMU_INVLD_START_A 0x5c4
#define REG_MMU_INVLD_END_A 0x5c8linux/drivers/iommu/mtk_iommu_v1.c Lines 70 to 76 in 84cb16e |
```c
static unsigned int m4u_index_of_larb[SMI_LARB_NR] = {0,0,1,0,1};
static unsigned int m4u_index_of_larb5 = 0, m4u_index_of_larb6 = 0;
static unsigned int smi_port0_in_larbx[SMI_LARB_NR+1] = {0, 10, 17, 29, 44 ,56};
static unsigned int m4u_port0_in_larbx[SMI_LARB_NR+1] = {0, 10, 17, 29, 43 ,53};
static unsigned int m4u_port_size_limit[M4U_PORT_NR] = {};
```
https://github.com/bq/aquaris-5/blob/bc1d0d0e35c969670e2d869001be944ad0c9c5e5/mediatek/platform/mt6589/kernel/drivers/m4u/m4u.c#L278-L282
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Member
Author
|
|
Member
Author
|
0x10205000 : M4U_CTRL |
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Member
Author
sleep 15
mount -t debugfs none /sys/kernel/debug
echo "clocksource:"
cat /sys/devices/system/clocksource/clocksource0/current_clocksource
echo "available_clocksource:"
cat /sys/devices/system/clocksource/clocksource0/available_clocksource
echo "block devices:"
ls /sys/class/block/
echo "not proved drivers:"
find /sys/bus/platform/devices/ -maxdepth 1 -mindepth 1 \
'!' -exec test -e "{}/driver" ';' -print | xargs -I {} basename {}
echo "dmesg part:"
dmesg | grep -i "probe failed"
dmesg | grep -i "err"
dmesg | grep -i "unable"
dmesg | grep -i "cannot"
dmesg | grep -i "can't"
dmesg | grep -i "fail"
dmesg | grep -i "waiting on"
#dmesg | grep "mtk-power-controller"
echo "devices_deferred:"
cat /sys/kernel/debug/devices_deferred
echo "pm_genpd_summary:"
cat /sys/kernel/debug/pm_genpd/pm_genpd_summary
ls -l /sys/bus/platform/devices/10205200.iommu/supplier:*
ls -l /sys/bus/platform/devices/14003000.ovl/supplier:*
ls -l /sys/bus/platform/devices/14011000.mutex/supplier:*
while true
do
sleep 15
done |
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Member
Author
|
smi_ao_base |
Member
Author
#define REG_SMI_SECUR_CON(x) (0x05C0+SMI_COMMON_AO_BASE+((x)<<2))
#define REG_SMI_SECUR_CON_OF_PORT(port) REG_SMI_SECUR_CON(((m4u_port_2_smi_port(port))>>3))
#define F_SMI_SECUR_CON_SECURE(port) ((1)<<(((m4u_port_2_smi_port(port))&0x7)<<2))
#define F_SMI_SECUR_CON_DOMAIN(port, val) (((val)&0x3)<<((((m4u_port_2_smi_port(port))&0x7)<<2)+1))
#define F_SMI_SECUR_CON_VIRTUAL(port) ((1)<<((((m4u_port_2_smi_port(port))&0x7)<<2)+3))
#define F_SMI_SECUR_CON_MASK(port) ((0xf)<<((((m4u_port_2_smi_port(port))&0x7)<<2))) |
Member
Author
/* Below are about mmu enable registers, they are different in SoCs */
/* gen1: mt2701 */
#define REG_SMI_SECUR_CON_BASE 0x5c0
/* every register control 8 port, register offset 0x4 */
#define REG_SMI_SECUR_CON_OFFSET(id) (((id) >> 3) << 2)
#define REG_SMI_SECUR_CON_ADDR(id) \
(REG_SMI_SECUR_CON_BASE + REG_SMI_SECUR_CON_OFFSET(id))linux/drivers/memory/mtk-smi.c Lines 65 to 72 in 6316de5 |
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
This reverts commit 6316de5.
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
thanks to rva3
https://github.com/mt6572-mainline/linux