drivers/soc/hisilicon/kunpeng_hccs.c
Source file repositories/reference/linux-study-clean/drivers/soc/hisilicon/kunpeng_hccs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/hisilicon/kunpeng_hccs.c- Extension
.c- Size
- 45694 bytes
- Lines
- 1833
- Domain
- Driver Families
- Bucket
- drivers/soc
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/delay.hlinux/iopoll.hlinux/platform_device.hlinux/stringify.hlinux/sysfs.hlinux/types.hacpi/pcc.hkunpeng_hccs.h
Detected Declarations
struct hccs_register_ctxfunction Systemfunction hccs_name_to_port_typefunction hccs_get_register_cbfunction hccs_get_pcc_chan_idfunction hccs_chan_tx_donefunction hccs_pcc_rx_callbackfunction hccs_unregister_pcc_channelfunction hccs_register_pcc_channelfunction hccs_wait_cmd_complete_by_pollfunction hccs_wait_cmd_complete_by_irqfunction hccs_fill_pcc_shared_mem_regionfunction hccs_fill_ext_pcc_shared_mem_regionfunction hccs_pcc_cmd_sendfunction hccs_init_req_descfunction hccs_get_dev_capsfunction hccs_query_chip_num_on_platformfunction hccs_get_chip_infofunction hccs_query_chip_info_on_platformfunction hccs_query_die_info_on_chipfunction hccs_query_all_die_info_on_platformfunction hccs_get_bd_infofunction hccs_get_all_port_attrfunction hccs_get_all_port_info_on_diefunction hccs_query_all_port_info_on_platformfunction hccs_get_hw_infofunction hccs_calc_used_type_numfunction hccs_init_type_name_mapsfunction for_each_set_bitfunction hccs_query_port_link_statusfunction hccs_query_port_crc_err_cntfunction hccs_get_die_all_link_statusfunction hccs_get_die_all_port_lane_statusfunction hccs_get_die_total_crc_err_cntfunction hccs_showfunction type_showfunction lane_mode_showfunction enable_showfunction cur_lane_num_showfunction link_fsm_showfunction lane_mask_showfunction crc_err_cnt_showfunction all_linked_on_die_showfunction linked_full_lane_on_die_showfunction crc_err_cnt_sum_on_die_showfunction all_linked_on_chip_showfunction linked_full_lane_on_chip_showfunction crc_err_cnt_sum_on_chip_show
Annotated Snippet
struct hccs_register_ctx {
struct device *dev;
u8 chan_id;
int err;
};
static acpi_status hccs_get_register_cb(struct acpi_resource *ares,
void *context)
{
struct acpi_resource_generic_register *reg;
struct hccs_register_ctx *ctx = context;
if (ares->type != ACPI_RESOURCE_TYPE_GENERIC_REGISTER)
return AE_OK;
reg = &ares->data.generic_reg;
if (reg->space_id != ACPI_ADR_SPACE_PLATFORM_COMM) {
dev_err(ctx->dev, "Bad register resource.\n");
ctx->err = -EINVAL;
return AE_ERROR;
}
ctx->chan_id = reg->access_size;
return AE_OK;
}
static int hccs_get_pcc_chan_id(struct hccs_dev *hdev)
{
acpi_handle handle = ACPI_HANDLE(hdev->dev);
struct hccs_register_ctx ctx = {0};
acpi_status status;
if (!acpi_has_method(handle, METHOD_NAME__CRS)) {
dev_err(hdev->dev, "No _CRS method.\n");
return -ENODEV;
}
ctx.dev = hdev->dev;
status = acpi_walk_resources(handle, METHOD_NAME__CRS,
hccs_get_register_cb, &ctx);
if (ACPI_FAILURE(status))
return ctx.err;
hdev->chan_id = ctx.chan_id;
return 0;
}
static void hccs_chan_tx_done(struct mbox_client *cl, void *msg, int ret)
{
if (ret < 0)
pr_debug("TX did not complete: CMD sent:0x%x, ret:%d\n",
*(u8 *)msg, ret);
else
pr_debug("TX completed. CMD sent:0x%x, ret:%d\n",
*(u8 *)msg, ret);
}
static void hccs_pcc_rx_callback(struct mbox_client *cl, void *mssg)
{
struct hccs_mbox_client_info *cl_info =
container_of(cl, struct hccs_mbox_client_info, client);
complete(&cl_info->done);
}
static void hccs_unregister_pcc_channel(struct hccs_dev *hdev)
{
pcc_mbox_free_channel(hdev->cl_info.pcc_chan);
}
static int hccs_register_pcc_channel(struct hccs_dev *hdev)
{
struct hccs_mbox_client_info *cl_info = &hdev->cl_info;
struct mbox_client *cl = &cl_info->client;
struct pcc_mbox_chan *pcc_chan;
struct mbox_chan *mbox_chan;
struct device *dev = hdev->dev;
int rc;
cl->dev = dev;
cl->tx_block = false;
cl->knows_txdone = true;
cl->tx_done = hccs_chan_tx_done;
cl->rx_callback = hdev->verspec_data->rx_callback;
init_completion(&cl_info->done);
pcc_chan = pcc_mbox_request_channel(cl, hdev->chan_id);
if (IS_ERR(pcc_chan)) {
dev_err(dev, "PCC channel request failed.\n");
rc = -ENODEV;
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/delay.h`, `linux/iopoll.h`, `linux/platform_device.h`, `linux/stringify.h`, `linux/sysfs.h`, `linux/types.h`, `acpi/pcc.h`.
- Detected declarations: `struct hccs_register_ctx`, `function System`, `function hccs_name_to_port_type`, `function hccs_get_register_cb`, `function hccs_get_pcc_chan_id`, `function hccs_chan_tx_done`, `function hccs_pcc_rx_callback`, `function hccs_unregister_pcc_channel`, `function hccs_register_pcc_channel`, `function hccs_wait_cmd_complete_by_poll`.
- Atlas domain: Driver Families / drivers/soc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.