Commit b804923b authored by jason-jh.lin's avatar jason-jh.lin Committed by Matthias Brugger

soc: mediatek: add mtk-mmsys support for mt8195 vdosys0

1. Add mt8195 mmsys compatible for 2 vdosys.
2. Add io_start into each driver data of mt8195 vdosys.
3. Add get match data function to identify mmsys by io_start.
4. Add mt8195 routing table settings of vdosys0.
Signed-off-by: default avatarjason-jh.lin <jason-jh.lin@mediatek.com>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: default avatarRex-BC Chen <rex-bc.chen@mediatek.com>
Reviewed-by: default avatarCK Hu <ck.hu@mediatek.com>
Link: https://lore.kernel.org/r/20220419094143.9561-2-jason-jh.lin@mediatek.comSigned-off-by: default avatarMatthias Brugger <matthias.bgg@gmail.com>
parent 31231092
This diff is collapsed.
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "mt8183-mmsys.h" #include "mt8183-mmsys.h"
#include "mt8186-mmsys.h" #include "mt8186-mmsys.h"
#include "mt8192-mmsys.h" #include "mt8192-mmsys.h"
#include "mt8195-mmsys.h"
#include "mt8365-mmsys.h" #include "mt8365-mmsys.h"
static const struct mtk_mmsys_driver_data mt2701_mmsys_driver_data = { static const struct mtk_mmsys_driver_data mt2701_mmsys_driver_data = {
...@@ -25,26 +26,61 @@ static const struct mtk_mmsys_driver_data mt2701_mmsys_driver_data = { ...@@ -25,26 +26,61 @@ static const struct mtk_mmsys_driver_data mt2701_mmsys_driver_data = {
.num_routes = ARRAY_SIZE(mmsys_default_routing_table), .num_routes = ARRAY_SIZE(mmsys_default_routing_table),
}; };
static const struct mtk_mmsys_match_data mt2701_mmsys_match_data = {
.num_drv_data = 1,
.drv_data = {
&mt2701_mmsys_driver_data,
},
};
static const struct mtk_mmsys_driver_data mt2712_mmsys_driver_data = { static const struct mtk_mmsys_driver_data mt2712_mmsys_driver_data = {
.clk_driver = "clk-mt2712-mm", .clk_driver = "clk-mt2712-mm",
.routes = mmsys_default_routing_table, .routes = mmsys_default_routing_table,
.num_routes = ARRAY_SIZE(mmsys_default_routing_table), .num_routes = ARRAY_SIZE(mmsys_default_routing_table),
}; };
static const struct mtk_mmsys_match_data mt2712_mmsys_match_data = {
.num_drv_data = 1,
.drv_data = {
&mt2712_mmsys_driver_data,
},
};
static const struct mtk_mmsys_driver_data mt6779_mmsys_driver_data = { static const struct mtk_mmsys_driver_data mt6779_mmsys_driver_data = {
.clk_driver = "clk-mt6779-mm", .clk_driver = "clk-mt6779-mm",
}; };
static const struct mtk_mmsys_match_data mt6779_mmsys_match_data = {
.num_drv_data = 1,
.drv_data = {
&mt6779_mmsys_driver_data,
},
};
static const struct mtk_mmsys_driver_data mt6797_mmsys_driver_data = { static const struct mtk_mmsys_driver_data mt6797_mmsys_driver_data = {
.clk_driver = "clk-mt6797-mm", .clk_driver = "clk-mt6797-mm",
}; };
static const struct mtk_mmsys_match_data mt6797_mmsys_match_data = {
.num_drv_data = 1,
.drv_data = {
&mt6797_mmsys_driver_data,
},
};
static const struct mtk_mmsys_driver_data mt8167_mmsys_driver_data = { static const struct mtk_mmsys_driver_data mt8167_mmsys_driver_data = {
.clk_driver = "clk-mt8167-mm", .clk_driver = "clk-mt8167-mm",
.routes = mt8167_mmsys_routing_table, .routes = mt8167_mmsys_routing_table,
.num_routes = ARRAY_SIZE(mt8167_mmsys_routing_table), .num_routes = ARRAY_SIZE(mt8167_mmsys_routing_table),
}; };
static const struct mtk_mmsys_match_data mt8167_mmsys_match_data = {
.num_drv_data = 1,
.drv_data = {
&mt8167_mmsys_driver_data,
},
};
static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = { static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = {
.clk_driver = "clk-mt8173-mm", .clk_driver = "clk-mt8173-mm",
.routes = mmsys_default_routing_table, .routes = mmsys_default_routing_table,
...@@ -52,6 +88,13 @@ static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = { ...@@ -52,6 +88,13 @@ static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = {
.sw0_rst_offset = MT8183_MMSYS_SW0_RST_B, .sw0_rst_offset = MT8183_MMSYS_SW0_RST_B,
}; };
static const struct mtk_mmsys_match_data mt8173_mmsys_match_data = {
.num_drv_data = 1,
.drv_data = {
&mt8173_mmsys_driver_data,
},
};
static const struct mtk_mmsys_driver_data mt8183_mmsys_driver_data = { static const struct mtk_mmsys_driver_data mt8183_mmsys_driver_data = {
.clk_driver = "clk-mt8183-mm", .clk_driver = "clk-mt8183-mm",
.routes = mmsys_mt8183_routing_table, .routes = mmsys_mt8183_routing_table,
...@@ -59,6 +102,13 @@ static const struct mtk_mmsys_driver_data mt8183_mmsys_driver_data = { ...@@ -59,6 +102,13 @@ static const struct mtk_mmsys_driver_data mt8183_mmsys_driver_data = {
.sw0_rst_offset = MT8183_MMSYS_SW0_RST_B, .sw0_rst_offset = MT8183_MMSYS_SW0_RST_B,
}; };
static const struct mtk_mmsys_match_data mt8183_mmsys_match_data = {
.num_drv_data = 1,
.drv_data = {
&mt8183_mmsys_driver_data,
},
};
static const struct mtk_mmsys_driver_data mt8186_mmsys_driver_data = { static const struct mtk_mmsys_driver_data mt8186_mmsys_driver_data = {
.clk_driver = "clk-mt8186-mm", .clk_driver = "clk-mt8186-mm",
.routes = mmsys_mt8186_routing_table, .routes = mmsys_mt8186_routing_table,
...@@ -66,25 +116,79 @@ static const struct mtk_mmsys_driver_data mt8186_mmsys_driver_data = { ...@@ -66,25 +116,79 @@ static const struct mtk_mmsys_driver_data mt8186_mmsys_driver_data = {
.sw0_rst_offset = MT8186_MMSYS_SW0_RST_B, .sw0_rst_offset = MT8186_MMSYS_SW0_RST_B,
}; };
static const struct mtk_mmsys_match_data mt8186_mmsys_match_data = {
.num_drv_data = 1,
.drv_data = {
&mt8186_mmsys_driver_data,
},
};
static const struct mtk_mmsys_driver_data mt8192_mmsys_driver_data = { static const struct mtk_mmsys_driver_data mt8192_mmsys_driver_data = {
.clk_driver = "clk-mt8192-mm", .clk_driver = "clk-mt8192-mm",
.routes = mmsys_mt8192_routing_table, .routes = mmsys_mt8192_routing_table,
.num_routes = ARRAY_SIZE(mmsys_mt8192_routing_table), .num_routes = ARRAY_SIZE(mmsys_mt8192_routing_table),
}; };
static const struct mtk_mmsys_match_data mt8192_mmsys_match_data = {
.num_drv_data = 1,
.drv_data = {
&mt8192_mmsys_driver_data,
},
};
static const struct mtk_mmsys_driver_data mt8195_vdosys0_driver_data = {
.io_start = 0x1c01a000,
.clk_driver = "clk-mt8195-vdo0",
.routes = mmsys_mt8195_routing_table,
.num_routes = ARRAY_SIZE(mmsys_mt8195_routing_table),
};
static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = {
.io_start = 0x1c100000,
.clk_driver = "clk-mt8195-vdo1",
};
static const struct mtk_mmsys_match_data mt8195_mmsys_match_data = {
.num_drv_data = 2,
.drv_data = {
&mt8195_vdosys0_driver_data,
&mt8195_vdosys1_driver_data,
},
};
static const struct mtk_mmsys_driver_data mt8365_mmsys_driver_data = { static const struct mtk_mmsys_driver_data mt8365_mmsys_driver_data = {
.clk_driver = "clk-mt8365-mm", .clk_driver = "clk-mt8365-mm",
.routes = mt8365_mmsys_routing_table, .routes = mt8365_mmsys_routing_table,
.num_routes = ARRAY_SIZE(mt8365_mmsys_routing_table), .num_routes = ARRAY_SIZE(mt8365_mmsys_routing_table),
}; };
static const struct mtk_mmsys_match_data mt8365_mmsys_match_data = {
.num_drv_data = 1,
.drv_data = {
&mt8365_mmsys_driver_data,
},
};
struct mtk_mmsys { struct mtk_mmsys {
void __iomem *regs; void __iomem *regs;
const struct mtk_mmsys_driver_data *data; const struct mtk_mmsys_driver_data *data;
spinlock_t lock; /* protects mmsys_sw_rst_b reg */ spinlock_t lock; /* protects mmsys_sw_rst_b reg */
struct reset_controller_dev rcdev; struct reset_controller_dev rcdev;
phys_addr_t io_start;
}; };
static int mtk_mmsys_find_match_drvdata(struct mtk_mmsys *mmsys,
const struct mtk_mmsys_match_data *match)
{
int i;
for (i = 0; i < match->num_drv_data; i++)
if (mmsys->io_start == match->drv_data[i]->io_start)
return i;
return -EINVAL;
}
void mtk_mmsys_ddp_connect(struct device *dev, void mtk_mmsys_ddp_connect(struct device *dev,
enum mtk_ddp_comp_id cur, enum mtk_ddp_comp_id cur,
enum mtk_ddp_comp_id next) enum mtk_ddp_comp_id next)
...@@ -179,7 +283,9 @@ static int mtk_mmsys_probe(struct platform_device *pdev) ...@@ -179,7 +283,9 @@ static int mtk_mmsys_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct platform_device *clks; struct platform_device *clks;
struct platform_device *drm; struct platform_device *drm;
const struct mtk_mmsys_match_data *match_data;
struct mtk_mmsys *mmsys; struct mtk_mmsys *mmsys;
struct resource *res;
int ret; int ret;
mmsys = devm_kzalloc(dev, sizeof(*mmsys), GFP_KERNEL); mmsys = devm_kzalloc(dev, sizeof(*mmsys), GFP_KERNEL);
...@@ -205,7 +311,27 @@ static int mtk_mmsys_probe(struct platform_device *pdev) ...@@ -205,7 +311,27 @@ static int mtk_mmsys_probe(struct platform_device *pdev)
return ret; return ret;
} }
mmsys->data = of_device_get_match_data(&pdev->dev); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(dev, "Couldn't get mmsys resource\n");
return -EINVAL;
}
mmsys->io_start = res->start;
match_data = of_device_get_match_data(dev);
if (match_data->num_drv_data > 1) {
/* This SoC has multiple mmsys channels */
ret = mtk_mmsys_find_match_drvdata(mmsys, match_data);
if (ret < 0) {
dev_err(dev, "Couldn't get match driver data\n");
return ret;
}
mmsys->data = match_data->drv_data[ret];
} else {
dev_dbg(dev, "Using single mmsys channel\n");
mmsys->data = match_data->drv_data[0];
}
platform_set_drvdata(pdev, mmsys); platform_set_drvdata(pdev, mmsys);
clks = platform_device_register_data(&pdev->dev, mmsys->data->clk_driver, clks = platform_device_register_data(&pdev->dev, mmsys->data->clk_driver,
...@@ -226,43 +352,47 @@ static int mtk_mmsys_probe(struct platform_device *pdev) ...@@ -226,43 +352,47 @@ static int mtk_mmsys_probe(struct platform_device *pdev)
static const struct of_device_id of_match_mtk_mmsys[] = { static const struct of_device_id of_match_mtk_mmsys[] = {
{ {
.compatible = "mediatek,mt2701-mmsys", .compatible = "mediatek,mt2701-mmsys",
.data = &mt2701_mmsys_driver_data, .data = &mt2701_mmsys_match_data,
}, },
{ {
.compatible = "mediatek,mt2712-mmsys", .compatible = "mediatek,mt2712-mmsys",
.data = &mt2712_mmsys_driver_data, .data = &mt2712_mmsys_match_data,
}, },
{ {
.compatible = "mediatek,mt6779-mmsys", .compatible = "mediatek,mt6779-mmsys",
.data = &mt6779_mmsys_driver_data, .data = &mt6779_mmsys_match_data,
}, },
{ {
.compatible = "mediatek,mt6797-mmsys", .compatible = "mediatek,mt6797-mmsys",
.data = &mt6797_mmsys_driver_data, .data = &mt6797_mmsys_match_data,
}, },
{ {
.compatible = "mediatek,mt8167-mmsys", .compatible = "mediatek,mt8167-mmsys",
.data = &mt8167_mmsys_driver_data, .data = &mt8167_mmsys_match_data,
}, },
{ {
.compatible = "mediatek,mt8173-mmsys", .compatible = "mediatek,mt8173-mmsys",
.data = &mt8173_mmsys_driver_data, .data = &mt8173_mmsys_match_data,
}, },
{ {
.compatible = "mediatek,mt8183-mmsys", .compatible = "mediatek,mt8183-mmsys",
.data = &mt8183_mmsys_driver_data, .data = &mt8183_mmsys_match_data,
}, },
{ {
.compatible = "mediatek,mt8186-mmsys", .compatible = "mediatek,mt8186-mmsys",
.data = &mt8186_mmsys_driver_data, .data = &mt8186_mmsys_match_data,
}, },
{ {
.compatible = "mediatek,mt8192-mmsys", .compatible = "mediatek,mt8192-mmsys",
.data = &mt8192_mmsys_driver_data, .data = &mt8192_mmsys_match_data,
},
{
.compatible = "mediatek,mt8195-mmsys",
.data = &mt8195_mmsys_match_data,
}, },
{ {
.compatible = "mediatek,mt8365-mmsys", .compatible = "mediatek,mt8365-mmsys",
.data = &mt8365_mmsys_driver_data, .data = &mt8365_mmsys_match_data,
}, },
{ } { }
}; };
......
...@@ -87,12 +87,18 @@ struct mtk_mmsys_routes { ...@@ -87,12 +87,18 @@ struct mtk_mmsys_routes {
}; };
struct mtk_mmsys_driver_data { struct mtk_mmsys_driver_data {
const resource_size_t io_start;
const char *clk_driver; const char *clk_driver;
const struct mtk_mmsys_routes *routes; const struct mtk_mmsys_routes *routes;
const unsigned int num_routes; const unsigned int num_routes;
const u16 sw0_rst_offset; const u16 sw0_rst_offset;
}; };
struct mtk_mmsys_match_data {
unsigned short num_drv_data;
const struct mtk_mmsys_driver_data *drv_data[];
};
/* /*
* Routes in mt8173, mt2701, mt2712 are different. That means * Routes in mt8173, mt2701, mt2712 are different. That means
* in the same register address, it controls different input/output * in the same register address, it controls different input/output
......
...@@ -17,13 +17,24 @@ enum mtk_ddp_comp_id { ...@@ -17,13 +17,24 @@ enum mtk_ddp_comp_id {
DDP_COMPONENT_COLOR0, DDP_COMPONENT_COLOR0,
DDP_COMPONENT_COLOR1, DDP_COMPONENT_COLOR1,
DDP_COMPONENT_DITHER, DDP_COMPONENT_DITHER,
DDP_COMPONENT_DITHER1,
DDP_COMPONENT_DP_INTF0,
DDP_COMPONENT_DP_INTF1,
DDP_COMPONENT_DPI0, DDP_COMPONENT_DPI0,
DDP_COMPONENT_DPI1, DDP_COMPONENT_DPI1,
DDP_COMPONENT_DSC0,
DDP_COMPONENT_DSC1,
DDP_COMPONENT_DSI0, DDP_COMPONENT_DSI0,
DDP_COMPONENT_DSI1, DDP_COMPONENT_DSI1,
DDP_COMPONENT_DSI2, DDP_COMPONENT_DSI2,
DDP_COMPONENT_DSI3, DDP_COMPONENT_DSI3,
DDP_COMPONENT_GAMMA, DDP_COMPONENT_GAMMA,
DDP_COMPONENT_MERGE0,
DDP_COMPONENT_MERGE1,
DDP_COMPONENT_MERGE2,
DDP_COMPONENT_MERGE3,
DDP_COMPONENT_MERGE4,
DDP_COMPONENT_MERGE5,
DDP_COMPONENT_OD0, DDP_COMPONENT_OD0,
DDP_COMPONENT_OD1, DDP_COMPONENT_OD1,
DDP_COMPONENT_OVL0, DDP_COMPONENT_OVL0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment