Lines Matching refs:sock

89 	struct hsmp_socket *sock;  member
98 static int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset, in amd_hsmp_pci_rdwr() argument
103 if (!sock->root) in amd_hsmp_pci_rdwr()
106 ret = pci_write_config_dword(sock->root, HSMP_INDEX_REG, in amd_hsmp_pci_rdwr()
107 sock->mbinfo.base_addr + offset); in amd_hsmp_pci_rdwr()
111 ret = (write ? pci_write_config_dword(sock->root, HSMP_DATA_REG, *value) in amd_hsmp_pci_rdwr()
112 : pci_read_config_dword(sock->root, HSMP_DATA_REG, value)); in amd_hsmp_pci_rdwr()
117 static void amd_hsmp_acpi_rdwr(struct hsmp_socket *sock, u32 offset, in amd_hsmp_acpi_rdwr() argument
121 iowrite32(*value, sock->virt_base_addr + offset); in amd_hsmp_acpi_rdwr()
123 *value = ioread32(sock->virt_base_addr + offset); in amd_hsmp_acpi_rdwr()
126 static int amd_hsmp_rdwr(struct hsmp_socket *sock, u32 offset, in amd_hsmp_rdwr() argument
130 amd_hsmp_acpi_rdwr(sock, offset, value, write); in amd_hsmp_rdwr()
132 return amd_hsmp_pci_rdwr(sock, offset, value, write); in amd_hsmp_rdwr()
147 static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *msg) in __hsmp_send_message() argument
155 mbinfo = &sock->mbinfo; in __hsmp_send_message()
159 ret = amd_hsmp_rdwr(sock, mbinfo->msg_resp_off, &mbox_status, HSMP_WR); in __hsmp_send_message()
168 ret = amd_hsmp_rdwr(sock, mbinfo->msg_arg_off + (index << 2), in __hsmp_send_message()
178 ret = amd_hsmp_rdwr(sock, mbinfo->msg_id_off, &msg->msg_id, HSMP_WR); in __hsmp_send_message()
195 ret = amd_hsmp_rdwr(sock, mbinfo->msg_resp_off, &mbox_status, HSMP_RD); in __hsmp_send_message()
230 ret = amd_hsmp_rdwr(sock, mbinfo->msg_arg_off + (index << 2), in __hsmp_send_message()
263 struct hsmp_socket *sock; in hsmp_send_message() local
272 if (!plat_dev.sock || msg->sock_ind >= plat_dev.num_sockets) in hsmp_send_message()
274 sock = &plat_dev.sock[msg->sock_ind]; in hsmp_send_message()
282 ret = down_timeout(&sock->hsmp_sem, msecs_to_jiffies(HSMP_MSG_TIMEOUT)); in hsmp_send_message()
286 ret = __hsmp_send_message(sock, msg); in hsmp_send_message()
288 up(&sock->hsmp_sem); in hsmp_send_message()
315 dev_err(plat_dev.sock[sock_ind].dev, in hsmp_test()
415 struct hsmp_socket *sock = data; in hsmp_resource() local
424 sock->mbinfo.base_addr = r.start; in hsmp_resource()
425 sock->mbinfo.size = resource_size(&r); in hsmp_resource()
436 static int hsmp_read_acpi_dsd(struct hsmp_socket *sock) in hsmp_read_acpi_dsd() argument
445 status = acpi_evaluate_object_typed(ACPI_HANDLE(sock->dev), "_DSD", NULL, in hsmp_read_acpi_dsd()
448 dev_err(sock->dev, "Failed to read mailbox reg offsets from DSD table, err: %s\n", in hsmp_read_acpi_dsd()
471 dev_err(sock->dev, "Invalid hsmp _DSD table data\n"); in hsmp_read_acpi_dsd()
493 sock->mbinfo.msg_id_off = msgint->integer.value; in hsmp_read_acpi_dsd()
496 sock->mbinfo.msg_resp_off = msgint->integer.value; in hsmp_read_acpi_dsd()
499 sock->mbinfo.msg_arg_off = msgint->integer.value; in hsmp_read_acpi_dsd()
506 if (!sock->mbinfo.msg_id_off || !sock->mbinfo.msg_resp_off || in hsmp_read_acpi_dsd()
507 !sock->mbinfo.msg_arg_off) in hsmp_read_acpi_dsd()
515 static int hsmp_read_acpi_crs(struct hsmp_socket *sock) in hsmp_read_acpi_crs() argument
519 status = acpi_walk_resources(ACPI_HANDLE(sock->dev), METHOD_NAME__CRS, in hsmp_read_acpi_crs()
520 hsmp_resource, sock); in hsmp_read_acpi_crs()
522 dev_err(sock->dev, "Failed to look up MP1 base address from CRS method, err: %s\n", in hsmp_read_acpi_crs()
526 if (!sock->mbinfo.base_addr || !sock->mbinfo.size) in hsmp_read_acpi_crs()
530 sock->virt_base_addr = devm_ioremap_uc(sock->dev, sock->mbinfo.base_addr, in hsmp_read_acpi_crs()
531 sock->mbinfo.size); in hsmp_read_acpi_crs()
532 if (!sock->virt_base_addr) { in hsmp_read_acpi_crs()
533 dev_err(sock->dev, "Failed to ioremap MP1 base address\n"); in hsmp_read_acpi_crs()
543 struct hsmp_socket *sock = &plat_dev.sock[sock_ind]; in hsmp_parse_acpi_table() local
546 sock->sock_ind = sock_ind; in hsmp_parse_acpi_table()
547 sock->dev = dev; in hsmp_parse_acpi_table()
550 sema_init(&sock->hsmp_sem, 1); in hsmp_parse_acpi_table()
553 ret = hsmp_read_acpi_crs(sock); in hsmp_parse_acpi_table()
558 return hsmp_read_acpi_dsd(sock); in hsmp_parse_acpi_table()
565 struct hsmp_socket *sock = bin_attr->private; in hsmp_metric_tbl_read() local
569 if (!sock) in hsmp_metric_tbl_read()
574 dev_err(sock->dev, "Wrong buffer size\n"); in hsmp_metric_tbl_read()
579 msg.sock_ind = sock->sock_ind; in hsmp_metric_tbl_read()
584 memcpy_fromio(buf, sock->metric_tbl_addr, bin_attr->size); in hsmp_metric_tbl_read()
591 struct hsmp_socket *sock = &plat_dev.sock[sock_ind]; in hsmp_get_tbl_dram_base() local
610 dev_err(sock->dev, "Invalid DRAM address for metric table\n"); in hsmp_get_tbl_dram_base()
613 sock->metric_tbl_addr = devm_ioremap(sock->dev, dram_addr, in hsmp_get_tbl_dram_base()
615 if (!sock->metric_tbl_addr) { in hsmp_get_tbl_dram_base()
616 dev_err(sock->dev, "Failed to ioremap metric table addr\n"); in hsmp_get_tbl_dram_base()
633 struct bin_attribute *hattr = &plat_dev.sock[sock_ind].hsmp_attr; in hsmp_init_metric_tbl_bin_attr()
640 hattr->private = &plat_dev.sock[sock_ind]; in hsmp_init_metric_tbl_bin_attr()
688 snprintf(plat_dev.sock[i].name, HSMP_ATTR_GRP_NAME_SIZE, "socket%u", (u8)i); in hsmp_create_non_acpi_sysfs_if()
689 attr_grp->name = plat_dev.sock[i].name; in hsmp_create_non_acpi_sysfs_if()
748 struct hsmp_socket *sock; in init_platform_device() local
754 sock = &plat_dev.sock[i]; in init_platform_device()
755 sock->root = node_to_amd_nb(i)->root; in init_platform_device()
756 sock->sock_ind = i; in init_platform_device()
757 sock->dev = dev; in init_platform_device()
758 sock->mbinfo.base_addr = SMN_HSMP_BASE; in init_platform_device()
765 sock->mbinfo.msg_id_off = SMN_HSMP_MSG_ID_F1A_M0H; in init_platform_device()
767 sock->mbinfo.msg_id_off = SMN_HSMP_MSG_ID; in init_platform_device()
769 sock->mbinfo.msg_resp_off = SMN_HSMP_MSG_RESP; in init_platform_device()
770 sock->mbinfo.msg_arg_off = SMN_HSMP_MSG_DATA; in init_platform_device()
771 sema_init(&sock->hsmp_sem, 1); in init_platform_device()
806 plat_dev.sock = devm_kcalloc(&pdev->dev, plat_dev.num_sockets, in hsmp_pltdrv_probe()
807 sizeof(*plat_dev.sock), in hsmp_pltdrv_probe()
809 if (!plat_dev.sock) in hsmp_pltdrv_probe()