12016e211SJiucheng Xu // SPDX-License-Identifier: GPL-2.0
22016e211SJiucheng Xu /*
32016e211SJiucheng Xu * Copyright (c) 2022 Amlogic, Inc. All rights reserved.
42016e211SJiucheng Xu */
52016e211SJiucheng Xu
62016e211SJiucheng Xu #include <linux/err.h>
77299fdc1SJiucheng Xu #include <linux/io.h>
82016e211SJiucheng Xu #include <linux/kernel.h>
92016e211SJiucheng Xu #include <linux/module.h>
102016e211SJiucheng Xu #include <linux/of.h>
112016e211SJiucheng Xu #include <linux/perf_event.h>
122016e211SJiucheng Xu #include <linux/platform_device.h>
132016e211SJiucheng Xu #include <linux/printk.h>
142016e211SJiucheng Xu #include <linux/types.h>
152016e211SJiucheng Xu
162016e211SJiucheng Xu #include <soc/amlogic/meson_ddr_pmu.h>
172016e211SJiucheng Xu
182016e211SJiucheng Xu #define PORT_MAJOR 32
192016e211SJiucheng Xu #define DEFAULT_XTAL_FREQ 24000000UL
202016e211SJiucheng Xu
212016e211SJiucheng Xu #define DMC_QOS_IRQ BIT(30)
222016e211SJiucheng Xu
232016e211SJiucheng Xu /* DMC bandwidth monitor register address offset */
24f9d323e7SMarc Gonzalez #define DMC_MON_G12_CTRL0 (0x0 << 2)
25f9d323e7SMarc Gonzalez #define DMC_MON_G12_CTRL1 (0x1 << 2)
26f9d323e7SMarc Gonzalez #define DMC_MON_G12_CTRL2 (0x2 << 2)
27f9d323e7SMarc Gonzalez #define DMC_MON_G12_CTRL3 (0x3 << 2)
28f9d323e7SMarc Gonzalez #define DMC_MON_G12_CTRL4 (0x4 << 2)
29f9d323e7SMarc Gonzalez #define DMC_MON_G12_CTRL5 (0x5 << 2)
30f9d323e7SMarc Gonzalez #define DMC_MON_G12_CTRL6 (0x6 << 2)
31f9d323e7SMarc Gonzalez #define DMC_MON_G12_CTRL7 (0x7 << 2)
32f9d323e7SMarc Gonzalez #define DMC_MON_G12_CTRL8 (0x8 << 2)
332016e211SJiucheng Xu
34f9d323e7SMarc Gonzalez #define DMC_MON_G12_ALL_REQ_CNT (0x9 << 2)
35f9d323e7SMarc Gonzalez #define DMC_MON_G12_ALL_GRANT_CNT (0xa << 2)
36f9d323e7SMarc Gonzalez #define DMC_MON_G12_ONE_GRANT_CNT (0xb << 2)
37f9d323e7SMarc Gonzalez #define DMC_MON_G12_SEC_GRANT_CNT (0xc << 2)
38f9d323e7SMarc Gonzalez #define DMC_MON_G12_THD_GRANT_CNT (0xd << 2)
39f9d323e7SMarc Gonzalez #define DMC_MON_G12_FOR_GRANT_CNT (0xe << 2)
40f9d323e7SMarc Gonzalez #define DMC_MON_G12_TIMER (0xf << 2)
412016e211SJiucheng Xu
422016e211SJiucheng Xu /* Each bit represent a axi line */
432016e211SJiucheng Xu PMU_FORMAT_ATTR(event, "config:0-7");
442016e211SJiucheng Xu PMU_FORMAT_ATTR(arm, "config1:0");
452016e211SJiucheng Xu PMU_FORMAT_ATTR(gpu, "config1:1");
462016e211SJiucheng Xu PMU_FORMAT_ATTR(pcie, "config1:2");
472016e211SJiucheng Xu PMU_FORMAT_ATTR(hdcp, "config1:3");
482016e211SJiucheng Xu PMU_FORMAT_ATTR(hevc_front, "config1:4");
492016e211SJiucheng Xu PMU_FORMAT_ATTR(usb3_0, "config1:6");
502016e211SJiucheng Xu PMU_FORMAT_ATTR(device, "config1:7");
512016e211SJiucheng Xu PMU_FORMAT_ATTR(hevc_back, "config1:8");
522016e211SJiucheng Xu PMU_FORMAT_ATTR(h265enc, "config1:9");
532016e211SJiucheng Xu PMU_FORMAT_ATTR(vpu_read1, "config1:16");
542016e211SJiucheng Xu PMU_FORMAT_ATTR(vpu_read2, "config1:17");
552016e211SJiucheng Xu PMU_FORMAT_ATTR(vpu_read3, "config1:18");
562016e211SJiucheng Xu PMU_FORMAT_ATTR(vpu_write1, "config1:19");
572016e211SJiucheng Xu PMU_FORMAT_ATTR(vpu_write2, "config1:20");
582016e211SJiucheng Xu PMU_FORMAT_ATTR(vdec, "config1:21");
592016e211SJiucheng Xu PMU_FORMAT_ATTR(hcodec, "config1:22");
602016e211SJiucheng Xu PMU_FORMAT_ATTR(ge2d, "config1:23");
612016e211SJiucheng Xu
622016e211SJiucheng Xu PMU_FORMAT_ATTR(spicc1, "config1:32");
632016e211SJiucheng Xu PMU_FORMAT_ATTR(usb0, "config1:33");
642016e211SJiucheng Xu PMU_FORMAT_ATTR(dma, "config1:34");
652016e211SJiucheng Xu PMU_FORMAT_ATTR(arb0, "config1:35");
662016e211SJiucheng Xu PMU_FORMAT_ATTR(sd_emmc_b, "config1:36");
672016e211SJiucheng Xu PMU_FORMAT_ATTR(usb1, "config1:37");
682016e211SJiucheng Xu PMU_FORMAT_ATTR(audio, "config1:38");
692016e211SJiucheng Xu PMU_FORMAT_ATTR(aififo, "config1:39");
702016e211SJiucheng Xu PMU_FORMAT_ATTR(parser, "config1:41");
712016e211SJiucheng Xu PMU_FORMAT_ATTR(ao_cpu, "config1:42");
722016e211SJiucheng Xu PMU_FORMAT_ATTR(sd_emmc_c, "config1:43");
732016e211SJiucheng Xu PMU_FORMAT_ATTR(spicc2, "config1:44");
742016e211SJiucheng Xu PMU_FORMAT_ATTR(ethernet, "config1:45");
752016e211SJiucheng Xu PMU_FORMAT_ATTR(sana, "config1:46");
762016e211SJiucheng Xu
772016e211SJiucheng Xu /* for sm1 and g12b */
782016e211SJiucheng Xu PMU_FORMAT_ATTR(nna, "config1:10");
792016e211SJiucheng Xu
802016e211SJiucheng Xu /* for g12b only */
812016e211SJiucheng Xu PMU_FORMAT_ATTR(gdc, "config1:11");
822016e211SJiucheng Xu PMU_FORMAT_ATTR(mipi_isp, "config1:12");
832016e211SJiucheng Xu PMU_FORMAT_ATTR(arm1, "config1:13");
842016e211SJiucheng Xu PMU_FORMAT_ATTR(sd_emmc_a, "config1:40");
852016e211SJiucheng Xu
862016e211SJiucheng Xu static struct attribute *g12_pmu_format_attrs[] = {
872016e211SJiucheng Xu &format_attr_event.attr,
882016e211SJiucheng Xu &format_attr_arm.attr,
892016e211SJiucheng Xu &format_attr_gpu.attr,
902016e211SJiucheng Xu &format_attr_nna.attr,
912016e211SJiucheng Xu &format_attr_gdc.attr,
922016e211SJiucheng Xu &format_attr_arm1.attr,
932016e211SJiucheng Xu &format_attr_mipi_isp.attr,
942016e211SJiucheng Xu &format_attr_sd_emmc_a.attr,
952016e211SJiucheng Xu &format_attr_pcie.attr,
962016e211SJiucheng Xu &format_attr_hdcp.attr,
972016e211SJiucheng Xu &format_attr_hevc_front.attr,
982016e211SJiucheng Xu &format_attr_usb3_0.attr,
992016e211SJiucheng Xu &format_attr_device.attr,
1002016e211SJiucheng Xu &format_attr_hevc_back.attr,
1012016e211SJiucheng Xu &format_attr_h265enc.attr,
1022016e211SJiucheng Xu &format_attr_vpu_read1.attr,
1032016e211SJiucheng Xu &format_attr_vpu_read2.attr,
1042016e211SJiucheng Xu &format_attr_vpu_read3.attr,
1052016e211SJiucheng Xu &format_attr_vpu_write1.attr,
1062016e211SJiucheng Xu &format_attr_vpu_write2.attr,
1072016e211SJiucheng Xu &format_attr_vdec.attr,
1082016e211SJiucheng Xu &format_attr_hcodec.attr,
1092016e211SJiucheng Xu &format_attr_ge2d.attr,
1102016e211SJiucheng Xu &format_attr_spicc1.attr,
1112016e211SJiucheng Xu &format_attr_usb0.attr,
1122016e211SJiucheng Xu &format_attr_dma.attr,
1132016e211SJiucheng Xu &format_attr_arb0.attr,
1142016e211SJiucheng Xu &format_attr_sd_emmc_b.attr,
1152016e211SJiucheng Xu &format_attr_usb1.attr,
1162016e211SJiucheng Xu &format_attr_audio.attr,
1172016e211SJiucheng Xu &format_attr_aififo.attr,
1182016e211SJiucheng Xu &format_attr_parser.attr,
1192016e211SJiucheng Xu &format_attr_ao_cpu.attr,
1202016e211SJiucheng Xu &format_attr_sd_emmc_c.attr,
1212016e211SJiucheng Xu &format_attr_spicc2.attr,
1222016e211SJiucheng Xu &format_attr_ethernet.attr,
1232016e211SJiucheng Xu &format_attr_sana.attr,
1242016e211SJiucheng Xu NULL,
1252016e211SJiucheng Xu };
1262016e211SJiucheng Xu
1272016e211SJiucheng Xu /* calculate ddr clock */
dmc_g12_get_freq_quick(struct dmc_info * info)1282016e211SJiucheng Xu static unsigned long dmc_g12_get_freq_quick(struct dmc_info *info)
1292016e211SJiucheng Xu {
1302016e211SJiucheng Xu unsigned int val;
1312016e211SJiucheng Xu unsigned int n, m, od1;
1322016e211SJiucheng Xu unsigned int od_div = 0xfff;
1332016e211SJiucheng Xu unsigned long freq = 0;
1342016e211SJiucheng Xu
1352016e211SJiucheng Xu val = readl(info->pll_reg);
1362016e211SJiucheng Xu val = val & 0xfffff;
1372016e211SJiucheng Xu switch ((val >> 16) & 7) {
1382016e211SJiucheng Xu case 0:
1392016e211SJiucheng Xu od_div = 2;
1402016e211SJiucheng Xu break;
1412016e211SJiucheng Xu
1422016e211SJiucheng Xu case 1:
1432016e211SJiucheng Xu od_div = 3;
1442016e211SJiucheng Xu break;
1452016e211SJiucheng Xu
1462016e211SJiucheng Xu case 2:
1472016e211SJiucheng Xu od_div = 4;
1482016e211SJiucheng Xu break;
1492016e211SJiucheng Xu
1502016e211SJiucheng Xu case 3:
1512016e211SJiucheng Xu od_div = 6;
1522016e211SJiucheng Xu break;
1532016e211SJiucheng Xu
1542016e211SJiucheng Xu case 4:
1552016e211SJiucheng Xu od_div = 8;
1562016e211SJiucheng Xu break;
1572016e211SJiucheng Xu
1582016e211SJiucheng Xu default:
1592016e211SJiucheng Xu break;
1602016e211SJiucheng Xu }
1612016e211SJiucheng Xu
1622016e211SJiucheng Xu m = val & 0x1ff;
1632016e211SJiucheng Xu n = ((val >> 10) & 0x1f);
1642016e211SJiucheng Xu od1 = (((val >> 19) & 0x1)) == 1 ? 2 : 1;
1652016e211SJiucheng Xu freq = DEFAULT_XTAL_FREQ / 1000; /* avoid overflow */
1662016e211SJiucheng Xu if (n)
1672016e211SJiucheng Xu freq = ((((freq * m) / n) >> od1) / od_div) * 1000;
1682016e211SJiucheng Xu
1692016e211SJiucheng Xu return freq;
1702016e211SJiucheng Xu }
1712016e211SJiucheng Xu
1722016e211SJiucheng Xu #ifdef DEBUG
g12_dump_reg(struct dmc_info * db)1732016e211SJiucheng Xu static void g12_dump_reg(struct dmc_info *db)
1742016e211SJiucheng Xu {
1752016e211SJiucheng Xu int s = 0, i;
1762016e211SJiucheng Xu unsigned int r;
1772016e211SJiucheng Xu
1782016e211SJiucheng Xu for (i = 0; i < 9; i++) {
1792016e211SJiucheng Xu r = readl(db->ddr_reg[0] + (DMC_MON_G12_CTRL0 + (i << 2)));
1802016e211SJiucheng Xu pr_notice("DMC_MON_CTRL%d: %08x\n", i, r);
1812016e211SJiucheng Xu }
1822016e211SJiucheng Xu r = readl(db->ddr_reg[0] + DMC_MON_G12_ALL_REQ_CNT);
1832016e211SJiucheng Xu pr_notice("DMC_MON_ALL_REQ_CNT: %08x\n", r);
1842016e211SJiucheng Xu r = readl(db->ddr_reg[0] + DMC_MON_G12_ALL_GRANT_CNT);
1852016e211SJiucheng Xu pr_notice("DMC_MON_ALL_GRANT_CNT:%08x\n", r);
1862016e211SJiucheng Xu r = readl(db->ddr_reg[0] + DMC_MON_G12_ONE_GRANT_CNT);
1872016e211SJiucheng Xu pr_notice("DMC_MON_ONE_GRANT_CNT:%08x\n", r);
1882016e211SJiucheng Xu r = readl(db->ddr_reg[0] + DMC_MON_G12_SEC_GRANT_CNT);
1892016e211SJiucheng Xu pr_notice("DMC_MON_SEC_GRANT_CNT:%08x\n", r);
1902016e211SJiucheng Xu r = readl(db->ddr_reg[0] + DMC_MON_G12_THD_GRANT_CNT);
1912016e211SJiucheng Xu pr_notice("DMC_MON_THD_GRANT_CNT:%08x\n", r);
1922016e211SJiucheng Xu r = readl(db->ddr_reg[0] + DMC_MON_G12_FOR_GRANT_CNT);
1932016e211SJiucheng Xu pr_notice("DMC_MON_FOR_GRANT_CNT:%08x\n", r);
1942016e211SJiucheng Xu r = readl(db->ddr_reg[0] + DMC_MON_G12_TIMER);
1952016e211SJiucheng Xu pr_notice("DMC_MON_TIMER: %08x\n", r);
1962016e211SJiucheng Xu }
1972016e211SJiucheng Xu #endif
1982016e211SJiucheng Xu
dmc_g12_counter_enable(struct dmc_info * info)1992016e211SJiucheng Xu static void dmc_g12_counter_enable(struct dmc_info *info)
2002016e211SJiucheng Xu {
2012016e211SJiucheng Xu unsigned int val;
2022016e211SJiucheng Xu unsigned long clock_count = dmc_g12_get_freq_quick(info) / 10; /* 100ms */
2032016e211SJiucheng Xu
2042016e211SJiucheng Xu writel(clock_count, info->ddr_reg[0] + DMC_MON_G12_TIMER);
2052016e211SJiucheng Xu
2062016e211SJiucheng Xu val = readl(info->ddr_reg[0] + DMC_MON_G12_CTRL0);
2072016e211SJiucheng Xu
2082016e211SJiucheng Xu /* enable all channel */
2092016e211SJiucheng Xu val = BIT(31) | /* enable bit */
2102016e211SJiucheng Xu BIT(20) | /* use timer */
2112016e211SJiucheng Xu 0x0f; /* 4 channels */
2122016e211SJiucheng Xu
2132016e211SJiucheng Xu writel(val, info->ddr_reg[0] + DMC_MON_G12_CTRL0);
2142016e211SJiucheng Xu
2152016e211SJiucheng Xu #ifdef DEBUG
2162016e211SJiucheng Xu g12_dump_reg(info);
2172016e211SJiucheng Xu #endif
2182016e211SJiucheng Xu }
2192016e211SJiucheng Xu
dmc_g12_config_fiter(struct dmc_info * info,int port,int channel)2202016e211SJiucheng Xu static void dmc_g12_config_fiter(struct dmc_info *info,
2212016e211SJiucheng Xu int port, int channel)
2222016e211SJiucheng Xu {
2232016e211SJiucheng Xu u32 val;
2242016e211SJiucheng Xu u32 rp[MAX_CHANNEL_NUM] = {DMC_MON_G12_CTRL1, DMC_MON_G12_CTRL3,
2252016e211SJiucheng Xu DMC_MON_G12_CTRL5, DMC_MON_G12_CTRL7};
2262016e211SJiucheng Xu u32 rs[MAX_CHANNEL_NUM] = {DMC_MON_G12_CTRL2, DMC_MON_G12_CTRL4,
2272016e211SJiucheng Xu DMC_MON_G12_CTRL6, DMC_MON_G12_CTRL8};
2282016e211SJiucheng Xu int subport = -1;
2292016e211SJiucheng Xu
2302016e211SJiucheng Xu /* clear all port mask */
2312016e211SJiucheng Xu if (port < 0) {
2322016e211SJiucheng Xu writel(0, info->ddr_reg[0] + rp[channel]);
2332016e211SJiucheng Xu writel(0, info->ddr_reg[0] + rs[channel]);
2342016e211SJiucheng Xu return;
2352016e211SJiucheng Xu }
2362016e211SJiucheng Xu
2372016e211SJiucheng Xu if (port >= PORT_MAJOR)
2382016e211SJiucheng Xu subport = port - PORT_MAJOR;
2392016e211SJiucheng Xu
2402016e211SJiucheng Xu if (subport < 0) {
2412016e211SJiucheng Xu val = readl(info->ddr_reg[0] + rp[channel]);
2422016e211SJiucheng Xu val |= (1 << port);
2432016e211SJiucheng Xu writel(val, info->ddr_reg[0] + rp[channel]);
2442016e211SJiucheng Xu val = 0xffff;
2452016e211SJiucheng Xu writel(val, info->ddr_reg[0] + rs[channel]);
2462016e211SJiucheng Xu } else {
2472016e211SJiucheng Xu val = BIT(23); /* select device */
2482016e211SJiucheng Xu writel(val, info->ddr_reg[0] + rp[channel]);
2492016e211SJiucheng Xu val = readl(info->ddr_reg[0] + rs[channel]);
2502016e211SJiucheng Xu val |= (1 << subport);
2512016e211SJiucheng Xu writel(val, info->ddr_reg[0] + rs[channel]);
2522016e211SJiucheng Xu }
2532016e211SJiucheng Xu }
2542016e211SJiucheng Xu
dmc_g12_set_axi_filter(struct dmc_info * info,int axi_id,int channel)2552016e211SJiucheng Xu static void dmc_g12_set_axi_filter(struct dmc_info *info, int axi_id, int channel)
2562016e211SJiucheng Xu {
2572016e211SJiucheng Xu if (channel > info->hw_info->chann_nr)
2582016e211SJiucheng Xu return;
2592016e211SJiucheng Xu
2602016e211SJiucheng Xu dmc_g12_config_fiter(info, axi_id, channel);
2612016e211SJiucheng Xu }
2622016e211SJiucheng Xu
dmc_g12_counter_disable(struct dmc_info * info)2632016e211SJiucheng Xu static void dmc_g12_counter_disable(struct dmc_info *info)
2642016e211SJiucheng Xu {
2652016e211SJiucheng Xu int i;
2662016e211SJiucheng Xu
2672016e211SJiucheng Xu /* clear timer */
2682016e211SJiucheng Xu writel(0, info->ddr_reg[0] + DMC_MON_G12_CTRL0);
2692016e211SJiucheng Xu writel(0, info->ddr_reg[0] + DMC_MON_G12_TIMER);
2702016e211SJiucheng Xu
2712016e211SJiucheng Xu writel(0, info->ddr_reg[0] + DMC_MON_G12_ALL_REQ_CNT);
2722016e211SJiucheng Xu writel(0, info->ddr_reg[0] + DMC_MON_G12_ALL_GRANT_CNT);
2732016e211SJiucheng Xu writel(0, info->ddr_reg[0] + DMC_MON_G12_ONE_GRANT_CNT);
2742016e211SJiucheng Xu writel(0, info->ddr_reg[0] + DMC_MON_G12_SEC_GRANT_CNT);
2752016e211SJiucheng Xu writel(0, info->ddr_reg[0] + DMC_MON_G12_THD_GRANT_CNT);
2762016e211SJiucheng Xu writel(0, info->ddr_reg[0] + DMC_MON_G12_FOR_GRANT_CNT);
2772016e211SJiucheng Xu
2782016e211SJiucheng Xu /* clear port channel mapping */
2792016e211SJiucheng Xu for (i = 0; i < info->hw_info->chann_nr; i++)
2802016e211SJiucheng Xu dmc_g12_config_fiter(info, -1, i);
2812016e211SJiucheng Xu }
2822016e211SJiucheng Xu
dmc_g12_get_counters(struct dmc_info * info,struct dmc_counter * counter)2832016e211SJiucheng Xu static void dmc_g12_get_counters(struct dmc_info *info,
2842016e211SJiucheng Xu struct dmc_counter *counter)
2852016e211SJiucheng Xu {
2862016e211SJiucheng Xu int i;
2872016e211SJiucheng Xu unsigned int reg;
2882016e211SJiucheng Xu
2892016e211SJiucheng Xu counter->all_cnt = readl(info->ddr_reg[0] + DMC_MON_G12_ALL_GRANT_CNT);
2902016e211SJiucheng Xu counter->all_req = readl(info->ddr_reg[0] + DMC_MON_G12_ALL_REQ_CNT);
2912016e211SJiucheng Xu
2922016e211SJiucheng Xu for (i = 0; i < info->hw_info->chann_nr; i++) {
2932016e211SJiucheng Xu reg = DMC_MON_G12_ONE_GRANT_CNT + (i << 2);
2942016e211SJiucheng Xu counter->channel_cnt[i] = readl(info->ddr_reg[0] + reg);
2952016e211SJiucheng Xu }
2962016e211SJiucheng Xu }
2972016e211SJiucheng Xu
dmc_g12_irq_handler(struct dmc_info * info,struct dmc_counter * counter)2982016e211SJiucheng Xu static int dmc_g12_irq_handler(struct dmc_info *info,
2992016e211SJiucheng Xu struct dmc_counter *counter)
3002016e211SJiucheng Xu {
3012016e211SJiucheng Xu unsigned int val;
3022016e211SJiucheng Xu int ret = -EINVAL;
3032016e211SJiucheng Xu
3042016e211SJiucheng Xu val = readl(info->ddr_reg[0] + DMC_MON_G12_CTRL0);
3052016e211SJiucheng Xu if (val & DMC_QOS_IRQ) {
3062016e211SJiucheng Xu dmc_g12_get_counters(info, counter);
3072016e211SJiucheng Xu /* clear irq flags */
3082016e211SJiucheng Xu writel(val, info->ddr_reg[0] + DMC_MON_G12_CTRL0);
3092016e211SJiucheng Xu ret = 0;
3102016e211SJiucheng Xu }
3112016e211SJiucheng Xu return ret;
3122016e211SJiucheng Xu }
3132016e211SJiucheng Xu
3142016e211SJiucheng Xu static const struct dmc_hw_info g12a_dmc_info = {
3152016e211SJiucheng Xu .enable = dmc_g12_counter_enable,
3162016e211SJiucheng Xu .disable = dmc_g12_counter_disable,
3172016e211SJiucheng Xu .irq_handler = dmc_g12_irq_handler,
3182016e211SJiucheng Xu .get_counters = dmc_g12_get_counters,
3192016e211SJiucheng Xu .set_axi_filter = dmc_g12_set_axi_filter,
3202016e211SJiucheng Xu
3212016e211SJiucheng Xu .dmc_nr = 1,
3222016e211SJiucheng Xu .chann_nr = 4,
3232016e211SJiucheng Xu .capability = {0X7EFF00FF03DF, 0},
3242016e211SJiucheng Xu .fmt_attr = g12_pmu_format_attrs,
3252016e211SJiucheng Xu };
3262016e211SJiucheng Xu
3272016e211SJiucheng Xu static const struct dmc_hw_info g12b_dmc_info = {
3282016e211SJiucheng Xu .enable = dmc_g12_counter_enable,
3292016e211SJiucheng Xu .disable = dmc_g12_counter_disable,
3302016e211SJiucheng Xu .irq_handler = dmc_g12_irq_handler,
3312016e211SJiucheng Xu .get_counters = dmc_g12_get_counters,
3322016e211SJiucheng Xu .set_axi_filter = dmc_g12_set_axi_filter,
3332016e211SJiucheng Xu
3342016e211SJiucheng Xu .dmc_nr = 1,
3352016e211SJiucheng Xu .chann_nr = 4,
3362016e211SJiucheng Xu .capability = {0X7FFF00FF3FDF, 0},
3372016e211SJiucheng Xu .fmt_attr = g12_pmu_format_attrs,
3382016e211SJiucheng Xu };
3392016e211SJiucheng Xu
3402016e211SJiucheng Xu static const struct dmc_hw_info sm1_dmc_info = {
3412016e211SJiucheng Xu .enable = dmc_g12_counter_enable,
3422016e211SJiucheng Xu .disable = dmc_g12_counter_disable,
3432016e211SJiucheng Xu .irq_handler = dmc_g12_irq_handler,
3442016e211SJiucheng Xu .get_counters = dmc_g12_get_counters,
3452016e211SJiucheng Xu .set_axi_filter = dmc_g12_set_axi_filter,
3462016e211SJiucheng Xu
3472016e211SJiucheng Xu .dmc_nr = 1,
3482016e211SJiucheng Xu .chann_nr = 4,
3492016e211SJiucheng Xu .capability = {0X7EFF00FF07DF, 0},
3502016e211SJiucheng Xu .fmt_attr = g12_pmu_format_attrs,
3512016e211SJiucheng Xu };
3522016e211SJiucheng Xu
g12_ddr_pmu_probe(struct platform_device * pdev)3532016e211SJiucheng Xu static int g12_ddr_pmu_probe(struct platform_device *pdev)
3542016e211SJiucheng Xu {
3552016e211SJiucheng Xu return meson_ddr_pmu_create(pdev);
3562016e211SJiucheng Xu }
3572016e211SJiucheng Xu
g12_ddr_pmu_remove(struct platform_device * pdev)358*94843f26SUwe Kleine-König static void g12_ddr_pmu_remove(struct platform_device *pdev)
3592016e211SJiucheng Xu {
3602016e211SJiucheng Xu meson_ddr_pmu_remove(pdev);
3612016e211SJiucheng Xu }
3622016e211SJiucheng Xu
3632016e211SJiucheng Xu static const struct of_device_id meson_ddr_pmu_dt_match[] = {
3642016e211SJiucheng Xu {
3652016e211SJiucheng Xu .compatible = "amlogic,g12a-ddr-pmu",
3662016e211SJiucheng Xu .data = &g12a_dmc_info,
3672016e211SJiucheng Xu },
3682016e211SJiucheng Xu {
3692016e211SJiucheng Xu .compatible = "amlogic,g12b-ddr-pmu",
3702016e211SJiucheng Xu .data = &g12b_dmc_info,
3712016e211SJiucheng Xu },
3722016e211SJiucheng Xu {
3732016e211SJiucheng Xu .compatible = "amlogic,sm1-ddr-pmu",
3742016e211SJiucheng Xu .data = &sm1_dmc_info,
3752016e211SJiucheng Xu },
3762016e211SJiucheng Xu {}
3772016e211SJiucheng Xu };
37832269e09SMarek Szyprowski MODULE_DEVICE_TABLE(of, meson_ddr_pmu_dt_match);
3792016e211SJiucheng Xu
3802016e211SJiucheng Xu static struct platform_driver g12_ddr_pmu_driver = {
3812016e211SJiucheng Xu .probe = g12_ddr_pmu_probe,
382*94843f26SUwe Kleine-König .remove_new = g12_ddr_pmu_remove,
3832016e211SJiucheng Xu
3842016e211SJiucheng Xu .driver = {
3852016e211SJiucheng Xu .name = "meson-g12-ddr-pmu",
3862016e211SJiucheng Xu .of_match_table = meson_ddr_pmu_dt_match,
3872016e211SJiucheng Xu },
3882016e211SJiucheng Xu };
3892016e211SJiucheng Xu
3902016e211SJiucheng Xu module_platform_driver(g12_ddr_pmu_driver);
3912016e211SJiucheng Xu MODULE_AUTHOR("Jiucheng Xu");
3922016e211SJiucheng Xu MODULE_LICENSE("GPL");
3932016e211SJiucheng Xu MODULE_DESCRIPTION("Amlogic G12 series SoC DDR PMU");
394