diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c index e36144c337cd..a51684f4bf0b 100644 --- a/drivers/platform/x86/intel_pmc_ipc.c +++ b/drivers/platform/x86/intel_pmc_ipc.c @@ -584,10 +584,35 @@ static struct itco_wdt_platform_data tco_info = { .update_no_reboot_bit = update_no_reboot_bit, }; -static int ipc_create_punit_device(struct platform_device *pdev) +static struct resource punit_resources[PLAT_RESOURCE_MEM_MAX_INDEX]; +static struct resource telemetry_resources[2]; +static struct resource wdt_resources[2]; + +static struct mfd_cell pmc_cell[] = { + { + .name = "intel_punit_ipc", + .resources = punit_resources, + .num_resources = PLAT_RESOURCE_MEM_MAX_INDEX, + .ignore_resource_conflicts = true, + }, + { + .name = "intel_telemetry", + .resources = telemetry_resources, + .num_resources = 2, + .ignore_resource_conflicts = true, + }, + { + .name = "iTCO_wdt", + .resources = wdt_resources, + .num_resources = 2, + .ignore_resource_conflicts = true, + .platform_data = &tco_info, + .pdata_size = sizeof(tco_info), + }, +}; + +static int ipc_get_punit_resources(struct platform_device *pdev) { - struct resource punit_res[PLAT_RESOURCE_MEM_MAX_INDEX]; - struct mfd_cell punit_cell; struct resource *res; int mindex, pindex = 0; @@ -616,30 +641,20 @@ static int ipc_create_punit_device(struct platform_device *pdev) * resource */ if (res) - memcpy(&punit_res[pindex], res, sizeof(*res)); - punit_res[pindex].flags = IORESOURCE_MEM; - dev_dbg(&pdev->dev, "PUNIT memory res: %pR\n", - &punit_res[pindex]); + memcpy(&punit_resources[pindex], res, + sizeof(*res)); + punit_resources[pindex].flags = IORESOURCE_MEM; pindex++; break; }; } - /* Create PUNIT IPC MFD cell */ - punit_cell.name = PUNIT_DEVICE_NAME; - punit_cell.num_resources = ARRAY_SIZE(punit_res); - punit_cell.resources = punit_res; - punit_cell.ignore_resource_conflicts = 1; - - return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, - &punit_cell, 1, NULL, 0, NULL); + return 0; } -static int ipc_create_wdt_device(struct platform_device *pdev) +static int ipc_get_wdt_resources(struct platform_device *pdev) { - static struct resource wdt_ipc_res[2]; struct resource *res; - static struct mfd_cell wdt_cell; /* If we have ACPI based watchdog use that instead, othewise create * a MFD cell for iTCO watchdog @@ -655,33 +670,18 @@ static int ipc_create_wdt_device(struct platform_device *pdev) return -ENXIO; } - wdt_ipc_res[0].start = res->start + TCO_BASE_OFFSET; - wdt_ipc_res[0].end = res->start + - TCO_BASE_OFFSET + TCO_REGS_SIZE - 1; - wdt_ipc_res[0].flags = IORESOURCE_IO; - wdt_ipc_res[1].start = res->start + SMI_EN_OFFSET; - wdt_ipc_res[1].end = res->start + - SMI_EN_OFFSET + SMI_EN_SIZE - 1; - wdt_ipc_res[1].flags = IORESOURCE_IO; - - dev_dbg(&pdev->dev, "watchdog res 0: %pR\n", &wdt_ipc_res[0]); - dev_dbg(&pdev->dev, "watchdog res 1: %pR\n", &wdt_ipc_res[1]); - - wdt_cell.name = TCO_DEVICE_NAME; - wdt_cell.platform_data = &tco_info; - wdt_cell.pdata_size = sizeof(tco_info); - wdt_cell.num_resources = ARRAY_SIZE(wdt_ipc_res); - wdt_cell.resources = wdt_ipc_res; - wdt_cell.ignore_resource_conflicts = 1; - - return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, - &wdt_cell, 1, NULL, 0, NULL); + wdt_resources[0].start = res->start + TCO_BASE_OFFSET; + wdt_resources[0].end = res->start + TCO_BASE_OFFSET + TCO_REGS_SIZE - 1; + wdt_resources[0].flags = IORESOURCE_IO; + wdt_resources[1].start = res->start + SMI_EN_OFFSET; + wdt_resources[1].end = res->start + SMI_EN_OFFSET + SMI_EN_SIZE - 1; + wdt_resources[1].flags = IORESOURCE_IO; + + return 0; } -static int ipc_create_telemetry_device(struct platform_device *pdev) +static int ipc_get_telemetry_resources(struct platform_device *pdev) { - struct resource telemetry_ipc_res[2]; - struct mfd_cell telemetry_cell; struct resource *res; /* Get telemetry resources */ @@ -692,44 +692,36 @@ static int ipc_create_telemetry_device(struct platform_device *pdev) return -ENXIO; } - telemetry_ipc_res[0].start = res->start + TELEM_PUNIT_SSRAM_OFFSET; - telemetry_ipc_res[0].end = res->start + - TELEM_PUNIT_SSRAM_OFFSET + TELEM_SSRAM_SIZE - 1; - telemetry_ipc_res[0].flags = IORESOURCE_MEM; - telemetry_ipc_res[1].start = res->start + TELEM_PMC_SSRAM_OFFSET; - telemetry_ipc_res[1].end = res->start + - TELEM_PMC_SSRAM_OFFSET + TELEM_SSRAM_SIZE - 1; - telemetry_ipc_res[1].flags = IORESOURCE_MEM; - - dev_dbg(&pdev->dev, "Telemetry res 0: %pR\n", &telemetry_ipc_res[0]); - dev_dbg(&pdev->dev, "Telemetry res 1: %pR\n", &telemetry_ipc_res[1]); - - telemetry_cell.name = TELEMETRY_DEVICE_NAME; - telemetry_cell.num_resources = ARRAY_SIZE(telemetry_ipc_res); - telemetry_cell.resources = telemetry_ipc_res; - telemetry_cell.ignore_resource_conflicts = 1; - - return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, - &telemetry_cell, 1, NULL, 0, NULL); + telemetry_resources[0].start = res->start + TELEM_PUNIT_SSRAM_OFFSET; + telemetry_resources[0].end = res->start + TELEM_PUNIT_SSRAM_OFFSET + + TELEM_SSRAM_SIZE - 1; + telemetry_resources[0].flags = IORESOURCE_MEM; + telemetry_resources[1].start = res->start + TELEM_PMC_SSRAM_OFFSET; + telemetry_resources[1].end = res->start + TELEM_PMC_SSRAM_OFFSET + + TELEM_SSRAM_SIZE - 1; + telemetry_resources[1].flags = IORESOURCE_MEM; + + return 0; } static int ipc_create_pmc_devices(struct platform_device *pdev) { int ret; - ret = ipc_create_punit_device(pdev); + ret = ipc_get_wdt_resources(pdev); if (ret < 0) return ret; - ret = ipc_create_wdt_device(pdev); + ret = ipc_get_punit_resources(pdev); if (ret < 0) return ret; - ret = ipc_create_telemetry_device(pdev); + ret = ipc_get_telemetry_resources(pdev); if (ret < 0) return ret; - return 0; + return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, pmc_cell, + ARRAY_SIZE(pmc_cell), NULL, 0, NULL); } static int ipc_plat_get_res(struct platform_device *pdev)