-
Notifications
You must be signed in to change notification settings - Fork 90
DNM: psci-mfd driver for review #389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,7 +129,7 @@ static const struct of_device_id psci_of_match[] = { | |
|
|
||
| static int psci_cpuidle_domain_probe(struct platform_device *pdev) | ||
| { | ||
| struct device_node *np = pdev->dev.of_node; | ||
| struct device_node *np = pdev->dev.parent->of_node; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file should drop its of_device_id table in favor of being probed by the MFD parent exclusively. |
||
| bool use_osi = psci_has_osi_support(); | ||
| int ret = 0, pd_count = 0; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| // SPDX-License-Identifier: GPL-2.0-only | ||
| /* | ||
| * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| */ | ||
|
|
||
| #include <linux/module.h> | ||
| #include <linux/device.h> | ||
| #include <linux/platform_device.h> | ||
| #include <linux/mfd/core.h> | ||
| #include <linux/of.h> | ||
| #include <linux/string.h> | ||
|
|
||
| static const struct mfd_cell psci_cells[] = { | ||
| { | ||
| .name = "psci-cpuidle-domain", | ||
| }, | ||
| { | ||
| .name = "psci-reboot-mode", | ||
| }, | ||
| }; | ||
|
|
||
| static int psci_mfd_match_pdev_name(struct device *dev, const void *data) | ||
| { | ||
| struct platform_device *pdev; | ||
|
|
||
| if (dev->bus != &platform_bus_type) | ||
| return 0; | ||
|
|
||
| pdev = to_platform_device(dev); | ||
|
|
||
| return !strcmp(pdev->name, data); | ||
| } | ||
|
|
||
| static void psci_mfd_bind_reboot_mode_node(struct platform_device *pdev) | ||
| { | ||
| struct device_node *np; | ||
| struct device *child; | ||
|
|
||
| if (!pdev->dev.of_node) | ||
| return; | ||
|
|
||
| np = of_get_child_by_name(pdev->dev.of_node, "reboot-mode"); | ||
| if (!np) | ||
| return; | ||
|
|
||
| child = device_find_child(&pdev->dev, "psci-reboot-mode", | ||
| psci_mfd_match_pdev_name); | ||
| if (!child) { | ||
| dev_dbg(&pdev->dev, "psci-reboot-mode child not found\n"); | ||
| of_node_put(np); | ||
| return; | ||
| } | ||
|
|
||
| device_set_node(child, of_fwnode_handle(np)); | ||
| put_device(child); | ||
| of_node_put(np); | ||
| } | ||
|
|
||
| static int psci_mfd_probe(struct platform_device *pdev) | ||
| { | ||
| int ret; | ||
|
|
||
| ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO, psci_cells, | ||
| ARRAY_SIZE(psci_cells), NULL, 0, NULL); | ||
| if (ret) | ||
| goto out; | ||
|
|
||
| psci_mfd_bind_reboot_mode_node(pdev); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is racy, the sub-device could have already been probed at this time after |
||
|
|
||
| out: | ||
| return ret; | ||
| } | ||
|
|
||
| static const struct of_device_id psci_mfd_of_match[] = { | ||
| { .compatible = "arm,psci-1.0" }, | ||
| { } | ||
| }; | ||
| MODULE_DEVICE_TABLE(of, psci_mfd_of_match); | ||
|
|
||
| static struct platform_driver psci_mfd_driver = { | ||
| .probe = psci_mfd_probe, | ||
| .driver = { | ||
| .name = "psci-mfd", | ||
| .of_match_table = psci_mfd_of_match, | ||
| }, | ||
| }; | ||
|
|
||
| static int __init psci_mfd_init(void) | ||
| { | ||
| return platform_driver_register(&psci_mfd_driver); | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop newline |
||
| core_initcall(psci_mfd_init); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -348,6 +348,16 @@ config NVMEM_REBOOT_MODE | |
| then the bootloader can read it and take different | ||
| action according to the mode. | ||
|
|
||
| config PSCI_REBOOT_MODE | ||
| bool "PSCI reboot mode driver" | ||
| depends on OF && ARM_PSCI_FW | ||
| select REBOOT_MODE | ||
| help | ||
| Say y here will enable PSCI reboot mode driver. This gets | ||
| the PSCI reboot mode arguments and passes them to psci | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some whitespace issue |
||
| driver. psci driver uses these arguments for issuing | ||
| device reset into different boot states. | ||
|
|
||
| config POWER_MLXBF | ||
| tristate "Mellanox BlueField power handling driver" | ||
| depends on (GPIO_MLXBF2 || GPIO_MLXBF3) && ACPI | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| // SPDX-License-Identifier: GPL-2.0-only | ||
| /* | ||
| * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| */ | ||
|
|
||
| #include <linux/device/faux.h> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like leftover. |
||
| #include <linux/device.h> | ||
| #include <linux/err.h> | ||
| #include <linux/of.h> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't seem to be using this nor err.h |
||
| #include <linux/psci.h> | ||
| #include <linux/reboot.h> | ||
| #include <linux/reboot-mode.h> | ||
| #include <linux/types.h> | ||
| #include <linux/platform_device.h> | ||
| #include <linux/module.h> | ||
|
|
||
| /* | ||
| * Predefined reboot-modes are defined as per the values | ||
| * of enum reboot_mode defined in the kernel: reboot.c. | ||
| */ | ||
| static struct mode_info psci_resets[] = { | ||
| { .mode = "warm", .magic = REBOOT_WARM}, | ||
| { .mode = "soft", .magic = REBOOT_SOFT}, | ||
| { .mode = "cold", .magic = REBOOT_COLD}, | ||
| }; | ||
|
|
||
| static void psci_reboot_mode_set_predefined_modes(struct reboot_mode_driver *reboot) | ||
| { | ||
| INIT_LIST_HEAD(&reboot->predefined_modes); | ||
| for (u32 i = 0; i < ARRAY_SIZE(psci_resets); i++) { | ||
| /* Prepare the magic with arg1 as 0 and arg2 as per pre-defined mode */ | ||
| psci_resets[i].magic = REBOOT_MODE_MAGIC(0, psci_resets[i].magic); | ||
| INIT_LIST_HEAD(&psci_resets[i].list); | ||
| list_add_tail(&psci_resets[i].list, &reboot->predefined_modes); | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| * arg1 is reset_type(Low 32 bit of magic). | ||
| * arg2 is cookie(High 32 bit of magic). | ||
| * If reset_type is 0, cookie will be used to decide the reset command. | ||
| */ | ||
| static int psci_reboot_mode_write(struct reboot_mode_driver *reboot, u64 magic) | ||
| { | ||
| u32 reset_type = REBOOT_MODE_ARG1(magic); | ||
| u32 cookie = REBOOT_MODE_ARG2(magic); | ||
|
|
||
| pr_err("DEBUG: PSCI write called"); | ||
| pr_err("DEBUG: PSCI write called"); | ||
| pr_err("DEBUG: PSCI write called"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these leftovers from development? |
||
| if (reset_type == 0) { | ||
| if (cookie == REBOOT_WARM || cookie == REBOOT_SOFT) | ||
| psci_set_reset_cmd(true, 0, 0); | ||
| else | ||
| psci_set_reset_cmd(false, 0, 0); | ||
| } else { | ||
| psci_set_reset_cmd(true, reset_type, cookie); | ||
| } | ||
|
|
||
| return NOTIFY_DONE; | ||
| } | ||
|
|
||
| static int psci_reboot_mode_probe(struct platform_device *pdev) | ||
| { | ||
| struct reboot_mode_driver *reboot; | ||
| int ret; | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
| reboot = devm_kzalloc(&pdev->dev, sizeof(*reboot), GFP_KERNEL); | ||
| if (!reboot) | ||
| return -ENOMEM; | ||
|
|
||
| psci_reboot_mode_set_predefined_modes(reboot); | ||
| reboot->write = psci_reboot_mode_write; | ||
| reboot->dev = &pdev->dev; | ||
|
|
||
| ret = devm_reboot_mode_register(&pdev->dev, reboot); | ||
| if (ret) { | ||
| dev_err_probe(&pdev->dev, ret, "devm_reboot_mode_register failed %d\n", ret); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| return ret; | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| static struct platform_driver psci_reboot_mode_driver = { | ||
| .probe = psci_reboot_mode_probe, | ||
| .driver = { | ||
| .name = "psci-reboot-mode", | ||
| }, | ||
| }; | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can drop this newline. |
||
| module_platform_driver(psci_reboot_mode_driver); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this needs to depend on MFD_PSCI.